If need to send the hex value of 0x18 to a serial port node, what is the proper way to do it using a Change node? I've found that is can be done using the following string "\u0018" within a JSONata expression field (I don't exactly understand why) but I am wondering if I am missing something simple and if there is a better way?
There are several places where you can enter data as a byte array, e.g.
change nodes. However, the implementation of the input editor is a bit... obscure:
If you read the Info panel closely, you may discover that you can enter an array of "character codes", which will be stored as their byte equivalents -- but I doubt it. I had to be shown this by Dave himself...
In JSON syntax,
["0x18"] represents an array of 1 byte, with hex value
18 -- where as if that character is entered as
["18"], it's interpretted as 1 char of decimal value 18 and stored as the hex byte
Thanks @shrickus, I'll give it a try tomorrow.
@shrickus I had a chance to mess with that today and this is what I found...
If I send the buffer value ["0x18"] directly to the serialport it does not work the same as if I send it the JSONata string value of "\u0018". However, if I perform a toString() operation on the buffer value, then send it to the serialport, it works as expected/needed?
I wish I understood why?
Ah, me too -- only thing I can think of is that the buffer is only 1 byte long, where the character string (of 1 char) is actually 2 bytes?
If the protocol expects 2 bytes, you might want to try left padding with 0, so