PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Simple-Libraries
Learn
Simple Libraries
Sensor
librfidser
librfidser.c
1
/*
2
librfidser.c
3
4
Test harness for rfidser library.
5
6
Enable -> P2
7
Sout -> P1
8
*/
9
10
#include "
simpletools.h
"
// Include simpletools
11
#include "
rfidser.h
"
// Include rfidser
12
13
int
rfidEn = 2;
// Reader /ENABLE pin
14
int
rfidSout = 1;
// Reader SOUT pin
15
16
rfidser *rfid;
// Set up device ID
17
18
int
main
()
// Main function
19
{
20
rfid =
rfid_open
(rfidSout, rfidEn);
// Open reader, start reading
21
22
while
(1)
// Main loop
23
{
24
char
*str =
rfid_get
(rfid, 1000);
// Wait up to 1 s for card
25
26
if
(!strcmp(str,
"timed out"
))
// Timed out?
27
print
(
"No ID scanned.\n"
);
// display "No ID..."
28
else
if
(!strcmp(str,
"70006E0299"
))
// Round card ID match?
29
print
(
"Round card.\n"
);
// diaplay "Round..."
30
else
if
(!strcmp(str,
"0200822A14"
))
// Rectangle card ID match?
31
print
(
"Rectangle card.\n"
);
// diaplay "Rectangle..."
32
else
// No matches?
33
print
(
"id = %s.\n"
, str);
// print ID.
34
}
35
}
36
rfid_get
char * rfid_get(rfidser *device, int timeoutms)
Get RFID code from serial buffer.
Definition:
rfidser.c:125
rfidser.h
Simplifies reading Parallax Serial RFID Card Reader.
simpletools.h
This library provides convenient functions for a variety of microcontroller I/O, timing,...
print
int print(const char *format,...) __attribute__((format(printf
Print format "..." args to the default simple terminal device. The output is limited to 256 bytes.
main
int main(void)
Definition:
GraphicsTest.c:20
rfid_open
rfidser * rfid_open(int soutPin, int enablePin)
Runs the RFID card reading process in another cog.
Definition:
rfidser.c:20
Generated on Fri May 20 2022 16:48:05 for PropWare by
1.8.17