I am building a prototype with Raspberry Pi. I have a TOF sensor using i2c that will record a distance. When an object is within a certain range measured by the TOF sensor, some LEDs will light up and a camera will capture. It has been working fine except with a few minor bugs. I then tried to use this with ArduCAM's motorized camera (https://www.arducam.com/docs/cameras-fo ... cus-camera) so that we can focus the camera depending on the distance. I've already talked with ArduCAM's support and have been unable to resolve this issue with them.
The problem is that there seems to be some sort of resource conflict when I am trying to capture. The process goes that I will find the distance, focus the camera, and then capture. It works fine but every now and then my application gets stuck. If I kill the process with sudo kill -9, I am unable to restart the application. When I do, my TOF sensor will not be able to start up. If I kill the process again, ps aux will show that the program is stuck in D state. According to this https://unix.stackexchange.com/a/5648, I am stuck waiting for some kernel call. I never encountered this problem prior to adding this device to my application. I have also not been using the I2C interface so close to capturing the image. This leads me to believe the issue is somewhere in I2C. In talking with ArduCAM, they don't think the problem is on their end or in my code controlling the focusing. Anytime this issue occurs, I have to use the magic sysrq key to reboot the Pi.
To interface with the camera, I am using this: https://sourceforge.net/projects/raspicam/ with version 0.1.6.