General area when it fits no where else

Moderator: Mmiscool

User avatar
By Ecoli-557
#52346 Good Afternoon-
I am trying to get serial data from a RFID reader and the data is in the format:
1.9600bps,N,8,1
2.CHECKSUM: card 10byte DATA entire do XOR operation
|-02-|-----10 ASCII Data Characters-----|-----Chechsum-----|-03-|

Output date(HEX): 02 | 30 31 30 30 30 37 33 34 45 30 | 44 32 | 03
->Change to Decimal
CardNumber Decimal: 48 49 48 48 48 55 51 52 69 48
CheckSum Decimal: 68 50
->Refer to ASCII table,get Ascill value
CardNumber Ascill: 0 1 0 0 0 7 3 4 E 0
CheckSum Ascill : D 2
(01H) xor (00H) xor (07H) xor (34H) xor (E0H) = D2H

How would I read the data when I don't know when a read will take place, and it does not terminate with a CR/LF?
As a test code I have tried the below but nothing prints when I bring a card near the coil
Code: Select allbaudrate 9600
[start]
serialinput ID
print ID
goto [start]


Maybe a serialbranch with a known character length????
OR trigger on a sync byte???
New idea for the interpreter??
User avatar
By Ecoli-557
#52350 UPDATE:
I did go ahead and try the serial2 as well as the serialbranch - still doesn't work, but here is updated code:
Code: Select allserial2begin 9600, 1 , 3
serial2branch [serialin]
wait

[serialin]
serial2input ID$
print “received:”
print ID$
return


The above does not give any errors, but doesn't work.
Interesting enough however that my serial 'sniffer' which listens to the output of the RFID chip only gives me 5 hex bytes: 00 81 91 8F 9F
curious.
Anyone use a RFID chip or module? This one is the Seeedstudio Mini 125Khz RFID Module.
User avatar
By Mmiscool
#52378 Try it like this.

Code: Select allserialbranch [serialin]
wait

[serialin]
delay 1000   ' give it some time to catch all of the string.
serialinput ID$
print "received:"
print ID$
return
User avatar
By Ecoli-557
#52413 Thanks Mike for the input. Still doesn't seem to work. I get the following error:
Error at line 9: Failed to reach end of input expression, likely malformed input error
Present code below:
Code: Select all'serial2begin 9600, 1 , 3
baudrate 9600
serialbranch [serialin]
wait

[serialin]
delay 1000
serialinput ID$
print “received:”
print ID$
return

Line 9 is the print "received:" line.
Just a thought, I have my reader on GPIO3 for receive - this IS the correct pin??