jim-easterbrook / python-gphoto2

Python interface to libgphoto2
GNU Lesser General Public License v3.0
362 stars 59 forks source link

PTP Device Busy #58

Closed leobel96 closed 6 years ago

leobel96 commented 6 years ago

Hi. I'm using gphoto2 cli version on a Raspberry Pi running Raspbian without problems. I've tried installing python-gphoto2 for a python project but I keep having this error when I try capturing an image:

WARNING: gphoto2: (b'ptp_list_folder_eos [library.c:7342]') b'storage 0xffffffff, but handle 0x00000000?'
Capturing image
Camera file path: //capt0000.jpg
Copying image to /tmp/capt0000.jpg
WARNING: gphoto2: (b'ptp_usb_getresp [usb.c:465]') b'PTP_OC 0x911c receiving resp failed: PTP Device Busy (0x2019)'
WARNING: gphoto2: (b'camera_unprepare_canon_eos_capture [config.c:457]') b"'ptp_canon_eos_resetuilock (params)' failed: PTP Device Busy (0x2019)"

In particular here I've run the "capture-image.py" example provided with the library. I've just installed python-gphoto2 using pip3 install gphoto2 so I think I've installed the last version. I'm using a Canon EOS 1100D.

jim-easterbrook commented 6 years ago

It's common to get "error" messages from libgohoto2 that aren't errors, or at least don't seem to affect normal operation. Your captured image is //capt0000.jpg, which I think means it's stored in temporary memory on the camera, not its SD card. Does the image actually get copied to /tmp/capt0000.jpg on your computer?

leobel96 commented 6 years ago

Sorry for the delay. I've seen now that the image get copied anyway as you suggested. Thank you!

leobel96 commented 6 years ago

How can I understand if an error is a false positive or it is a real error?

jim-easterbrook commented 6 years ago

I think any "real" error will return an appropriate status (or raise an exception if gp_check_result is used). libgphoto2 actually has four levels of log message severity, but it doesn't appear to use them consistently. gp.GP_LOG_ERROR is often used for things that don't seem to be a problem at all.

leobel96 commented 6 years ago

Could you please suggest me a way to ignore not "real" errors?

jim-easterbrook commented 6 years ago

Don't call use_python_logging(). Since libgphoto2 uses its highest log level for things that don't seem to be errors, it's not possible to tell if any of the logging messages are real errors. (Perhaps add a verbose option to your application so that if there are problems it can be run with use_python_logging() as a debug facility.)

leobel96 commented 6 years ago

Thank you, it resolved the problem.