Project

General

Profile

Revision 269

Added by Kevin Woo almost 14 years ago

Parity check implemented

View differences:

trunk/cardbox/cardreader.c
126 126

  
127 127
    byte = 0;
128 128
    byte_idx = 0;
129
    parity = 0;
129 130

  
130 131
    while (i >= 0) {
131 132
        // Parity bit
132 133
        if (byte_idx == CR_MAX_IDX) {
133 134

  
135
            if (!(cr_buf[i]) != (parity % 2)) {
136
                rs485_send_byte('F');
137
            }
138

  
134 139
            rs485_send_byte(cr_dict[byte]);
135 140

  
136 141
            // Stop at the stop sentinal
......
140 145

  
141 146
            byte_idx = 0;
142 147
            byte = 0;
148
            parity = 0;
143 149
            
144 150
        // Data bits
145 151
        } else {
146 152
            byte = (((byte >> 1) & 0x1F) | (cr_buf[i]));
147 153
            byte_idx++;
154
            parity += (cr_buf[i] == 0) ? 0 : 1;
148 155
        }
149 156

  
150 157
        // Goto next bit in cr_buf

Also available in: Unified diff