Shop OBEX P1 Docs P2 Docs Learn Events
SX28 serin question — Parallax Forums

SX28 serin question

martinbushnellmartinbushnell Posts: 1
edited 2013-12-23 17:09 in General Discussion
I know that much has been written about SERIN for the SX28 but I'm a bit confused about the subroutine required for receiving strings.
Can anyone suggest how I recreate the following statement from a Stamp BS2 programme for use with the SX28

SERIN rxpin, baud, [WAIT("SENDRX")]

Many thanks

Martin

Comments

  • ZootZoot Posts: 2,227
    edited 2013-12-23 17:09
    SERIN just gets a byte, so you generally want to wrap it in a subroutine. Presume that each call to my_ser_in gets one byte
    
    Main:
    
    
    Wait_For_Header:
        tmpB1 = my_ser_in
        IF tmpB1 <> "S" THEN Wait_For_Header
        tmpB1 = my_ser_in
        IF tmpB1 <> "E" THEN Wait_For_Header
        tmpB1 = my_ser_in
        IF tmpB1 <> "N" THEN Wait_For_Header
        tmpB1 = my_ser_in
        IF tmpB1 <> "D" THEN Wait_For_Header
        tmpB1 = my_ser_in
        IF tmpB1 <> "R" THEN Wait_For_Header
        tmpB1 = my_ser_in
        IF tmpB1 <> "X" THEN Wait_For_Header
    ' only here if correct header received, so next two bytes (??) are data
    
        tmpB1 = my_ser_in
        tmpB2 = my_ser_in
    
       IF tmpB1= "." THEN Do_Something
       IF tmpB1= "," THEN Do_Something_Else
    
    ' etc
    
      GOTO Main
    
    
    
    FUNCTION my_ser_in
         SERIN ..... your code into one byte, say, "tmpB1"
         RETURN tmpB1
         ENDFUNC
    
    
Sign In or Register to comment.