Library for the Robotics RedBee™RFID Reader.
robotics_rfid_reader.cpp@0:9765e979a653, 2021-11-10 (annotated)
- Committer:
- Sebastien Prouff
- Date:
- Wed Nov 10 16:46:03 2021 +0100
- Revision:
- 0:9765e979a653
initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Sebastien Prouff |
0:9765e979a653 | 1 | #include "robotics_rfid_reader.h" |
Sebastien Prouff |
0:9765e979a653 | 2 | |
Sebastien Prouff |
0:9765e979a653 | 3 | /** |
Sebastien Prouff |
0:9765e979a653 | 4 | * @file robotics_rfid_reader.cpp |
Sebastien Prouff |
0:9765e979a653 | 5 | * @brief RFID Robotics reader class |
Sebastien Prouff |
0:9765e979a653 | 6 | * @author sepro |
Sebastien Prouff |
0:9765e979a653 | 7 | * @version 1.0 |
Sebastien Prouff |
0:9765e979a653 | 8 | * @class RoboticsRfidReader |
Sebastien Prouff |
0:9765e979a653 | 9 | * @date 31/01/2021 |
Sebastien Prouff |
0:9765e979a653 | 10 | */ |
Sebastien Prouff |
0:9765e979a653 | 11 | |
Sebastien Prouff |
0:9765e979a653 | 12 | RoboticsRfidReader::RoboticsRfidReader(PinName Tx, PinName Rx) |
Sebastien Prouff |
0:9765e979a653 | 13 | : _rfid(Tx, Rx) |
Sebastien Prouff |
0:9765e979a653 | 14 | |
Sebastien Prouff |
0:9765e979a653 | 15 | { |
Sebastien Prouff |
0:9765e979a653 | 16 | _rfid.baud(9600); |
Sebastien Prouff |
0:9765e979a653 | 17 | _rfid.format(8, SerialBase::None, 1); |
Sebastien Prouff |
0:9765e979a653 | 18 | } |
Sebastien Prouff |
0:9765e979a653 | 19 | |
Sebastien Prouff |
0:9765e979a653 | 20 | |
Sebastien Prouff |
0:9765e979a653 | 21 | bool RoboticsRfidReader::rfidRead(unsigned char *tampon) { |
Sebastien Prouff |
0:9765e979a653 | 22 | static int iBuffer = 0; |
Sebastien Prouff |
0:9765e979a653 | 23 | |
Sebastien Prouff |
0:9765e979a653 | 24 | if (_rfid.readable()) { |
Sebastien Prouff |
0:9765e979a653 | 25 | _rfid.read(&_c,1); |
Sebastien Prouff |
0:9765e979a653 | 26 | tampon[iBuffer++] = _c; |
Sebastien Prouff |
0:9765e979a653 | 27 | if (_c == '\n') { |
Sebastien Prouff |
0:9765e979a653 | 28 | tampon[iBuffer] = 0; |
Sebastien Prouff |
0:9765e979a653 | 29 | iBuffer = 0; |
Sebastien Prouff |
0:9765e979a653 | 30 | return true; |
Sebastien Prouff |
0:9765e979a653 | 31 | } |
Sebastien Prouff |
0:9765e979a653 | 32 | } |
Sebastien Prouff |
0:9765e979a653 | 33 | return false; |
Sebastien Prouff |
0:9765e979a653 | 34 | } |