I am calling a script called ‘pi_camera_script’ to take a picture using the RPi camera and then upload it to dropbox. I have followed the example of the pi camera project and have tested the script on the Pi through the command terminal. This all works fine.
When I call the script from my sketch:
Serial.println("5 minutes passed - take photo and upload");
Process proc = Process::run("/home/pi/bin/pi_camera_script"); // image capture and upload shell script
proc.wait();
Serial.println("Done!");
It never exits.
If I monitor the serial outputs it just appears to freeze after the picture has been taken and on the dropbox_uploader
@kennethlimcp The script is in /home/pi/bin so ./pi_camera_script from the command line doesn’t work but /home/pi/bin/pi_camera_script does work fine.
The issue is still the script gets called by the sketch the still picture is taken and stored but the dropbox_uploader hangs and indeed so does the sketch I am guessing waiting for the process to exit?
Try adding proc.in().close(); before proc.wait(). Maybe the Dropbox upload script is reading the standard input and waiting forever for the firmware to send some input.
@jvanier I have got around to trying this and unfortunately it doesn’t make any difference. To recap the issue, the script runs fine when run from the console (takes a picture, stores it in the piCam directory and then uploads to dropbox). When called from the Process::run() the script takes a picture, stores the image and then seemingly skips the dropbox_uploader. The dropbox_uploader does output to the console, > Uploading "xyz" to "/dropbox"... DONE so I am now wondering if this is the problem when the script is run from the Process::run()? Should I be using proc.out() to read this output? I have tried dropbox_uploader -q upload to invoke quiet mode, this doesn’t seem to do anything different.