I try to read a file in Node Red every second. The file is written from a program every 0.2 seconds.
Now the file sometimes changes the length of the array:
This is in a way impossible cause the program writes always a new line into the txt file.
I now suspect that this happens when the program writes the file and node red has opened it for reading.
Has anyone had experience with something like this and can help me?
Thank you for your help!
normally you would something like the tail node to just monitor things being added to a file.
writing it so often and reading it is generally a bad idea for the reasons you are finding.
But some operating systems cope better than others.
I totally agree with you, but my problem is, that the filename change after few minutes..
I don't understand what you mean by that. Please provide more details of exactly what is going on. Then we may be able to suggest a solution.
the tail node it self works well, but with the tail node I am just able to read the new line?
For my application I need the hole file because I show it in a grid
I think the easiest way would be if I just copie the file without reading it.
Is that possible?
You have not answered the question that I asked earlier. What exactly do you want to achieve.
sorry, my PLC write every 0.2s some different data in a new line into a file. I want to show the data on the dashboard.
I have now tried different ways of doing this.
The one that I think works best is when I look at the file with a tail node to get the last line that was added.
This works fine, but I can't encode the utf le 16 string to display numbers correctly.
Please answer all questions - there may be a simple solution you are missing...
What make and model of PLC?
Where does PLC write this file? Inside the PLc file system?
How do you access this file?
The plc is a Siemens 1500
But the plc correspondent with a pc via network and writes a .mcv data file on the pc.
So, the PLC does not write a file, a PC connected to the PLC and that PC reads PLC data then writes the file.
What program is writing this file? Wincc? Custom application? Node-red?
As it is a relatively new PLC and there are several nodes available, why don't you simply request the values from the PLC instead of messing around with files?
Its a custom application. The file is used for some other stuff, so I don t want to change the why this is running (cause this runs since a while). I don't want to change this communication. I am looking for a simple solution how I can access the data with node red without further changes or further communication to the PLC.
As I said, the tail node works very well, except for the fact that I get the data UTF-LE16 encoded and therefore cannot change the string to a number.
Feed the data into a debug node and show us what it displays so we can better understand what you have.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.