root / toolbox / rfid.h @ 532ba0bd
History | View | Annotate | Download (1.43 KB)
1 | 9b2b6d91 | Tom Mullins | #ifndef RFID_H
|
---|---|---|---|
2 | #define RFID_H
|
||
3 | |||
4 | /* First byte back from rfid reader */
|
||
5 | #define RFID_OK 1 |
||
6 | |||
7 | /* Bytes in serial number on rfid tags */
|
||
8 | #define RFID_SERNO_SIZE 4 |
||
9 | |||
10 | /* In rfid_read_safe, it must read the same value RFID_MIN_OK times. If it
|
||
11 | * encounters RFID_MAX_ERRS read errors first, it will output all 0's. */
|
||
12 | #define RFID_MAX_ERRS 10 |
||
13 | #define RFID_MIN_OK 5 |
||
14 | |||
15 | /* Should be called before anything else */
|
||
16 | void rfid_init();
|
||
17 | |||
18 | 532ba0bd | Tom Mullins | /* Sends the read command to the rfid reader. After, you should call rfid_poll
|
19 | * until it returns nonzero */
|
||
20 | void rfid_start_read();
|
||
21 | |||
22 | /* Should only be called after rfid_start_read. Keep calling until it returns
|
||
23 | * nonzero, which means it is finished reading the serial number, and
|
||
24 | * rfid_get_serno can be called */
|
||
25 | char rfid_poll();
|
||
26 | 9b2b6d91 | Tom Mullins | |
27 | /* Attempts to read the serial number multiple times, and only accepts it if it
|
||
28 | 532ba0bd | Tom Mullins | * is the same every time. Don't use it */
|
29 | 9b2b6d91 | Tom Mullins | void rfid_read_safe();
|
30 | |||
31 | 532ba0bd | Tom Mullins | /* Call this only after rfid_poll returns nonzero. This will copy the value it
|
32 | * read into serno, which should be at least RFID_SERNO_SIZE bytes */
|
||
33 | 9b2b6d91 | Tom Mullins | void rfid_get_serno(char *serno); |
34 | |||
35 | 532ba0bd | Tom Mullins | /* Call this only after rfid_poll returns nonzero. Returns 1 if serno matches
|
36 | * the internal buffer of the most recently read serial number */
|
||
37 | 12ea39cc | Tom Mullins | char rfid_check_serno(char *serno); |
38 | |||
39 | 532ba0bd | Tom Mullins | /* Call this only after rfid_poll returns nonzero. Returns 1 if the internal
|
40 | * buffer is nonzero, meaning a serial number was successfully read from an
|
||
41 | * rfid tag */
|
||
42 | 12ea39cc | Tom Mullins | char rfid_nonzero();
|
43 | |||
44 | 9b2b6d91 | Tom Mullins | #endif |