OK. I have sort of solved my own problem. The following code works:
Include "modedefs.bas" ' Include serial modes
DEFINE OSC 20
SO var portb.0 ' Define serial out pin
SI var portb.1 ' Define serial in pin
RI VAR portb.3 ' serial in from reader
RR VAR portb.2 ' reader reset
B0 var byte 'byte variable
B1 var byte 'byte variable
B2 var byte 'byte variable
B3 var byte 'byte variable
B4 var byte 'byte variable
B5 var byte 'byte variable
B6 var byte 'byte variable
B7 var byte 'byte variable
B8 var byte 'byte variable
B9 var byte 'byte variable
B10 var byte 'byte variable
HIGH RR 'reset Reader
loop: Serin SI,N9600,B0 ' B0 = input character
PAUSE 1500 'wait a sec
Serout SO,N9600,["ready "] 'Send ready
SERIn RI, N9600,B0 'useless input
SERIn RI, N9600,B0 'useless input
SERIn RI, N9600,B1 '1st real data
SERIn RI, N9600,B2 '2nd character
SERIn RI, N9600,B3
SERIn RI, N9600,B4
SERIn RI, N9600,B5
SERIn RI, N9600,B6
SERIn RI, N9600,B7
SERIn RI, N9600,B8
SERIn RI, N9600,B9
SERIn RI, N9600,B10 'last character
SEROUT SO,N9600,["got the code: "]
print: Serout SO,N9600,[B1] 'output 1st character
Serout SO,N9600,[B2] 'output 2nd character
Serout SO,N9600,[B3]
Serout SO,N9600,[B4]
Serout SO,N9600,[B5]
Serout SO,N9600,[B6]
Serout SO,N9600,[B7]
Serout SO,N9600,[B8]
Serout SO,N9600,[B9]
Serout SO,N9600,[B10] 'output last character
Serout SO,N9600,[" done"]
Goto loop
The first two characters from the RFID reader are junk, so they are read in and then disregarded. the following 10 characters are the ones I want. As you more experienced PICers will note, the code above is not a very elegant program. Surely there is a way to do this without 11 byte variables. Here's a program that uses arrays that does not work:
' SERIN & SEROUT Commands
'
' Upper case serial filter.
Include "modedefs.bas" ' Include serial modes
DEFINE OSC 20
Define HSER_
SO var portb.0 ' Define serial out pin
SI var portb.1 ' Define serial in pin
RI VAR portb.3 ' serial in from reader
RR VAR portb.2 ' reader reset
B0 var byte 'byte variable
tag var BYTE[10] ' Creates a byte array of 10 bytes
HIGH RR 'reset Reader
loop: Serin SI,N9600,B0 ' B0 = input character
PAUSE 1500 'wait a sec
Serout SO,N9600,["ready "] 'Send ready
SERIN2 RI, N9600,[skip 2, STR tag\10]
SEROUT SO,N9600,["got the code: "]
print: Serout2 SO,N9600,[STR tag]
Serout SO,N9600,[" done"]
Goto loop
This program just seems to skip the SERIN2 line altogether and just outputs "ready got the code: done" all at once. Anybody have any ideas about what I am doing wrong?.
Bookmarks