Interpreting received data (RS232, ASCII, BS2)
Grant_O
Posts: 36
hi, i was just wondering if anyone knows how to interpret incomming·ASCII strings·and use them in commands with a BS2. Im running a SimpleStep stepper motor·controller that i can call on through RS232 for information on settings and current position. but all of its information is not just numbers, in the begening of·its response string Theres (d9<) then the number or characters i need. basicly if i wanted to do a command similar to this:
IF "SERIN" = d9<1000·THEN (something)
(d) = external·devices·prefix response
(9) =·external·devices network number
(<1000) = external·devices data string
what would i need to do to seperate the string?
thanks:
IF "SERIN" = d9<1000·THEN (something)
(d) = external·devices·prefix response
(9) =·external·devices network number
(<1000) = external·devices data string
what would i need to do to seperate the string?
thanks:
Comments
So:
D_BYTE VAR BYTE
Nine_Byte VAR BYTE
NumVal VAR WORD
DoAgain:
SERIN StepPin, 16384, [noparse][[/noparse]D_Byte, Nine_Byte, wait("<"), DEC NumVal]
IF D_Byte <> 'd' THEN DoAgain
IF Nine_Byte <> '9' THEN DoAgain
SEROUT 16, 16384, [noparse][[/noparse]"Got ", DEC Nine_Byte, 13]
GOTO DoAgain
I believe the DEC modifier wants a comma, space, or line-feed to end the token.
Oh, and note that "16384" will have to be modified to be the baudmode select value for your BS2 'flavor'.
You want "Inverted, 9600" for the PC (SEROUT 16).· I don't know what the baud rate is for your device,
nor the pin.· Look it up in the manual under "SEROUT".
dont worry bout the baud rates, i figured them out the hard way but now iv learned how to calculate them.
again thanks allenlane!