DAT length including HEX 00
Ltech
Posts: 385
I mis something her !
->I have a DAT field : "MessageSentToServer byte "11010106002510080E0101",0 "
"StrSize(@MessageSentToServer)" Give 22 corect !
->It has to be in hexadecimal code
->I make : "MessageSentToServer byte $11, $01, $01, $06, $00, $25, $10, $08, $0E, $01, $01, 0"
Fine !
But now : StrSize(@MessageSentToServer) Give 5 !
Yes I need to send Hex00 on byte 5.
I understand the counter stop on 0 but is there a nice way to solve this?????
Thanks
->I have a DAT field : "MessageSentToServer byte "11010106002510080E0101",0 "
"StrSize(@MessageSentToServer)" Give 22 corect !
->It has to be in hexadecimal code
->I make : "MessageSentToServer byte $11, $01, $01, $06, $00, $25, $10, $08, $0E, $01, $01, 0"
Fine !
But now : StrSize(@MessageSentToServer) Give 5 !
Yes I need to send Hex00 on byte 5.
I understand the counter stop on 0 but is there a nice way to solve this?????
Thanks

Comments
-Phil
PUB fixedLengthString( x, n ) repeat n serial.tx(byte[x++])This assumes you're using FullDuplexSerial to send your message. You'd call fixedLengthString(@MessageSentToServer,11) since there are 11 bytes to send.Where does it say
The only way I know of sending hexadecimal is to send it in ASCII characters. When I've seen this done, it's usually two characters per byte (doubling the size of the data).
So to send the data Phil entered
You'd use
I use this technique myself since it lets me use the ASCII control characters mixed in with data.
Here's a method I use to poke the ASCII characters into an array.
PUB Hex(value, digits, localPtr) '' Print a hexadecimal number value <<= (8 - digits) << 2 repeat digits byte[localPtr++] := lookupz((value <-= 4) & $F : "0".."9", "A".."F")To retrieve the values from the ASCII characters, I use.
PUB FromAsciiHex(digits, localPtr) | localCharacter repeat digits localCharacter := byte[localPtr++] if localCharacter => "0" and localCharacter =< "9" localCharacter -= "0" elseif localCharacter => "A" and localCharacter =< "F" localCharacter -= "A" localCharacter += $0A else localCharacter := 0 result <<= 4 result += localCharacterThe second method isn't as efficient as the first one since I adapted the first method from someone elses code. The second method assumes capital letters are used for values $A and $F.
Duane
That is very useful. Thank you.
Duane
I love the way everybody is helping here !
JonnyMac give me the best choice for my system.
Now I count manualy the bytes of hex data
Ps I use it on spinneret to remote control a huge live broadcast HD video switcher .
Inpressive small spinneret !