I have a program that talks to a ttyACM0 usb device. When the USB bus is power-cycled the program is supposed to re-initialize the device handle.
The program executes properly and re-initializes the Device-handle on USB power-cycle when called from the command-line
Program executes properly if rc.local script is called after its called at-least once from the command line during a given session.
If I boot the system rc.local executes but once the USB power-cycle starts the process is getting killed by the OS (atexit() printfs are not logged)
I have tried compiling the code over a fresh raspbian strech install and the problem still persists.
Can somebody throw some light behind this issue? I have been stuck on this issue for a week now. Any help is appreciated.
This is the rc.local file
#!/bin/sh -e
#
# rc.local
exec >>/data/rc_log.txt 2>&1
/root/bin/proc &
sleep 2
exit 0
The program gets sensor data from the ttyACM device and put it in a variable in a shared memory for another process to access and I need to it do so continuously, hence if the usb is removed, the program goes to sleep and once the usb is reconnected the program gets access again to the device and resumes
The program works properly when called from the command line using ./proc and it pauses and resumes when usb is removed or reattached. But when I reboot the rpi and make the program run from rc.local it works only till the device is connected and it exits once its disconnected from usb
The program is started and I can see it on htop, also my other process is getting sensor data from it. Once the usb device is removed the program dissappears from htop and since my ExitHandler is not being called as I cannot see any output in log I am assuming that the program is getting killed by the kernel.
/etc/rc.local
and explain in more detail what the program is doing. – goldilocks Dec 16 '17 at 13:13exec >>/data/rc_log.txt 2>&1
/root/bin/proc &
sleep 2
– Balaji G Dec 16 '17 at 13:44exit 0
The program gets sensor data from the ttyACM device and put it in a variable in a shared memory for another process to access and I need to it do so continuously, hence if the usb is removed, the program goes to sleep and once the usb is reconnected the program gets access again to the device and resumes./proc
and it pauses and resumes when usb is removed or reattached. But when I reboot the rpi and make the program run from rc.local it works only till the device is connected and it exits once its disconnected from usb – Balaji G Dec 16 '17 at 13:51/etc/rc.local
, it will remain closed. Understand this is not a discussion forum wherein you can expect people to prod you for information in an ongoing dialog. Instead, you are expected to make an effort to present the problem in a complete form. Please take the tour to understand better how the site works. – goldilocks Dec 16 '17 at 14:07/etc/rc.local
has limitations due to Compatibility with SysV. We have seen many problems here on this site using it. Following the recommendation of the developers from systemd you should avoid using it. – Ingo Feb 22 '20 at 20:24