How to implement equivalent of BS2's SERIN functionality with HSERIN?

Pongo

Senior Member
I thought this might be a common question but I couldn't find a thread (except the one about speed and hex conversion) so apologies in advance if I'm just a lousy searcher.

I would like some hints how to implement the equivalent of the BS2's SERIN Qualifier and Timeout functions with HSERIN on a 20X2. For example my BS2 program has:

SERIN SI,84,6000,WHOOPS,[WAIT("XZY"),{dataspec}]

which means ignore any data on the serial input until it sees the qualifier "XZY" and then grab the data specified by {dataspec} and move on to the next program line, if it doesn't see "XZY" in 6 seconds then timeout and jump to the WHOOPS subroutine. I don't have any problem with pin, baud, or dataspec, but the qualifier and timeout escape me.
 

Pongo

Senior Member
Thanks, I saw that but "Qualifier - is an optional single variable/constant (0-255)" implies that I can only use a single character as a qualifier, is that correct?
 

Goeytex

Senior Member
Hserin only allows a single byte qualifier so you can't use "XYZ" since that is three bytes. However with a bit of extra code you can do something like this.

Code:
#picaxe 20X2
hsersetup B9600_8,%00

main:

do
  hserin [6000,whoops],0,10,("X")
       
    if @ptrinc = "Y" and @ptrinc = "Z" then
                 
       for ptr = 0 to 9
         sertxd (#@ptr," ")
       next
     endif
   
   whoops:
   pause 1000

loop

Simulate and Enter > "XYZ",22,33,44,55,66,77,88,99 when asked
 
Top