How do I Send & Receive HEX values via Serial?
DavidM
Posts: 630
Hi
Now that I have my AERCOM AC4490-200M-02 Module working ( sort of??)
all the documentation for the commands are in HEX, so..
Q1) How to I send ( and receive ) HEX values via the EXTENDED_FDSerial Object??
for example I want to send
$CC C1 80 06 to my Aerocomm module
I know that some hex values can be converted to ascii , but some don't have keyboard equivalents ie. $CC is some kind of A with a line above it??
Q2) This command will also return HEX values as well, So How to I view the result as HEX on my LCD? ( I am using a string pointer variable)
Q3) Ideally I want to create CONSTANTS for my HEX Commands , Is this done with a DAT declaration?
eg..
EnterATCmdMode := $41, $54, $2B, $2B, $2B, $0D
ExitATCmdMode := $CC, $41, $54, $4F, $0D
Thanks
Dave M
Now that I have my AERCOM AC4490-200M-02 Module working ( sort of??)
all the documentation for the commands are in HEX, so..
Q1) How to I send ( and receive ) HEX values via the EXTENDED_FDSerial Object??
for example I want to send
$CC C1 80 06 to my Aerocomm module
I know that some hex values can be converted to ascii , but some don't have keyboard equivalents ie. $CC is some kind of A with a line above it??
Q2) This command will also return HEX values as well, So How to I view the result as HEX on my LCD? ( I am using a string pointer variable)
Q3) Ideally I want to create CONSTANTS for my HEX Commands , Is this done with a DAT declaration?
eg..
EnterATCmdMode := $41, $54, $2B, $2B, $2B, $0D
ExitATCmdMode := $CC, $41, $54, $4F, $0D
Thanks
Dave M
Comments
Remember that hex is just a way of representing the bytes that are transmitted for us humans to read, it's all 1's and 0's at the end of the day. If I said that the Aerocomm had to receive 01000001 you might scratch your head. If I said it had to receive A you might still scratch your head. If now I say that you have to send $41 in this manner ---> Serial.tx($41) then you would type that in exactly like that and it would work. So would Serial.tx(%01000001) and so would Serial.tx("A") as they all do the same thing. I've included a short demo code snippet and the "hex" output, notice the two "HELLO" strings as well as the two "AT+++" strings that were compiled.
*Peter*
Thanks for the clear explanation
I guess all I needed to know was the SYNTAX for the multiple hex values, I did not know that the string function handles it this way,
i.e
STRING( $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF )
and also combining different data types
e.g.
Hex, Alpha and numeric..
STRING( $FF, "HELLO", 13 )
This is not mentioned in the manual for the string function. (PAGE 310 )
Thanks
Dave M