Hi Robban, with each command you send the elm unit you should·know how many bytes it will return and which bytes you require. In the example you have been dealing with you are saying that the elm returns four bytes and you only require the last two bytes. What you could do is assign a variable for the SKIP and HexStr dependent on what you were expecting to recieve. Assuming you are using allan's code
HexVal (defined as a WORD) would then have the value 6904 in it, if given the two strings "1A" and "F8".
Or "1a" and "f8", same thing. And if you're begin given the string "1AF8", then you'd use:
The "HEX" is a 'deformatting' keyword, that converts a hexadecimal formatted string into the equivalent decimal value, then puts the resulting value into a variable.
Comments
*confused*
SEROUT tx,baud, [noparse][[/noparse]"0100",13]
skip_len=2
return_len=4
SERIN rx,baud, [noparse][[/noparse]SKIP skip_len,STR HexStr\return_len]
the skip and return variables would be dependent on the issued command
Jeff T.
Yes, but you'd use:
SERIN rx, baud, [noparse][[/noparse]SKIP skip_len, HEX HexVal.HighByte, HEX HexVal.LowByte]
HexVal (defined as a WORD) would then have the value 6904 in it, if given the two strings "1A" and "F8".
Or "1a" and "f8", same thing. And if you're begin given the string "1AF8", then you'd use:
SERIN rx, baud, [noparse][[/noparse]SKIP skip_len, HEX HexVal]
The "HEX" is a 'deformatting' keyword, that converts a hexadecimal formatted string into the equivalent decimal value, then puts the resulting value into a variable.