Hello ,
I want to send acknowledgement to device in hex format.
I'm doing this.please help me how to send acknowledgement in hex format
Thanks
var data;
if(msg.payload.length == 17){
data= stringToHex('01');
}else{
data= stringToHex('00','utf8');
}
msg.payload = data;
return msg;
Add a catch
node connected to a debug
node (set to display the complete msg object) and see if that will lead you to figuring out your issue.
also, if you just want to send back a hex 0 or 1 why not to that? For reference take look at https://www.w3schools.com/js/js_numbers.asp The section on Hexadecimal
I want to send acknowledgement like this i.e 1 byte 0x01 or 0x00.
if you just want to send back a hex 0 or 1 why not to that? For reference take look at https://www.w3schools.com/js/js_numbers.asp The section on Hexadecimal
there is no such function stringToHex
unless you make it.
hexadecimal 0x0 is simply 0
and hex 0x01 is simply 1
.
If you want to send a hex string
then just set payload to "00"
or "01"
Actually, i also did this msg.payload =0x01; & msg.payload =0x00; in this scenario device getting 30 or 31
if(msg.payload.length == 17){
msg.payload =0x01;
}else{
msg.payload =0x00;
}
return msg;
And also did this msg.payload ='01'; & msg.payload ='00'; in this scenario device getting D3.
if(msg.payload.length == 17){
msg.payload ='01';
}else{
msg.payload ='00';
}
return msg;
Device Should be received 01 or 00.
30 is ASCII '0'
and 31 is ASCII '1'
- something in the transmission path is converting the number in payload
to a character before or during transmission.
I realise now you are trying to transmit NUL
and STX
- which are not really idea characters to send as ACK or NAK.
Can you share your flow so we can see if there is something is possible.
Alternatively, can you change the code in the other device to accept a string/ASCII response like "OK" or "NG"?
i want to send acknowledgement to device ...should be sent as binary packet. I.e. 1 byte 0x01 or 0x00.
Thansks
You need to share your flow - I cannot see how you have set the nodes from a screenshot.
Also, some questions...
What is the End device?
is it possible to change the end device to use something else (like a string or a different protocol)?
system
Closed
14 February 2021 13:37
10
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.