Running python-gphoto2 as root or not.

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Running python-gphoto2 as root or not.

Bob Smith-2
It has taken me 2 days to get to this point but I will be a succinct as
I can be.
I have a python program controlling a Canon camera (several models in
fact) in response to an Xbee remote controller.
I created each item to be controlled in a separate module and then
imported into the final application. Just when I thought it was ll done
and working, during testing I came across  a problem

I have 2 capture modes. One uses capture_image in gphoto2 and the other
is a physical remote release (over a realy).
In both cases, when I have the full application runnig I found that the
shutter was exercised but the images was never saves. Also, the camera
was locked up "recording" to who knows where. The only resort was
removing the battery.

I tracked it down(to some extent) to the capturetarget. I had it working
reliably from a test script but when I pasted this into the main program
it failed. A day later I had stripped the main program down to the same
lines of code as the working test script and it still failed. I wa
challenging the very deterministic nature of code.

Then I had an epiphany. The only difference was that the main program
required, due to other libraries, that I run it as root. I had the
launch command programmed as root ./slave.py and the test program was
run simply without root, ./test.py

Now whet I run ./test.py as toor it fails. So now the problem is defined
and repeatable but not yet solved.

I run the following code as root and none root and the camera stored the
image without root and does not with root.

Here are the 2 cases

     pi@slave:~ $ sudo ./test.py
     WARNING: gphoto2: (ptp_list_folder_eos [library.c:7113]) storage
0xffffffff, but handle 0x00000000?
     WARNING: gphoto2: (ptp_usb_getresp [usb.c:438]) PTP_OC 0x9109
receiving resp failed: PTP General Error (0x2002)
     WARNING: gphoto2: (ptp_list_folder_eos [library.c:7129])
'ptp_canon_eos_getobjectinfoex ( params, storageids.Storage[k], handle ?
handle : 0xffffffff, 0x100000, &tmp, &nroftmp)' failed: PTP General
Error (0x2002)
     CAMERA READY
     > Original; Capture target= [0, 'Internal RAM']
     >> New Capture target= [0, 'Memory card']
     >>> Final Capture target= [0, 'Memory card']
     > Original; Capture target= [0, 'Internal RAM']
     >> New Capture target= [0, 'Memory card']
     Final Capture target= [0, 'Memory card']
     ^[[AWARNING: gphoto2: (ptp_usb_getresp [usb.c:438]) PTP_OC 0x911c
receiving resp failed: PTP Device Busy (0x2019)
     WARNING: gphoto2: (camera_unprepare_canon_eos_capture
[config.c:449]) 'ptp_canon_eos_resetuilock (params)' failed: PTP Device
Busy (0x2019)
     pi@slave:~ $ ./test.py
     WARNING: gphoto2: (ptp_list_folder_eos [library.c:7113]) storage
0xffffffff, but handle 0x00000000?
     WARNING: gphoto2: (ptp_usb_getresp [usb.c:438]) PTP_OC 0x9109
receiving resp failed: PTP General Error (0x2002)
     WARNING: gphoto2: (ptp_list_folder_eos [library.c:7129])
'ptp_canon_eos_getobjectinfoex ( params, storageids.Storage[k], handle ?
handle : 0xffffffff, 0x100000, &tmp, &nroftmp)' failed: PTP General
Error (0x2002)
     CAMERA READY
     > Original; Capture target= [0, 'Memory card']
     >> New Capture target= [0, 'Memory card']
     >>> Final Capture target= [0, 'Memory card']
     > Original; Capture target= [0, 'Memory card']
     >> New Capture target= [0, 'Memory card']
     >>> Final Capture target= [0, 'Memory card']
         WARNING: gphoto2: (ptp_usb_getresp [usb.c:438]) PTP_OC 0x911c
receiving resp failed: PTP Device Busy (0x2019)
     : gphoto2: (camera_unprepare_canon_eos_capture [config.c:449])
'ptp_canon_eos_resetuilock (params)' failed: PTP Device Busy (0x2019)

The code simply performs 2 captures with delays and prints out the
capturetarget alot.
Thus:

     #!/usr/bin/env python

     import sys,time,logging

     import gphoto2 as gp

     global camera,context,config
     logging.basicConfig(format='%(levelname)s: %(name)s: %(message)s',
level=logging.WARNING)
     gp.check_result(gp.use_python_logging())
     context = gp.gp_context_new()
     camera = gp.check_result(gp.gp_camera_new())
     gp.check_result(gp.gp_camera_init(camera, context))
     print "CAMERA READY"

     def Capture():
             global camera, context
         config = gp.check_result(camera.get_config(context))
         error, target = gp.gp_widget_get_child_by_name( config,
'capturetarget')
         print "> Original; Capture target=",
gp.gp_widget_get_value(target)
         target.set_value('Memory card')
         print ">> New Capture target=", gp.gp_widget_get_value(target)
            gp.gp_camera_capture(camera, gp.GP_CAPTURE_IMAGE, context)
         print ">>> Final Capture target=", gp.gp_widget_get_value(target)
             return 0

     Capture()
     time.sleep(3)
     ()
     time.sleep(5)
     gp.check_result(gp.gp_camera_exit(camera, context))

I am using wiringPi which demands root for the main program. In any
case, it would be nce to understand what's going on.

Other info:
Raspberry Pi running Jessie.pi@slave:~ $ gphoto2 -v
gphoto2 2.5.10

Copyright (c) 2000-2016 Lutz Mueller and others

gphoto2 comes with NO WARRANTY, to the extent permitted by law. You may
redistribute copies of gphoto2 under the terms of the GNU General Public
License. For more information about these matters, see the files named
COPYING.

This version of gphoto2 is using the following software versions and
options:
gphoto2         2.5.10         gcc, popt(m), exif, no cdk, no aa, no
jpeg, no readline
libgphoto2      2.5.10         all camlibs, gcc, ltdl, EXIF
libgphoto2_port 0.12.0         gcc, ltdl, USB, serial without locking


I hope this is obvious to someone because it is kicking my ass!

cheers
Bob



---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus


------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev
_______________________________________________
Gphoto-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gphoto-user
Loading...