Hi, linux noob, just mucking round with the exec node:
Why does the payload of the command sometimes display human readable ascii string and sometimes hex:
e.g with ls -a cmd, display a nice string of human readable ascii:
with cat /sys/firmware/devicetree/base/model:
While a function node can change it to readable string:
msg.payload = Buffer.from(msg.payload);
msg.payload = msg.payload.toString();
jus like to understand why it does not display ascii string in the first instance.
What do you see if you run the cat command in a terminal?
Also show us how you have configured the exec node.
When I run in the cmd terminal I see:
Raspberry Pi 3 Model B Rev 1.2
The exec node config:
Please try the following:
ie: man cat
- u The output is not buffered
Can you show us the whole of the buffer output please. The help text for the exec node says
payload is usually a string , unless non-UTF8 characters are detected, in which case it is a buffer .
which suggests that there is a non-ascii character there. In fact, before posting it look at it and see if there are any unusual characters there. Find an ascii table to check it against. I note that the buffer is 31 characters but the text output is 30 and there is no newline on the end. I suspect that there may be a null character on the end, or something similar.
Indeed on a Pi at least there is a 0x00 at the end of the string... a quick way to trim it is to add
| xargs to the command in the exec node - so
Hi @Colin, the whole buffer output is (I think is decimal, when I copy & paste):
[82,97,115,112,98,101,114,114,121,32,80,105,32,51,32,77,111,100,101,108,32,66,32,82,101,118,32,49,46,50,0], and does look like a 0 is sent at the end as per @dceejay said, but I thought 0 is valid null ASCII chr.
Does not explain why on the same pi, cmd ls -a, does not buffer and outputs string as I would expect.
@Ranki, thanks for the suggestion, that works & save me another function node to convert to string, just curious why some command buffer & some dont. Hope u are enjoying your boating, I am working on a seatalk to nmea converter and hope to display all my instruments in NR's Dashboard.
Hi @kenkoknz ,
Good to hear that it is working now. In the end I think the problem is not the exec node, but the general output of cat on Linux; therefore they introduced this parameter. We need to ask them why
Concerning the boat project: good look!
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.