RFID Read When the Card Touch
Show older comments
Hello, I wrote a program where fscanf() should run in continuous, for the sake of getting data & storing into my database from RFID, which is connected with serial cable, two callback are there, when I'm running first callback the code contain while(1), run infinite and take the data from RFID reader and storing it. When the callback is running in which while (1) is present the program cant move on any other function or callback. How can I control it ? or what is the shortest way to read data from RFID ? Is it possible to read data only when the RFID Card/Tag touch to RFID Reader ?
2 Comments
Khalid
on 14 May 2014
Edited: Walter Roberson
on 14 May 2014
Walter Roberson
on 14 May 2014
Is there a line terminator? Is the string width fixed per sample?
Answers (1)
Walter Roberson
on 14 May 2014
0 votes
Set the serial port up with a BytesAvailableFcn that runs when the RFID information is detected as having been presented to the serial device. In that callback, fread() or fgetl() from the serial port to transfer from the buffer into your program.
You can check the BytesAvailable property of the serial port to determine whether anything has been received and transferred into the buffer.
1 Comment
Walter Roberson
on 14 May 2014
s.BytesAvailableFcn = @(src, evt) fastinsert(conn, 'RFID_FINAL', col, {fgetl(s)});
and then no loop will be needed: the callback will be triggered when data is available.
Categories
Find more on Characters and Strings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!