File truncated message

#1

Hi there, I'm new to this forum and new to node-red. I have a Raspberry Pi 3 B+ with node-red server running. I have a simple flow set up where tail watches a file for updates and sends a simple message to a gauge. The gauge updates when file updates but I get this message - tail: /dev/shm/pressure: file truncated - in debug window. The file holds a short string such as '19.3'. This is my "hello world" test - need a little help to get it over the finish line. Any guidance will be appreciated.

0 Likes

#2

Let me be the first to welcome to the world of Node-Red! :sparkler:

Now when opening a thread it is a good idea to name your platform (which you did!) what release of NR and node.js you are on (if you run NR with a node-red-start command in a terminal, you will see both releases at the start of the log)

And in a case like this, providing your flow would b useful (select export to clipboard, copy it and in the thread start with three back tic's ``` on a line, then paste the flow and on the next line put in three more back tics.

I't nice to see you are already using the debug node and I (and many othters) will be happy to guide you along

0 Likes

#3

Thanks for the welcome and the reminder,

Node.js version: v8.12.0
Node-RED version: v0.19.5
Linux 4.14.79-v7+ arm LE

[{"id":"c64b31f0.ee667","type":"ui_gauge","z":"10bb1299.024e2d","name":"Flow Rate","group":"351aad56.0170ca","order":1,"width":0,"height":0,"gtype":"gage","title":"Flow Rate","label":"gpm","format":"{{value}}","min":0,"max":"20","colors":["#ca3838","#e6e600","#00ca06"],"seg1":"7","seg2":"14","x":580,"y":80,"wires":[]},{"id":"57ac8cce.a0ca44","type":"tail","z":"10bb1299.024e2d","name":"read file flow-rate","filetype":"text","split":false,"filename":"/home/pi/Juicer/flow-rate","x":180,"y":80,"wires":[["c64b31f0.ee667","70b1ce7.01fa6b"]]},{"id":"70b1ce7.01fa6b","type":"debug","z":"10bb1299.024e2d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":570,"y":120,"wires":[]},{"id":"351aad56.0170ca","type":"ui_group","z":"","name":"WRL Dashboard","tab":"afe8a68a.3c0a78","order":3,"disp":true,"width":"6","collapse":false},{"id":"afe8a68a.3c0a78","type":"ui_tab","z":"","name":"Main Tab","icon":"dashboard","order":1}]

The message does not seem to be generated by the debug node. I get the message with or without debug node.

0 Likes

#4

Tail is designed to watch a file that is being added to. If you use it for a file that is completely overwritten each time then it gets confused. Try this in a terminal
echo " " > temp.txt
then open another terminal and run
tail -f temp.txt
back in the first terminal
echo "hello " >> temp.txt
which appends to the file, so it appears in the tail window. Then, in the first terminal again
echo "hello again" > temp.txt
which overwrites the file, and you will see the truncated message from tail.
Instead of the Tail node you can use the Watch node, which will tell you when the file is written to. When it gets written to then use a File In node to fetch the value.

0 Likes

#5

Alternatively see if your version of tail has -F (capital) option which checks to see if the file has be "rotated" ie removed/replaced by a new one of same name.

0 Likes

#6

I believe the Tail node already uses -F, I don't think that stops it showing the truncated message.

0 Likes

#7

@tristan you can just ignore the message if you like, I believe the tail will still work correctly.

0 Likes

#8

Thanks for responding. I was using the Tail node incorrectly - it seems to work without error when files are appended to not rewritten. I have taken Colin's advice and use the Watch and File nodes together. With Node-RED and help from this forum I'm solving some long-standing problems quickly. Thanks again.

0 Likes