Required Hex format in Serialwrite Node

Hi,
When we send Hex value from Losant Framework using
Serial Write Node(in Edge Work Flow),it will transmit the ASCII Value,But we need Hex value.Do we have any specific format for sending Hex value?
For the same here I have shared my screen shots.
Screenshot 1:
SerialWritenode1
Screenshot 2:

If you have any specific format for sending Hexvalue in SerialWriteNode,
Kindly share me the details.

Thanks
Sivasankari S

Hi @sivasankari_s,

I believe the problem could be related to the spaces you have in the Write Template, so I would test that first. Since you denoted hex, I believe the template is looking for only 16 characters. Try removing the spaces and see if the Serial Write Node performs as expected.

Thanks!
Julia

Hi Julia,
Thanks for your prompt reply. I have tried with space and without space and 0x prefix in each Hex value,But It’s not working.

if I send this value via serial write node with following configuration
Serial Path:/dev/ttyUSB0
BaudRate:9600
Write Template :0A 03 00 81 00 02 95 58(with space Example)
Result in coolTerm : 30 41 20 30 33 20 30 30 20 38 31 20 30 30 20 30 32 20 39 35 20 35 28

which means losant transmit the Hex value in following method.

0 A Space 0 3 space 0 0 space
30 41 20 30 33 20 30 30 20 38 31 20 30 30 20 30 32 20 39 35 20 35 28.

if I send Hex Value without space like this 0A03008100029558,My result
was 30 41 30 33 30 30 38 31 30 30 30 32 39 35 35 28.
Only space Hex value 20 removed in cool term.

But My Correct device(Energy meter) result is when i send 8byte in write node the result should come 9 bytes,which is the correct format.

Thanks
Sivasankari S

Hi @sivasankari_s,

The “Write Encoding” here is converting the string you have into it’s Hex representation. Since it’s already encoded have you tried sending it using utf8 as the “Write Encoding”?

I have tried ‘utf8’ but still not working.
if i send ascii method in serial writenode its working perfectly but if i send Hex method
in serial write node its not working.
I have listed my process below.
In my ‘Energy Meter’ Only accept Hex Code.if i write 0A 03 00 81 00 02 95 58 in serial write node and deployed edge gateway and I got serial result true.But my serial read node not reply to me this is because of Hex Code not sending Hexformat ,losant serial write node considered Hex Code as ASCII.
please share me how to write HexCode in Serialwrite Node.

Thanks
Sivasankari S.

Hi @sivasankari_s,

Could you provide a screenshot of your current node configuration, and any other relevant screenshots?

Thanks!
Julia

I have deployed the above work flow to my edge gateway.
I have Connected My “Energymeter” to this port “/dev/ttyUSB0” and
my Energy Meter only accept the Hex Code not ASCII and others.
I got “serialwriteresult:true” but i didn’t get any reply from the Energy Meter.
I have tried with space and without space in write template but it is not working.

Thanks
Sivasankari S

Hi @sivasankari_s,

The configuration you currently have is going to hex encode the string is your Write Template. Since you have your hex value in the Write Template, this hex value will be hex encoded again, resulting in the long hex value on your device:

0A 03 00 81 00 02 95 58->Hex Encode->30 41 20 30 33 20 30 30 20 38 31 20 30 30 20 30 32 20 39 35 20 35 28

If you remove the spaces from your write Write Template (0A03008100029558) and set your Write Encoding to UTF8, what do you see in your serial monitor and workflow?

Thanks!
Julia

SerialWrite

SerialWriteResult

Hi Julia,
I have set my write encoding as UTF8 and I got SerialWriteResult true but My Energymeter not replied anything, regarding this i have enclosed the above screens.if you have any suggesstion for the above screen ,kindly share me.

Thanks,
Sivasankari S