parsing serialin data
Jay Bedard
Posts: 4
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
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]