Revision 6ca98a3f
Eradicated use of signed chars in serial d'oh
toolbox/rfid.c | ||
---|---|---|
1 | 1 |
#include <string.h> |
2 |
#include <stdint.h> |
|
2 | 3 |
#include <util/delay.h> |
3 | 4 |
#include "rfid.h" |
4 | 5 |
#include "serial.h" |
5 | 6 |
|
6 |
static char read_cmd[] = {'!', 'R', 'W', 1, 32};
|
|
7 |
static uint8_t read_cmd[] = {'!', 'R', 'W', 1, 32};
|
|
7 | 8 |
|
8 | 9 |
static int serno_idx; |
9 |
static char serno[RFID_SERNO_SIZE];
|
|
10 |
static uint8_t serno[RFID_SERNO_SIZE];
|
|
10 | 11 |
|
11 | 12 |
static void zero_serno() { |
12 | 13 |
int i; |
... | ... | |
72 | 73 |
char rfid_poll() { |
73 | 74 |
int c; |
74 | 75 |
|
75 |
c = serial_read(); |
|
76 |
while (c >= 0) { |
|
76 |
while ((c = serial_read()) >= 0) { |
|
77 | 77 |
|
78 | 78 |
if (serno_idx < 0) { |
79 | 79 |
if (c != RFID_OK) { |
... | ... | |
89 | 89 |
return 1; |
90 | 90 |
} |
91 | 91 |
|
92 |
c = serial_read(); |
|
93 | 92 |
} |
94 | 93 |
|
95 | 94 |
return 0; |
96 | 95 |
} |
97 | 96 |
|
98 |
void rfid_get_serno(char *buf) {
|
|
97 |
void rfid_get_serno(uint8_t *buf) {
|
|
99 | 98 |
memcpy(buf, serno, sizeof(serno)); |
100 | 99 |
} |
101 | 100 |
|
102 |
char rfid_check_serno(char *buf) {
|
|
101 |
char rfid_check_serno(uint8_t *buf) {
|
|
103 | 102 |
return memcmp(buf, serno, sizeof(serno)) == 0; |
104 | 103 |
} |
105 | 104 |
|
Also available in: Unified diff