General area when it fits no where else

Moderator: Mmiscool

User avatar
By Ecoli-557
#52497 Bugs, thanks.
I don't know for certain but I think my serial eavesdropper adds the spaces between bytes instead of the reader inserting the spaces.
That being said, I understand better your example.

I will confirm where the spaces are being generated for clarification.

Enjoy the Diving!
User avatar
By bugs
#52500 Ah - I missed that possiblity with the sniffer.
It would be interesting to see what you get just connecting the reader to a simple terminal program on pc.
I use Bray's terminal for all serial stuff:-
https://sites.google.com/site/terminalbpp/

I had a look at this site:-
http://www.seeedstudio.com/wiki/index.p ... put_format

and it seems that you are correct in that there are no space separators but there is a start character of 02 and an end character of 03 - these are the standard ASCII codes for STX and ETX (start and end of text).

I have a cheap RFID reader module on order from china so will be playing with that next month.
User avatar
By Ecoli-557
#52501 That is just what I found out...... you beat me by a bit (no pun).
The 0x02 and 0x03 are used in the larger RFID readers, this little unit does not output that; it just dumps 5 bytes, 4 of which are the 10 digit ID number followed by a byte of checksum. Cool little unit - less than postage stamp in size! Has a STM8S003F3 proc and a LM158 and comes with the coil antenna.

What I am needing is a way to read the serial data as HEX and not decimal, ASCII, or integer. Not really finding a way to that either.......
User avatar
By Ecoli-557
#52570 Bugs-
Below is my current code which has your suggestions as well as 2 new serial commands courtesy from Mike.
Code: Select allserialbranch [serialin]
wait

[serialin]
ID$ = ""
Do
    ID$ = str(serial.read.int()) & ID$
Loop while serial.available()

    print "received:" & ID$

'dimension string and numeric arrays
dim a$(5)
dim b(5)

'split the input string into pairs of ASCII characters
'i = 0
for ptr = 0 to 4
        a$(i) = mid(ID$,ptr,1)

'store the numeric values of the hex
    b(ptr) = hextoint(a$(ptr))
' i = i+1
next ptr

'calculate the crc - using the DECIMAL equivilent characters (works with calculator)

crc = b(0) xor b(1) xor b(2) xor b(3)
if crc <> b(4) then
 print "bad data"
else
 print "ok"

'reconstruct the hex value (without the spaces)
 tag$ = a$(0) & a$(1) & a$(2) & a$(3)
print "tag is:" & hextoint(tag$)
endif

end

The 2 new commands are
str(serial.read.int()
serial.available()
which come out of the ESP-duino stuff I was told.
When I run this my result is:
received:1341111071300 - I don't know why this is backwards.......
My serial eavesdropper gets this: 00 82 6B 6F 86 (spaces are for clarity only). 1st 4 bytes are for the Tag ID, 5th is checksum.
So the decimal equivalent should be: ‭8547183‬ which is exactly what the tag should read.
The program waits a bit and then prints:
ok
and then it prints
tag is:0

So, I understand what you are doing with the arrays but I still don't know how to get the hex correct so I can then strip off the 0x86 (in this example) and generate my own checksum for comparison to ensure a good read and good tag data.
THEN, generate the tag ID in decimal from the 4 hex digits.

BTW, without the 2 new commands, I was not getting anything from the reader - Thanks Mike!