String multiple bytes into a usable string
deanwesterburg
Posts: 25
I am using code from the RFID_Basics.ZIP file on the Parallax site. They read an RFID tag by looping 10 times and reading one byte each time.
I would like to string the bytes all together into a usable string so I can evaluate the RFID number with a CASE statment.
Here is the code that loops 10 times to read the RFID tags
FOR idx = 0 TO 9 ' scan bytes in tag
#IF __No_SPRAM #THEN
SEROUT TX, LcdBaud, [buf(idx)]
#ELSE
GET idx, Char ' read char from SPRAM
SEROUT TX, LcdBaud, [Char]
#ENDIF
NEXT
Can someone help point me in the right direction on how to string each byte together?
Thanks!
I would like to string the bytes all together into a usable string so I can evaluate the RFID number with a CASE statment.
Here is the code that loops 10 times to read the RFID tags
FOR idx = 0 TO 9 ' scan bytes in tag
#IF __No_SPRAM #THEN
SEROUT TX, LcdBaud, [buf(idx)]
#ELSE
GET idx, Char ' read char from SPRAM
SEROUT TX, LcdBaud, [Char]
#ENDIF
NEXT
Can someone help point me in the right direction on how to string each byte together?
Thanks!
Comments
I have setup a tree of Case statements and evaluate each of the 10 bytes. If the byte matches, it moves down the tree and goes through those case statements.
It works, but there has got to be a better way.
It still stores and is handled in bytes.
Can you store them to an array with a pointer? You could write a dedicated compare routine for this.
RFID1 DATA "A",1,2,3,4,5,"XXXBC"
IDTAG VAR Byte(6)
ptr=RFID1
FOR n=0 to 5
READ ptr+n, i
IF i <> IDTAG(n) THEN flag=0:return 'Sequence failed
NEXT
flag=1 'Sequence confirmed
RETURN
Yes. I am trying to evaluate the entire ID of the tag, not just the last 2 values.