Raspberry Pi Weighting Control System
This project serves as a simple weighting control system, that was realized as a Bachelor Thesis
rfid_reader.h
Go to the documentation of this file.
1 #ifndef RFID_READER_H
2 #define RFID_READER_H
3 
4 struct rfid_e;
5 typedef struct rfid_e rfid_event;
6 
7 namespace rfid_reader {
12  typedef struct {
13  uint16_t tag_type;
14  uint8_t serial[10] = {0};
15  uint8_t serial_size;
16  uint8_t ser_ack[3] = {0};
17  int32_t max_blocks = 64;
18  uint8_t page_step = 0;
19  } rfid_tag;
20 
21 
32  void clear_event_queue();
33 
39  int init(const char*, uint8_t, uint32_t, uint16_t, uint8_t);
45  int init_from_conf();
50  void start_reading_cards();
55  void clean();
56 
57  // following 3 functions are taken from https://github.com/paulvha/rfid-rc522.git
66  char detect_tag(uint16_t *tag_type, uint8_t *buff);
75  char read_tag_serialn(uint8_t *serial, uint8_t *serial_size, uint8_t *ser_ack, uint8_t *buff);
84  int read_tag(rfid_tag *tag);
85 }
86 
93  RFID_FLAGS_REPEATING = 0x01 << 0
94 };
95 
100 struct rfid_e {
102  uint8_t flags;
103 };
104 
105 #endif
int init(const char *device, uint8_t mode=0, uint32_t speed=1000000, uint16_t delay=0, uint8_t bits_per_word=8)
RFID reader init through values.
Definition: rfid_reader.cpp:25
int init_from_conf()
RFID reader init from loaded configuration.
Definition: rfid_reader.cpp:46
char read_tag_serialn(uint8_t *serial, uint8_t *serial_size, uint8_t *ser_ack, uint8_t *buff)
This function reads the serial number of RIFD tag put near the reader.
void clean()
Stops the reading thread.
void clear_event_queue()
Clears event queue, discarding all waiting events.
int read_tag(rfid_tag *tag)
This function is a loop handling the scanner.
rfid_event * poll_event()
Polls event from RFID event_queue.
char detect_tag(uint16_t *tag_type, uint8_t *buff)
This function detects if a RFID tag was put near the reader.
void start_reading_cards()
Loop that is run in its own thread, reading the RFID reader.
Definition: rfid_reader.cpp:76
RFID_FLAGS_
Flags of RFID events.
Definition: rfid_reader.h:91
@ RFID_FLAGS_REPEATING
Definition: rfid_reader.h:93
@ RFID_FLAGS_NONE
Definition: rfid_reader.h:92
Structure used for RFID event. This structure contains read tag and flags of the event.
Definition: rfid_reader.h:100
uint8_t flags
Definition: rfid_reader.h:102
rfid_reader::rfid_tag tag
Definition: rfid_reader.h:101
RFID tag structure. Stores data read from SPI.
Definition: rfid_reader.h:12