I have an input signal going into GPIO 26 from a UPS that indicates it is time to shutdown the OS and save data. How can I use that GPIO in Codesys to force my persistent values to save?
The reason I need to do this is because the shutdown sequence of the device causes Codesys to abruptly exit before Linux is properly shut down and Codesys will not save data. I need to make Codesys immediately save the data when the signal changes.
I found a function block to save persistent values to a specified file, but I want to save it to the normal location so on startup Codesys reads the values without the need for my program to do anything.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
My hardware causes a difficult situation. It has a built in UPS that relies on a Python script to fire an event when the power changes, which in turn performs the system shutdown. Prior to the system shutdown command, the UPS removes power from the Ethernet ports, which causes Codesys to dump out in a license fault.
In the Python power change event, I added the code mentioned to stop Codesys prior to power being removed from the Ethernet ports and all works good. However after I installed the PREEMPT RT patch, the CPU usage goes up to about 30% causing high jitter and poor performance. In order to fix this problem, I enable the FIQ by changing dwc_otg.fiq_enable=N in the /boot/cmdline.txt file. Enabling the FIQ in turn stops the Python event from doing its job and no longer stops Codesys.
My best compromise I can come up with is to have the Codesys program watch the signal from the UPS and explicitly have it store the persistent values the same way it does when Codesys shuts down normally. But I have not found a function block to perform this task.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have an input signal going into GPIO 26 from a UPS that indicates it is time to shutdown the OS and save data. How can I use that GPIO in Codesys to force my persistent values to save?
The reason I need to do this is because the shutdown sequence of the device causes Codesys to abruptly exit before Linux is properly shut down and Codesys will not save data. I need to make Codesys immediately save the data when the signal changes.
I found a function block to save persistent values to a specified file, but I want to save it to the normal location so on startup Codesys reads the values without the need for my program to do anything.
Hi Archie,
Sounds like this link below won't help you if your shutdown kills Codesys too early. Does it work if you modify it to:
l viewtopic.php?t=8063#p18745 l
My hardware causes a difficult situation. It has a built in UPS that relies on a Python script to fire an event when the power changes, which in turn performs the system shutdown. Prior to the system shutdown command, the UPS removes power from the Ethernet ports, which causes Codesys to dump out in a license fault.
In the Python power change event, I added the code mentioned to stop Codesys prior to power being removed from the Ethernet ports and all works good. However after I installed the PREEMPT RT patch, the CPU usage goes up to about 30% causing high jitter and poor performance. In order to fix this problem, I enable the FIQ by changing dwc_otg.fiq_enable=N in the /boot/cmdline.txt file. Enabling the FIQ in turn stops the Python event from doing its job and no longer stops Codesys.
My best compromise I can come up with is to have the Codesys program watch the signal from the UPS and explicitly have it store the persistent values the same way it does when Codesys shuts down normally. But I have not found a function block to perform this task.
This store example seems to have functions for reading and writing persistent/retain memory area with the CmpApp library.
https://store.codesys.com/application-m ... re=default
I think you can alternate file retain files in the event one gets corrupt, and load the backup if the last write failed..
Interested in your projectarchive or how-to once you get something working.