Help Parsing out a return message from a stage controller
Tue, 11/15/2016 - 09:07 am
I am attempting to interface an IAI stage system with IP7. It communicates on serial and needs a convoluted (IMHO) messaging string to communicate. In general it communicates in hex but with varying field widths and then the first character is thrown in just to mess you up.
Example: Stage move
Sprintf input, "!99234%02X%04X%04X%04X%08X",axispattern(ctrlName),Accel,decel,vel,VarNum*1000
This part works now I am trying to figure out how to parse the response specifically I want to know when it has stop moving.
The response format is
Header "#" width of 1 byte
Station "XX(h)" width of 2 bytes
Mess ID "212(h)" width of 3 bytes
Axis Pattern "XX(h)" width of 2 bytes
Axis Status "XX(h)" width of 2 bytes
... to carriage return and line feed.
I need to look at bit 0 of the Axis status field to see it is still moving. So in principle I should know where to expect the data.
Do date I have tried just getting the whole message as a text string but I am getting a bunch of unknown characters which show up as diamonds with question marks. Any suggestions?
If I look at the VTDReadHex2 it is looking for either 4 or 8 bytes. So how should I approach this?