Shop OBEX P1 Docs P2 Docs Learn Events
parsing serialin data — Parallax Forums

parsing serialin data

Jay BedardJay Bedard Posts: 4
edited 2011-08-21 09:26 in BASIC Stamp
I am using SERIN RX, Baud, 100, Timeout, [STR NB0R2\8\CLS] to read a decimal string from the PINK. What I can't seem to do is then break the data up into individual segments. For instance the first 2 digits are device code the next four digits are time (2 digits for hour and 2 digits for minutes) and so on. Is this possible with the BS2?

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2011-08-21 09:26
    Try something like:

    code = (NB0R2(0)-"0")*10+(NB0R2(1)-"0")
    hour = (NB0R2(2)-"0")*10+(NB0R2(3)-"0")

    and something similar for the minutes.

    You could also read the decimal values directly with:

    SERIN RX,Baud,100,Timeout,[DEC2 code,DEC2 hour,DEC2 minute,STR NB0R2\2\CLS]
Sign In or Register to comment.