Project

General

Profile

Statistics
| Branch: | Revision:

root / toolbox / rfid.h @ 12ea39cc

History | View | Annotate | Download (1.24 KB)

1
#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
/* Reads the serial number of an rfid tag into an internal buffer, accessible
19
 * with rfid_get_serno */
20
void rfid_read();
21

    
22
/* Attempts to read the serial number multiple times, and only accepts it if it
23
 * is the same every time. Use rfid_read instead until this one is proven
24
 * necessary */
25
void rfid_read_safe();
26

    
27
/* Call this only after calling rfid_read. This will copy the value it read
28
 * into serno, which should be at least RFID_SERNO_SIZE bytes */
29
void rfid_get_serno(char *serno);
30

    
31
/* Call this only after calling rfid_read. Returns 1 if serno matches the
32
 * internal buffer of the most recently read serial number */
33
char rfid_check_serno(char *serno);
34

    
35
/* Call this only after calling rfid_read. Returns 1 if the internal buffer is
36
 * nonzero, meaning a serial number was successfully read from an rfid tag */
37
char rfid_nonzero();
38

    
39
#endif