gphoto / gphoto2

The gphoto2 commandline tool for accessing and controlling digital cameras.
GNU General Public License v2.0
710 stars 116 forks source link

Canon EOS R Image Capture Not Possible #198

Closed sinaghaffari closed 5 years ago

sinaghaffari commented 5 years ago

Describe the bug

--capture-image correctly triggered the autofocus and captures an image on the camera. Then it prints: debug_capture.log

*** Error ***
PTP Invalid Parameter
ERROR: Could not capture image.
ERROR: Could not capture.

--capture-tethered crashes after I take a picture with: debug_tethered.log

*** Error ***
PTP Invalid Parameter
*** Error (-1: 'Unspecified error') ***

Name the camera Canon EOS R

libgphoto2 and gphoto2 version

gphoto2         2.5.20.1       gcc, popt(m), exif, cdk, no aa, jpeg, no readline
libgphoto2      2.5.22.1       all camlibs, gcc, ltdl, EXIF
libgphoto2_port 0.12.0         iolibs: disk ptpip serial usb1 usbdiskdirect usbscsi, gcc, ltdl, USB, serial without locking

To Reproduce 1) Connect EOS R via USB-C to USB-C 2) Run --capture-image 3) Application crashes with error.

msmeissn commented 5 years ago

The EOS_GetPartialObject fails with that error ... it should not :/

can you try card capture as workaround? gphoto2 --set-config capturetarget=1 ?

sinaghaffari commented 5 years ago

That allowed me to successfully use --capture-image, but obviously --capture-tethered still didn't work.

Unfortunately my usecase is that I specifically want the images to end up on my camera and my computer :P

sinaghaffari commented 5 years ago

Let me know if there is anything you would like me to test :) I'm more than willing to try any ideas you might have

msmeissn commented 5 years ago

did you only try RAW? can you try smaller JPEGs? I will see if I can get you a test patch in the next days

sinaghaffari commented 5 years ago

I just tried all JPEG sizes. They all worked except for the two Large sized ones.

The Large Fine shooting mode gave the same error as before. The Large Normal shooting mode gave a different error: my-logfile.txt

*** Error ***
Canon EOS Get Changes failed (0x02ff: PTP I/O Error)
*** Error (-7: 'I/O problem') ***
sinaghaffari commented 5 years ago

I also tried CRAW shooting. It gives the same result as Fine Normal.

msmeissn commented 5 years ago

I think it might just be a timing problem, the camera is writing the file and not yet ready for us to download.

Can you apply this patch to camlibs/ptp2/library.c taht adds a 0.2 second wait and see if that helps?

xx.txt

You can try to increase / decrease the wait time.

sinaghaffari commented 5 years ago

That completely broke shooting on the camera. I get:

*** Error ***
Canon EOS Get Changes failed (0x02ff: PTP I/O Error)
*** Error (-7: 'I/O problem') ***

as well as the same error as before

sinaghaffari commented 5 years ago

Just a quick update. I found out that I get the same error when trying to use --get-file. I took one picture with each of the different quality modes and tried to download them with the latest commit (with and without the patch you provided). Note: All commands run with prefix:

env LANG=C gphoto2 --debug --folder=/store_00020001/DCIM/100EOS_R

Here are the results:

File Type Command Result Log File Without Patch Log File With Patch
Small 2 ... --debug-logfile=my-logfile-s2.txt --get-file=1 Success my-logfile-s2.txt my-logfile-s2.txt
Small 1 Rough ... --debug-logfile=my-logfile-s1r.txt --get-file=2 Success my-logfile-s1r.txt my-logfile-s1r.txt
Small 1 Fine ... --debug-logfile=my-logfile-s1f.txt --get-file=3 Success my-logfile-s1f.txt my-logfile-s1f.txt
Medium Rough ... --debug-logfile=my-logfile-mr.txt --get-file=4 Success my-logfile-mr.txt my-logfile-mr.txt
Medium Fine ... --debug-logfile=my-logfile-mf.txt --get-file=5 Error 1 my-logfile-mf.txt my-logfile-mf.txt
Large Rough ... --debug-logfile=my-logfile-lr.txt --get-file=6 Error 1 my-logfile-lr.txt my-logfile-lr.txt
Large Fine ... --debug-logfile=my-logfile-lf.txt --get-file=7 Error 1 my-logfile-lf.txt my-logfile-lf.txt
RAW ... --debug-logfile=my-logfile-raw.txt --get-file=8 Error 1 my-logfile-raw.txt my-logfile-raw.txt
CRAW ... --debug-logfile=my-logfile-craw.txt --get-file=9 Error 1 my-logfile-craw.txt my-logfile-craw.txt

Error 1:

*** Error ***
PTP Invalid Parameter
*** Error (-1: 'Unspecified error') ***

Relevant Log Lines:

0.280136 get_file_func               (2): Getting file '4M2A7341.CR3'.
0.280177 ptp_usb_sendreq             (2): Sending PTP_OC 0x9107 (PTP_OC_CANON_EOS_GetPartialObject) (0x9191cad1,0x0,0x500000) request...
0.280192 gp_port_write               (3): Writing 24 = 0x18 bytes to port...
0.280348 gp_port_write               (3): Wrote   24 = 0x18 bytes to port: (hexdump of 24 bytes)
0000  18 00 00 00 01 00 07 91-09 00 00 00 d1 ca 91 91  ................
0010  00 00 00 00 00 00 50 00-                         ......P.        

0.280369 ptp_usb_getdata             (2): Reading PTP_OC 0x9107 (PTP_OC_CANON_EOS_GetPartialObject) data...
0.280385 gp_port_read                (3): Reading 1024 = 0x400 bytes from port...
0.282446 gp_port_read                (3): Read    12 = 0xc out of 1024 bytes from port: (hexdump of 12 bytes)
0000  0c 00 00 00 02 00 07 91-09 00 00 00              ............    

0.282637 ptp_usb_getresp             (2): Reading PTP_OC 0x9107 (PTP_OC_CANON_EOS_GetPartialObject) response...
0.282659 gp_port_read                (3): Reading 1024 = 0x400 bytes from port...
0.286621 gp_port_read                (3): Read    12 = 0xc out of 1024 bytes from port: (hexdump of 12 bytes)
0000  0c 00 00 00 03 00 1d 20-09 00 00 00              ....... ....    

0.286849 ptp_usb_getresp [usb.c:514] (0): PTP_OC 0x9107 receiving resp failed: PTP Invalid Parameter (0x201d)
0.286876 get_file_func [library.c:7596](0): 'ptp_canon_eos_getpartialobject (params, oid, offset, xsize, &ximage)' failed: 'PTP Invalid Parameter' (0x201d)
0.286914 gp_context_error            (0): PTP Invalid Parameter

TL;DR: The patch didn't make much of a difference, should I still play around with the sleep time? This seems to be a problem specifically with downloading a file in multiple parts. There is some sort of invalid parameter being passed to ptp_canon_eos_getpartialobject, but (Get object) works fine in the lower sized images.

sinaghaffari commented 5 years ago

Any updates to this? Should I move this to the libgphoto2 issues?

msmeissn commented 5 years ago

Sorry for not getting back sooner.

The EOS GetPartialObject call fails ... I changed in git to use the regular GetPartialObject from the PTP base set, can you check if that helps? Either via current GIT, or via attached patch.

xx.txt

sinaghaffari commented 5 years ago

No worries! Looks like the same error, even with the other function call my-logfile.txt

13.098935 camera_wait_for_event       (2): Found new object! OID 0x300073b1, name °s
13.099046 camera_wait_for_event       (2): trying to get object size=0x22442ee
13.099068 ptp_usb_sendreq             (2): Sending PTP_OC 0x101b (Get partial object) (0x300073b1,0x0,0x500000) request...
13.099081 gp_port_write               (3): Writing 24 = 0x18 bytes to port...
13.099288 gp_port_write               (3): Wrote   24 = 0x18 bytes to port: (hexdump of 24 bytes)
0000  18 00 00 00 01 00 1b 10-46 02 00 00 b1 73 00 30  ........F....s.0
0010  00 00 00 00 00 00 50 00-                         ......P.        

13.099310 ptp_usb_getdata             (2): Reading PTP_OC 0x101b (Get partial object) data...
13.099323 gp_port_read                (3): Reading 1024 = 0x400 bytes from port...
13.105309 gp_port_read                (3): Read    12 = 0xc out of 1024 bytes from port: (hexdump of 12 bytes)
0000  0c 00 00 00 02 00 1b 10-46 02 00 00              ........F...    

13.105548 ptp_usb_getresp             (2): Reading PTP_OC 0x101b (Get partial object) response...
13.105569 gp_port_read                (3): Reading 1024 = 0x400 bytes from port...
13.106169 gp_port_read                (3): Read    12 = 0xc out of 1024 bytes from port: (hexdump of 12 bytes)
0000  0c 00 00 00 03 00 1d 20-46 02 00 00              ....... F...    

13.106264 ptp_usb_getresp [usb.c:514] (0): PTP_OC 0x101b receiving resp failed: PTP Invalid Parameter (0x201d)
13.106289 camera_wait_for_event [library.c:5539](0): 'ptp_getpartialobject (params, newobject, offset, xsize, &yimage, &xsize)' failed: 'PTP Invalid Parameter' (0x201d)
13.106434 gp_context_error            (0): PTP Invalid Parameter
13.106547 gp_camera_wait_for_event [gphoto2-camera.c:1451](0): 'camera->functions->wait_for_event ( camera, timeout, eventtype, eventdata, context)' failed: -1
13.108658 gp_camera_free              (2): Freeing camera...
13.108794 gp_camera_exit              (2): Exiting camera ('Canon EOS R')...
msmeissn commented 5 years ago

THis is weird. hard to sayx which is the invalid parameter. the objectid or the partial size...

there are 3

define BLOBSIZE 510241024

can you change them to 110241024 and see if it works better afterwards?

msmeissn commented 5 years ago

alternatively you can increase it to always get the GetObject usage (but that would crash other EOS with Error 70)

sinaghaffari commented 5 years ago

IT WORKED! OH MAN!

Thank you for your help :) Changing to

#define BLOBSIZE 1*1024*1024

fixed the issue completely :)

msmeissn commented 5 years ago

Very good, thanks for checking back :))