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.