Post 1 made on Friday December 13, 2019 at 11:19 |
I’ve always had issues with RS232 inputs in HEX. I’m hoping someone can help. I created two simplified examples to help explain the issue.
In Scenario 1, I just send a HEX code to the TV. Works perfectly.
In Scenario 2, I manipulated data and create the HEX code in the necessary format. When I send to the TV, it does nothing.
Does anyone know what I need to do in Scenario 2 to get the TV to accept the code? It is likely some type of ASCII to HEX conversion but can’t figure it out.
SCENERIO 1:
var SendHex1 = "\x08\x22\x01\x00\x00\x0F\xC6"; System.print("SendHex1 [" + SendHex1 + "]"); Serial.OT.send(SendHex1);
Output: SendHex1 [ " [hex format]
Result: TV resets volume to 15
SCENERIO 2:
var SendHex2 = "08 22 01 00 00 0F C6"; SendHex2 = "\\x" + SendHex2.replace(/\s/g, "\\x"); System.print("SendHex2 [" + SendHex2 + "]"); Serial.OT.send(SendHex2);
Output: SendHex2 [\x08\x22\x01\x00\x00\x0F\xC6]
Result: TV does nothing
|
|
Post 2 made on Saturday December 14, 2019 at 12:15 |
raiders_fan94 Long Time Member |
Joined: Posts: | September 2002 324 |
|
|
Well, the outputs don't look the same. Not sure if that's a mistype on your end.
Also, depending on the compiler, if you've specified 0x before an alphanumeric, it may treat it as byte code and thus not a string, the minute you start manipulating a string, it will always treat it as a string. Thus the ASCII to hex conversion issue.
Maybe try converting to binary afterwards and see what the 1s and 0s are.
|
Never underestimate the predictability of stupidity |
|
Please read the following: Unsolicited commercial advertisements are absolutely not permitted on this forum. Other private buy & sell messages should be posted to our
Marketplace. For information on how to advertise your service or product
click here. Remote Central reserves the right to remove or modify any post that is deemed inappropriate.