Script is a wrapper to execute chdkptp commands. (2) cameras are connected via USB bus; cameras have a shorted ON/OFF switch; powered on via wrapper script -> who calls an arduino application to close a relay.
Chdkptp is run " -i " inside a gnu 'screen' session. Chdkptp operational commands are fed into the screen-session. Wrapper script sleeps between 3-5 seconds between chdkptp commands - to give the camera a chance to respond.
I'm still a little unclear how this works. You start one chdkptp session in each screen, end then feed individual CLI commands periodically?
If this is correct, does the chdkptp connect only happen when the screen is first started, or do you connect/disconnect for each command?
In general, I'd suggest leaving the connection open, but this may cause problems connecting by serial number.
Example of wrapper script executing chdkptp command below; I do not yet pass the camera serial number as a variable (it's on the list.)
Note that connecting by serial number attempts to make a connection to every camera on the USB bus, to get the serial number (the same is true for connecting by name, but not bus, device or product id). If there are other instances of CHDKPTP with active connections you will probably see messages like you reported:
Jan 24 06:45:08 zeus kernel: [721933.564704] usb 1-2: usbfs: interface 0 claimed by usbfs while 'chdkptp' sets config #1
Jan 24 06:45:08 zeus kernel: [721933.564731] usb 1-2: usbfs: process 21919 (chdkptp) did not claim interface 0 before use
in the log. I would not be surprised if this caused problems. I thought it completely killed the other connection, but in a quick test on ubuntu 14.04 it didn't seem to. It may depend on the specific linux verion, distro, hardware etc. In any case, I would not recommend connecting by name or serial number when using more than one instance of chdkptp.
This makes connecting to multiple cameras of the same model awkward. One option would be to do a "list" in one instance of chdkptp, and then use the device and bus info to connect the remaining instances. However, the device number may change if the camera is reconnected, rebooted etc.
Re: the dev id number 99; No, that number increments once each time the usb device is seen by the host PC. After a few hundred iterations and no NUC reboot, the number is, well, a few hundred, I guess.
Right, I was wondering if it happened specifically after 99 reconnects.
It may be that the chdkptp usb-reset you mentioned is what's biting me..
I don't know that it's a problem, but it's a bit of legacy code I have wondered about. I look into adding an option to control this, I've been meaning to do that for a while but never had a specific reason.
I played a little with multicam, but got hung up on making it exec 'remoteshoot' - which is quite handy for me. I *could* simply have my wrapper let multicam save to SDcard, then go get images from SDcard instead of remoteshoot, but it was more code.. gotta not be lazy..
If your application doesn't require the cameras to shoot at the same moment with the exact same settings, multicam may not be a very good solution.
If you want to control multiple cameras, without shooting at the same time, you can just swap the global connection object (named con) around and use normal cli commands. e.g
connect -s=<cam 1 serial>
!cam1_con=con
connect -s=<cam 2 serial> -nodis
!cam2_con=con
The -nodis option tells chdkptp not to close the existing connection when it connects to the new camera.
Now you have two connection objects, and you can just set con to point to the one you want to control, like
!con=cam1_con
remoteshoot ....
!con=cam2_con
remoteshoot
...
Within a single chdkptp session, it's OK to connect to multiple cams by serial number, because it's aware of the existing connection.
If you do want to trigger the shutters at the exact same moment, remoteshoot is probably not good solution. While you could theoretically implement it with multicam, the actual data download would be sequential anyway so there wouldn't be much advantage over shooting and doing a image download/delete after.