Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fuji X-T2, USB ID 04cb:02cd #133

Open
jbreiden opened this issue Jan 23, 2017 · 80 comments

Comments

@jbreiden
Copy link

commented Jan 23, 2017

This is the Fuji X-T2 camera. I'll look into USB communication details next.

$ lsusb | grep Fuji
Bus 004 Device 004: ID 04cb:02cd Fuji Photo Film Co., Ltd

--- a/camlibs/ptp2/library.c
+++ b/camlibs/ptp2/library.c
@@ -1978,6 +1978,7 @@ static struct {
        {"Fuji:Fujifilm X-E2",                  0x04cb, 0x02b5, 0},
        /* Vladimir K <enewsletters@inbox.ru> */
        {"Fuji:Fujifilm X-T1",                  0x04cb, 0x02bf, 0},
+        {"Fuji:Fujifilm X-T2",                 0x04cb, 0x02cd, 0},
        /* https://github.com/gphoto/libgphoto2/issues/32 */
        {"Fuji:Fujifilm X-T10",                 0x04cb, 0x02c8, 0},
 

@msmeissn msmeissn closed this in e7b37b1 Jan 23, 2017

@jbreiden

This comment has been minimized.

Copy link
Author

commented Jan 23, 2017

0.066445 print_debug_deviceinfo      (2): Device info:
0.066448 print_debug_deviceinfo      (2): Manufacturer: FUJIFILM
0.066451 print_debug_deviceinfo      (2):   Model: X-T2
0.066453 print_debug_deviceinfo      (2):   device version: 1.00
0.066455 print_debug_deviceinfo      (2):   serial number: '5935333130321611296B3020112361'
0.066457 print_debug_deviceinfo      (2): Vendor extension ID: 0x0000000e
0.066459 print_debug_deviceinfo      (2): Vendor extension version: 100
0.066462 print_debug_deviceinfo      (2): Vendor extension description: fujifilm.co.jp: 1.0; 
0.066464 print_debug_deviceinfo      (2): Functional Mode: 0x0000
0.066466 print_debug_deviceinfo      (2): PTP Standard Version: 100
0.066468 print_debug_deviceinfo      (2): Supported operations:
0.066473 print_debug_deviceinfo      (2):   0x1001 (Get device info)
0.066476 print_debug_deviceinfo      (2):   0x1002 (Open session)
0.066479 print_debug_deviceinfo      (2):   0x1003 (Close session)
0.066482 print_debug_deviceinfo      (2):   0x1004 (Get storage IDs)
0.066484 print_debug_deviceinfo      (2):   0x1005 (Get storage info)
0.066487 print_debug_deviceinfo      (2):   0x1006 (Get number of objects)
0.066489 print_debug_deviceinfo      (2):   0x1007 (Get object handles)
0.066492 print_debug_deviceinfo      (2):   0x1008 (Get object info)
0.066494 print_debug_deviceinfo      (2):   0x1009 (Get object)
0.066497 print_debug_deviceinfo      (2):   0x100a (Get thumbnail)
0.066500 print_debug_deviceinfo      (2):   0x100b (Delete object)
0.066502 print_debug_deviceinfo      (2):   0x100c (Send object info)
0.066505 print_debug_deviceinfo      (2):   0x100d (Send object)
0.066507 print_debug_deviceinfo      (2):   0x100f (Format storage)
0.066510 print_debug_deviceinfo      (2):   0x1014 (Get device property description)
0.066513 print_debug_deviceinfo      (2):   0x1015 (Get device property value)
0.066516 print_debug_deviceinfo      (2):   0x1016 (Set device property value)
0.066518 print_debug_deviceinfo      (2):   0x101b (Get partial object)
0.066521 print_debug_deviceinfo      (2):   0x900c (Unknown VendorExtensionID)
0.066524 print_debug_deviceinfo      (2):   0x900d (Unknown VendorExtensionID)
0.066526 print_debug_deviceinfo      (2):   0x901d (Unknown VendorExtensionID)
0.066529 print_debug_deviceinfo      (2):   0x9801 (Unknown VendorExtensionID)
0.066532 print_debug_deviceinfo      (2):   0x9802 (Unknown VendorExtensionID)
0.066534 print_debug_deviceinfo      (2):   0x9803 (Unknown VendorExtensionID)
0.066537 print_debug_deviceinfo      (2):   0x9805 (Unknown VendorExtensionID)
0.066539 print_debug_deviceinfo      (2): Events Supported:
0.066541 print_debug_deviceinfo      (2):   0x4002 
0.066542 print_debug_deviceinfo      (2):   0x4003
0.066544 print_debug_deviceinfo      (2):   0x4004
0.066546 print_debug_deviceinfo      (2):   0x4005
0.066547 print_debug_deviceinfo      (2):   0x4006
0.066549 print_debug_deviceinfo      (2):   0x4008
0.066551 print_debug_deviceinfo      (2):   0x4009
0.066552 print_debug_deviceinfo      (2): Device Properties Supported:
0.066554 print_debug_deviceinfo      (2):   0x5001
0.066556 print_debug_deviceinfo      (2):   0xd303
0.066558 print_debug_deviceinfo      (2):   0xd406
0.066559 print_debug_deviceinfo      (2):   0xd407
0x4002 ObjectAdded
0x4003 ObjectRemoved
0x4004 StoreAdded
0x4005 StoreRemoved
0x4006 DevicePropChanged
0x4007 ObjectInfoChanged
0x4008 DeviceInfoChanged
0x4009 RequestObjectTransfer 
0x5001 BatteryLevel 
@msmeissn

This comment has been minimized.

Copy link
Contributor

commented Jan 24, 2017

So far there is no indication that it has capture opcodes.
The only unknown opcodes are 900c, 900d, 901d
(The 0x98xx opcodes are generic MTP commands.)
There is no event for capturecomplete.
The 0xd303 and 0xd4xx properties are the standard MTP properties.

While capture might be hiding behind the 0x90xx codes or be hidden from the deviceinfo altogether, this seems unlikely.

@jbreiden

This comment has been minimized.

Copy link
Author

commented Jan 24, 2017

Tethering capability was added in firmware revision 1.1 released Nov 2016. I will update the camera today.

@jbreiden

This comment has been minimized.

Copy link
Author

commented Jan 24, 2017

To my surprise, the newer firmware (which supports tethering) has identical opcodes. I'll will shortly have my hands on a Windows computer and will endeavor to monitor USB communication during tethering. If there is a preferred mechanism for USB sniffing on Windows, please let me know.

0.034602 print_debug_deviceinfo      (2): Device info:
0.034605 print_debug_deviceinfo      (2): Manufacturer: FUJIFILM
0.034607 print_debug_deviceinfo      (2):   Model: X-T2
0.034609 print_debug_deviceinfo      (2):   device version: 1.10
0.034611 print_debug_deviceinfo      (2):   serial number: '5935333130321611296B3020112361'
0.034613 print_debug_deviceinfo      (2): Vendor extension ID: 0x0000000e
0.034614 print_debug_deviceinfo      (2): Vendor extension version: 100
0.034617 print_debug_deviceinfo      (2): Vendor extension description: fujifilm.co.jp: 1.0; 
0.034619 print_debug_deviceinfo      (2): Functional Mode: 0x0000
0.034621 print_debug_deviceinfo      (2): PTP Standard Version: 100
0.034622 print_debug_deviceinfo      (2): Supported operations:
0.034627 print_debug_deviceinfo      (2):   0x1001 (Get device info)
0.034629 print_debug_deviceinfo      (2):   0x1002 (Open session)
0.034631 print_debug_deviceinfo      (2):   0x1003 (Close session)
0.034634 print_debug_deviceinfo      (2):   0x1004 (Get storage IDs)
0.034636 print_debug_deviceinfo      (2):   0x1005 (Get storage info)
0.034638 print_debug_deviceinfo      (2):   0x1006 (Get number of objects)
0.034640 print_debug_deviceinfo      (2):   0x1007 (Get object handles)
0.034643 print_debug_deviceinfo      (2):   0x1008 (Get object info)
0.034645 print_debug_deviceinfo      (2):   0x1009 (Get object)
0.034647 print_debug_deviceinfo      (2):   0x100a (Get thumbnail)
0.034649 print_debug_deviceinfo      (2):   0x100b (Delete object)
0.034651 print_debug_deviceinfo      (2):   0x100c (Send object info)
0.034654 print_debug_deviceinfo      (2):   0x100d (Send object)
0.034656 print_debug_deviceinfo      (2):   0x100f (Format storage)
0.034658 print_debug_deviceinfo      (2):   0x1014 (Get device property description)
0.034661 print_debug_deviceinfo      (2):   0x1015 (Get device property value)
0.034663 print_debug_deviceinfo      (2):   0x1016 (Set device property value)
0.034665 print_debug_deviceinfo      (2):   0x101b (Get partial object)
0.034668 print_debug_deviceinfo      (2):   0x900c (Unknown VendorExtensionID)
0.034670 print_debug_deviceinfo      (2):   0x900d (Unknown VendorExtensionID)
0.034672 print_debug_deviceinfo      (2):   0x901d (Unknown VendorExtensionID)
0.034674 print_debug_deviceinfo      (2):   0x9801 (Unknown VendorExtensionID)
0.034677 print_debug_deviceinfo      (2):   0x9802 (Unknown VendorExtensionID)
0.034679 print_debug_deviceinfo      (2):   0x9803 (Unknown VendorExtensionID)
0.034681 print_debug_deviceinfo      (2):   0x9805 (Unknown VendorExtensionID)
0.034683 print_debug_deviceinfo      (2): Events Supported:
0.034684 print_debug_deviceinfo      (2):   0x4002
0.034686 print_debug_deviceinfo      (2):   0x4003
0.034687 print_debug_deviceinfo      (2):   0x4004
0.034689 print_debug_deviceinfo      (2):   0x4005
0.034690 print_debug_deviceinfo      (2):   0x4006
0.034692 print_debug_deviceinfo      (2):   0x4008
0.034693 print_debug_deviceinfo      (2):   0x4009
0.034695 print_debug_deviceinfo      (2): Device Properties Supported:
0.034696 print_debug_deviceinfo      (2):   0x5001
0.034698 print_debug_deviceinfo      (2):   0xd303
0.034699 print_debug_deviceinfo      (2):   0xd406
0.034701 print_debug_deviceinfo      (2):   0xd407
@msmeissn

This comment has been minimized.

Copy link
Contributor

commented Jan 24, 2017

In in earlier times used SnoopyPro. Not sure if it still lives..

Can you try

gphoto2 --capture-tethered

and press shutter button and see if something happens?

@msmeissn msmeissn reopened this Jan 24, 2017

@jbreiden

This comment has been minimized.

Copy link
Author

commented Jan 24, 2017

Nothing. I'll play with the camera and make sure that I'm in the right mode.

31.309643 camera_wait_for_event       (2): no events received.
31.309653 camera_wait_for_event       (2): waiting for events timeout 1000 ms
31.309661 gp_port_get_timeout         (2): Current port timeout is 20000 milliseconds.
31.309667 gp_port_set_timeout         (2): Setting port timeout to 150 milliseconds.
31.309674 gp_port_check_int           (3): Reading 24 = 0x18 bytes from interrupt endpoint...
31.459909 gp_port_check_int           (3): Reading 24 = 0x18 bytes from interrupt endpoint...
31.610150 gp_port_set_timeout         (2): Setting port timeout to 20000 milliseconds.
31.610200 ptp_usb_event [usb.c:530]   (0): Reading PTP event failed: Timeout reading from or writing to the port (-10)
@jbreiden

This comment has been minimized.

Copy link
Author

commented Jan 24, 2017

Now with the camera in the correct mode (Connection Setting > PC Shoot Mode > USB Auto) we get a lot more. Still nothing from gphoto2 --capture-tethered

log.txt

@jbreiden

This comment has been minimized.

Copy link
Author

commented Jan 24, 2017

Wait, maybe I am getting something. Need to charge battery.

@jbreiden

This comment has been minimized.

Copy link
Author

commented Jan 24, 2017

$ gphoto2 --capture-tethered --camera="Fuji Fujifilm X-T2" --debug --debug-logfile=/tmp/debug.txt --debug-loglevel=debug
Waiting for events from camera. Press Ctrl-C to abort.                         
Saving file as DSCF0001.jpg                                                    
^C
Cancelling...

debug.txt

@msmeissn

This comment has been minimized.

Copy link
Contributor

commented Jan 25, 2017

0.035898 print_debug_deviceinfo (2): 0x100e (Initiate capture)

gphoto2 --capture-image now should also work

@jbreiden

This comment has been minimized.

Copy link
Author

commented Jan 26, 2017

$ gphoto2 --capture-image
                                                                               
*** Error ***              
PTP Device Busy
ERROR: Could not capture image.
ERROR: Could not capture.
*** Error (-110: 'I/O in progress') ***       

For debugging messages, please use the --debug option.
Debugging messages may help finding a solution to your problem.
If you intend to send any error or debug messages to the gphoto
developer mailing list <gphoto-devel@lists.sourceforge.net>, please run
gphoto2 as follows:

    env LANG=C gphoto2 --debug --debug-logfile=my-logfile.txt --capture-image

Please make sure there is sufficient quoting around the arguments.

debug.txt

@msmeissn

This comment has been minimized.

Copy link
Contributor

commented Jan 27, 2017

usually that should just work as is when called. hard to say why it reports busy :(

can you get output of:

gphoto2 --summary > summary.txt
gphoto2 --list-all-config > allconfig.txt

@jbreiden

This comment has been minimized.

Copy link
Author

commented Jan 27, 2017

Had to reschedule USB tracing, should have that by the end of Monday.

summary.txt
allconfig.txt

msmeissn added a commit that referenced this issue Jan 29, 2017

@jbreiden

This comment has been minimized.

Copy link
Author

commented Jan 30, 2017

@jbreiden

This comment has been minimized.

Copy link
Author

commented Feb 2, 2017

Decoded USB traces added to same location. Note the double call to InitiateCapture.

@jbreiden

This comment has been minimized.

Copy link
Author

commented Feb 2, 2017

I think the camera is unhappy and becomes "PTP Device Busy" because when we try to list the files on the camera. Here is what gphoto2 is doing.

$ gphoto2 --debug --capture-image |& grep Sending | cut -f2 -d:
 Sending PTP_OC 0x1002 (Open session) (0x1) request...
 Sending PTP_OC 0x1001 (Get device info) request...
 Sending PTP_OC 0x1007 (Get object handles) (0xffffffff,0x0,0xffffffff) request...
 Sending PTP_OC 0x1004 (Get storage IDs) request...
 Sending PTP_OC 0x1007 (Get object handles) (0x10000001,0x0,0xffffffff) request...
 Sending PTP_OC 0x1007 (Get object handles) (0x10000002,0x0,0xffffffff) request...
 Sending PTP_OC 0x100e (Initiate capture) (0x0,0x0) request...
 FAIL

Comparing to the working USB trace, there isn't any attempt to get object handles until after capture is complete. And when it does happen, it looks different to my eye.

$ grep COMMAND Single\ Shot.txt | cut -f4- -d: | less
...
PTP_OC_InitiateCapture         trans:831c payload:'\x00\x00\x00\x00\x00\x00\x00\x00'
...
PTP_OC_InitiateCapture         trans:835e payload:'\x00\x00\x00\x00\x00\x00\x00\x00'
...
PTP_OC_GetObjectHandles        trans:8365 payload:'\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00'
PTP_OC_GetObjectInfo           trans:8366 payload:'\x07\x00\x00\x00'
PTP_OC_GetObjectInfo           trans:8367 payload:'\x07\x00\x00\x00'
PTP_OC_GetObjectInfo           trans:8368 payload:'\x07\x00\x00\x00'
PTP_OC_MTP_GetObjPropList      trans:8369 payload:'\x07\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00'
PTP_OC_GetObject               trans:836a payload:'\x07\x00\x00\x00'
PTP_OC_DeleteObject            trans:836b payload:'\x07\x00\x00\x00'
...

@msmeissn msmeissn self-assigned this Feb 3, 2017

@msmeissn

This comment has been minimized.

Copy link
Contributor

commented Feb 3, 2017

This is very helpful, thanks. It is setting various properties, that is probably more the reason.

(currently a bit busy witjh work and FOSDEM travel, hope to have some time next week to check it out more)

@jbreiden

This comment has been minimized.

Copy link
Author

commented Feb 6, 2017

This appears to be the magical incantation to allow InitiateCapture() to work. Only works once per camera powercycle. This will make the camera beep, presumably indicating successful autofocus.

propval.u16 = 0x0002; C_PTP_REP (ptp_setdevicepropvalue (params, 0xd207, &propval, PTP_DTC_UINT16));
propval.u16 = 0x0200; C_PTP_REP (ptp_setdevicepropvalue (params, 0xd208, &propval, PTP_DTC_UINT16));
C_PTP_REP(ptp_initiatecapture(params, 0x00000000, 0x00000000));

Add in this part, and we get a click sound after the beep.

usleep(1000*1000);
propval.u16 = 0x0304; C_PTP_REP (ptp_setdevicepropvalue (params, 0xd208, &propval, PTP_DTC_UINT16));
C_PTP_REP(ptp_initiatecapture(params, 0x00000000, 0x00000000));        

At this point the camera is blocked and unresponsive to further shot requests. The camera has in image in RAM and is very afraid to lose that data. There is a small LED on the camera body the flashes red and green. I have to unplug USB, turn off the power switch, then hit "okay" to actually powercycle and prepare for next shot.

Here's a debug log when I plumb this through --capture-image-and-download.

debuglog.txt

msmeissn added a commit that referenced this issue Feb 7, 2017

@msmeissn

This comment has been minimized.

Copy link
Contributor

commented Feb 7, 2017

ignore last commit, it seems per-captuyre specific.

@msmeissn

This comment has been minimized.

Copy link
Contributor

commented Feb 7, 2017

(thanks for your work so far ... still not yet found time to properly go over it :/ )

@jbreiden

This comment has been minimized.

Copy link
Author

commented Apr 19, 2017

Looking at Fuji XT-2 again. This is what it takes to make a "beep" (presumably autofocus) then a "click" (presumably shutter release) using gphoto2 --trigger-capture. Contrary to my earlier reports above, the only property I'm messing with is 0xd208. And this is sufficient run multiple times without power cycling. Yay. I am going to try to rewrite this for real. (Also, we need to revert c998fcd which is causing harm)

happy.txt

--- a/camlibs/ptp2/library.c
+++ b/camlibs/ptp2/library.c
@@ -4577,7 +4577,15 @@ camera_trigger_capture (Camera *camera, GPContext *context)
                        _("Sorry, your camera does not support generic capture"));
                return GP_ERROR_NOT_SUPPORTED;
        }
-       C_PTP_REP (ptp_initiatecapture(params, 0x00000000, 0x00000000));
+        {
+          PTPPropertyValue     propval;
+          propval.u16 = 0x0200; C_PTP_REP (ptp_setdevicepropvalue (params, 0xd208, &propval, PTP_DTC_UINT16));
+          C_PTP_REP (ptp_initiatecapture(params, 0x00000000, 0x00000000));
+          usleep(1000*1000);
+          propval.u16 = 0x0304; C_PTP_REP (ptp_setdevicepropvalue (params, 0xd208, &propval, PTP_DTC_UINT16));
+          C_PTP_REP(ptp_initiatecapture(params, 0x00000000, 0x00000000));
+        }
+
        return GP_OK;
 }
@jbreiden

This comment has been minimized.

Copy link
Author

commented Apr 19, 2017

... And now I can't communicate with the camera under any circumstance. Same code, nothing obviously different from the logs. Powercycled camera including primary battery removal. Wasn't fooling around with camera settings.

sad.txt

0.163308 camera_trigger_capture      (2): camera_trigger_capture
0.163321 camera_trigger_capture      (2): Triggering capture to , autofocus=0
0.163329 camera_trigger_capture      (2): XXX Hey
0.163356 ptp_usb_sendreq             (2): Sending PTP_OC 0x1016 (Set device property value) (0xd208) request...
0.163428 ptp_usb_senddata            (2): Sending PTP_OC 0x1016 (Set device property value) data...
0.163499 ptp_usb_getresp             (2): Reading PTP_OC 0x1016 (Set device property value) response...
0.363983 ptp_usb_sendreq             (2): Sending PTP_OC 0x100e (Initiate capture) (0x0,0x0) request...
0.364127 ptp_usb_getresp             (2): Reading PTP_OC 0x100e (Initiate capture) response...
0.364739 ptp_usb_getresp [usb.c:466] (0): PTP_OC 0x100e receiving resp failed: PTP Device Busy (0x2019)
0.364752 camera_trigger_capture [library.c:4585](0): 'ptp_initiatecapture(params, 0x00000000, 0x00000000)' failed: 'PTP Device Busy' (0x2019)
0.364763 gp_context_error            (0): PTP Device Busy

*** Error ***              
PTP Device Busy
0.364778 gp_camera_trigger_capture [gphoto2-camera.c:1369](0): 'camera->functions->trigger_capture (camera, context)' failed: -110
ERROR: Could not trigger capture.
*** Error (-110: 'I/O in progress') ***       
@jbreiden

This comment has been minimized.

Copy link
Author

commented Apr 24, 2017

Flashed camera firmware to from v1.10 to v2.00; no change. Camera does not want to talk to me anymore.

@msmeissn

This comment has been minimized.

Copy link
Contributor

commented Apr 24, 2017

urks :( sorry to hear :(

and sorry i currently did not pursue this issue further .. quite busy and i focused a bit more on pentax and canon eos m, but wanted to get back here

@msmeissn

This comment has been minimized.

Copy link
Contributor

commented Apr 24, 2017

check for possible causes of busy condit9ion ... sd card full? bttery empty? ;)

@jbreiden

This comment has been minimized.

Copy link
Author

commented May 17, 2017

Thank you! The checked in code works, but is still too slow. I'm not totally sure where the speed problem is, but I have this variation running right now at 75+ shots per minute. We'll see what happens when it reaches 32K shots.

static int
camera_fuji_capture (Camera *camera, CameraCaptureType type, CameraFilePath *path, GPContext *context)
{
	PTPParams		*params = &camera->pl->params;
	PTPPropertyValue	propval;
	PTPObjectHandles	handles, beforehandles;
	PTPObject               *ob;

	GP_LOG_D ("camera_fuji_capture");

	C_PTP (ptp_getobjecthandles (params, PTP_HANDLER_SPECIAL, 0x000000, 0x000000, &beforehandles));

	/* focus */
	propval.u16 = 0x0200;
	C_PTP_REP (ptp_setdevicepropvalue (params, 0xd208, &propval, PTP_DTC_UINT16));
	C_PTP_REP(ptp_initiatecapture(params, 0x00000000, 0x00000000));

	/* poll camera until it is ready */
	propval.u16 = 0x0001;
	while (propval.u16 == 0x0001) {
		ptp_getdevicepropvalue (params, 0xd209, &propval, PTP_DTC_UINT16);
	}

	/* shoot */
	propval.u16 = 0x0304;
	C_PTP_REP (ptp_setdevicepropvalue (params, 0xd208, &propval, PTP_DTC_UINT16));
	C_PTP_REP (ptp_initiatecapture(params, 0x00000000, 0x00000000));

        /* poll until image is ready */
	while (1) {
		usleep(20 * 1000);
		C_PTP_REP (ptp_getobjecthandles (params, PTP_HANDLER_SPECIAL, 0x000000, 0x000000, &handles));
		if (handles.n == beforehandles.n) continue;
		C_PTP_REP (ptp_object_want (params, handles.Handler[handles.n - 1], PTPOBJECT_OBJECTINFO_LOADED, &ob));
		if (ob->oi.ObjectFormat != PTP_OFC_Association) break;
	}

	/* extract image path */
	path->name[0]='\0';
	path->folder[0]='\0';
        strcpy  (path->name,  ob->oi.Filename);
	sprintf (path->folder,"/"STORAGE_FOLDER_PREFIX"%08lx/",(unsigned long)ob->oi.StorageID);
	get_folder_from_handle (camera, ob->oi.StorageID, ob->oi.ParentObject, path->folder);
	path->folder[ strlen(path->folder)-1 ] = '\0';

        /* clean up and write image data */
        free (handles.Handler);
	free (beforehandles.Handler);
        return gp_filesystem_append (camera->fs, path->folder, path->name, context);
}
@jbreiden

This comment has been minimized.

Copy link
Author

commented Jun 7, 2017

Unless I am very confused, I think these should be PTP_DTC_UINT16

https://github.com/gphoto/libgphoto2/blob/master/camlibs/ptp2/library.c#L3978
https://github.com/gphoto/libgphoto2/blob/master/camlibs/ptp2/library.c#L4748

Also, when polling the camera, we currently look for everything and then explicitly ignore directories. It's more elegant to ask the camera for handles from images only, which can be done by feeding the parameter 0xFFFFU to the third parameter of GetObjectHandles instead of 0x000000.

https://github.com/gphoto/libgphoto2/blob/master/camlibs/ptp2/library.c#L4035

@msmeissn

This comment has been minimized.

Copy link
Contributor

commented Jun 15, 2017

the last ... i doubt it makes any kind of speed difference.

for the first, i used your patch. The 0xD212 property seems to occasionaly return more data in your traces, but this might be a mistake of the tracing tool?

@jbreiden

This comment has been minimized.

Copy link
Author

commented Jun 20, 2017

FujiFilm GFX 50 S is 04cb:02d3 on USB. Works fine.

@msmeissn

This comment has been minimized.

Copy link
Contributor

commented Jun 20, 2017

does the GFX 50S support capture?

@jbreiden

This comment has been minimized.

Copy link
Author

commented Jul 10, 2017

Yes, the GFX 50S supports capture.

@jbreiden

This comment has been minimized.

Copy link
Author

commented Jul 10, 2017

Here are the results of querying the camera itself about properties. There are a few weird ones. As far as I can tell 0xd212 completely violates the PTP specification; amongst other things it has an invalid datatype code. 0xd153 is missing the form field, which I think is required. All the string properties are also missing the form field, but I don't know if that violates the PTP specification or not.

fuji-xt-2-properties.txt

@ghost

This comment has been minimized.

Copy link

commented Aug 31, 2017

A friend has lent me a Fuji X-T2 to test with my code, but I'm having problem with gphoto2.
As you can see, gphoto2 2.5.14 is able to capture and download images from the camera, even if it returns an error on strating. But as long as I just use "--capture-image" it reports more severe errors and I have to reboot che computer to be able to shoot again!

Having tried also "--reset" with no results. Is there something I can try, softer that reboot?

Also, is there a way to simulate the same behaviour as "--capture-image-and-download" using the Python binding to libghoto2 since just capturing an image would not work?

Debug files are very big, even when zipped. I can send/attache the relevant parts if needed.

root# env LANG=C gphoto2 --debug --debug-logfile=fujixt2-1.txt --port usb:001,005 --capture-image-and-download

*** Error ***
PTP General Error
ERROR: Could not capture image.
ERROR: Could not capture.
New file is in location /store_10000001/DSCF0001.jpg on the camera
Saving file as DSCF0001.jpg
Deleting file /store_10000001/DSCF0001.jpg on the camera
root# env LANG=C gphoto2 --debug --debug-logfile=fujixt2-2.txt --port usb:001,005 --capture-image-and-download
New file is in location /store_10000001/DSCF0002.jpg on the camera
Saving file as DSCF0002.jpg
Deleting file /store_10000001/DSCF0002.jpg on the camera
root# env LANG=C gphoto2 --debug --debug-logfile=fujixt2-3.txt --port usb:001,005 --capture-image
New file is in location /store_10000001/DSCF0003.jpg on the camera
root# env LANG=C gphoto2 --debug --debug-logfile=fujixt2-4.txt --port usb:001,005 --capture-image

*** Error ***
An error occurred in the io-library ('Unknown error'): No error description available
ERROR: Could not capture image.
ERROR: Could not capture.
*** Error (-110: 'I/O in progress') ***

root# env LANG=C gphoto2 --debug --debug-logfile=fujixt2-5.txt --port usb:001,005 --capture-image

*** Error ***
An error occurred in the io-library ('Unknown error'): No error description available
ERROR: Could not capture image.
ERROR: Could not capture.
*** Error (-110: 'I/O in progress') ***

root# env LANG=C gphoto2 --debug --debug-logfile=fujixt2-6.txt --port usb:001,005 --capture-image-and-download

*** Error ***
An error occurred in the io-library ('Unknown error'): No error description available
ERROR: Could not capture image.
ERROR: Could not capture.
*** Error (-110: 'I/O in progress') ***

@elijahparker

This comment has been minimized.

Copy link
Contributor

commented Sep 22, 2017

I've been doing a bit of work with Fuji here this week and it's been quite interesting. I've got full camera control (ISO, shutter, aperture) as well as live view and reliable capture. Like @jbreiden noted, it seems to violate standards in many ways. For switching to PC mode (to then allow setting the camera parameters), it requires setting a property, 0xd38c, to 1, which isn't even listed in the camera's supported property codes. @msmeissn -- is there a system in place to handle properties that are not reported? Right now to make it work I hacked _set_config in config.c to allow a list of hidden properties if the vendor is Fuji, but it's messy.

Also, capture would fail for shutter speeds longer than a few seconds. This is due to detecting the "object added" event. 0xd212 polls events, but the current code was triggering any time a single event was detected. It actually turns out that first byte is the number of events, followed by a array with an item size of 6 bytes, the first 2 the property, and the last 4 the value. Here's the code I'm using to parse this:

uint16_t ptp_fuji_getevents (PTPParams* params, uint16_t** events, uint16_t* count)
{
        PTPContainer    ptp;
        unsigned char   *data;
        unsigned int    size;
        uint16_t        ret;                  

        PTP_CNT_INIT(ptp, PTP_OC_GetDevicePropValue, 0xd212);
        CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &size));
        ptp_debug(params, "ptp_fuji_getevents");
        int i;                    
        *count = 0;                         
        if(size >= 2)
        {
                memcpy(count, data, 2);
                ptp_debug(params, "event count: %d", *count);
                *events = calloc(*count, sizeof(uint16_t));
                if(size >= 2 + *count * 6)
                {
                        uint16_t param;
                        uint32_t value;
                        for(i = 0; i < *count; i++)
                        {
                                memcpy(&param, &data[2 + 6 * i], 2);
                                memcpy(&value, &data[2 + 6 * i + 2], 4);
                                *events[i] = param;
                                ptp_debug(params, "param: %02x, value: %d ", param, value);
                        }
                }             
        }
        free(data);
        return PTP_RC_OK;        
}

The event property that appears to signify the object added is 0xd20d, and this seems to be very reliable on the Fuji X-T1 I'm using for testing. Here's code in the capture routine that looks for this:

/* poll camera until it is ready */        
propval.u16 = 0x0000;
int loops = 0, i;
uint16_t *events;
uint16_t count, ready = 0;  
while (loops < 3300) { // loop for about 33 seconds max
        ptp_fuji_getevents (params, &events, &count);
        if(count > 0) {
                for(i = 0; i < count; i++) {
                        if(events[i] == 0xd20d) {
                                ready = 1;
                                break;        
                        }
                }                   
                free(events);
                if(ready) break;
        }
        C_PTP_REP (ptp_check_event (params));
        usleep(10000);       
        i++;              
}

I'm still trying to figure out how to best incorporate everything now. The main thing is how unlisted properties are handled.

Thanks @jbreiden and @msmeissn for getting it this far!

@msmeissn

This comment has been minimized.

Copy link
Contributor

commented Sep 24, 2017

fixup_cached_deviceinfo if something is not reported. or just set it if its not there.

interesting findings. :)

@msmeissn

This comment has been minimized.

Copy link
Contributor

commented Sep 24, 2017

as reports came in that older firmwares do not like getting unknown properties, this might be tricky to determine fwiw.

@jbreiden

This comment has been minimized.

Copy link
Author

commented Sep 25, 2017

I'm no longer using gphoto2 so have not kept my findings up to date. But I am able to communicate just fine with the camera over PTP these days. I never touch property 0xd38c. Instead, I use property 0xd207and set it to 2 for remote control and 1 for local control. This works when the camera has the USB AUTO setting. For detecting the photo, I poll the camera for image object handles only. You can do that by passing 0xFFFFU to the GetObjectHandles opcode 0x1007. Let me know if you have any further questions. I'm able to set a variety of parameters programatically including exposure time, ISO, white balance mode, white balance fine tune, exposure program mode, and a couple others.

@elijahparker

This comment has been minimized.

Copy link
Contributor

commented Sep 25, 2017

@msmeissn thanks for the info! I'll check out fixup_cached_deviceinfo. If it comes to it, I suppose properties could be added per camera model. Once I've got everything cleaned up and working well, I'll try to put together a pull request.

@elijahparker

This comment has been minimized.

Copy link
Contributor

commented Sep 25, 2017

@jbreiden I appreciate the reply! Very interesting about not needing 0xd38c. That has not been my experience, but I will try again. Perhaps it's different with the X-T1, but I hope not. Good to know about polling object handles. Further testing my method posted above, I was still sometimes missing events after 1k+ frames. So once you get the object handles, do you just download all of them and then delete them afterward? I've found that objects need to be deleted since it seems to save a copy to both the camera's RAM as well as the card (if present), and the RAM object needs to be removed. Is it the same for you? Also, is the code for the project you've switched to online as well? Thanks!

@jbreiden

This comment has been minimized.

Copy link
Author

commented Sep 25, 2017

I only use RAM and keep the card slot empty. I've had no problems shooting continuously for 300k+ shots on both the X-T2 and GFX 50S. This works both in normal mode (shoot then download) or when pipelining (shoot then download previous image). You have to be a little careful not to strand an image in RAM because the camera really hates that. Note that the folder name changes after 64K shots. That will generate an object handle, but I don't have to worry about it due to the restriction to image only handles. I am now working with proprietary code so I can't share it, but happy to discuss what I've learned about the camera either here or some other venue.

@msmeissn

This comment has been minimized.

Copy link
Contributor

commented Sep 25, 2017

as reports came in that older firmwares do not like getting unknown properties, this might be tricky to determine fwiw.

@jbreiden

This comment has been minimized.

Copy link
Author

commented Oct 4, 2017

@elijahparker How far did you get figuring out property 0xd208? I only know three so far: half press is 0x0200, full press is 0x0304 and half press release is 0x0004. Also how did you get live view? Maybe we should talk directly.

 PtpDevicePropertyDescriptor {
  property_code=0xD208
  datatype_code=0x0004
  settable=y
  factory_default_value=772
  current_value=772
  supported_value=260
  supported_value=512
  supported_value=4
  supported_value=772
  supported_value=1280
  supported_value=12
  supported_value=40960
  supported_value=6
  supported_value=36864
  supported_value=2
  supported_value=37120
  supported_value=1
  supported_value=37632
  supported_value=5
}

msmeissn added a commit that referenced this issue Nov 15, 2017

msmeissn added a commit that referenced this issue Nov 15, 2017

prototype ptp_fuji_getevents
hook polling into fuji capture for testing

#133
@msmeissn

This comment has been minimized.

Copy link
Contributor

commented Nov 15, 2017

I tried this with a XT-2 of a colleague today and the d202 does not seem to do receive changes here.
also d38c seems not settable.

did you make any further progress here?

@anarcat

This comment has been minimized.

Copy link

commented Jul 18, 2018

so for what it's worth, i have a X-T2 body with the latest (i believe) firmware version 4.10 here and capture definitely does not work with gphoto2 2.5.17-1 as compiled in debian unstable (but running in stable/stretch). I get the Sorry, your camera does not support generic capture error, with the following logfile:

my-logfile.txt

i'm available for further debugging if that's useful at all. it would be great to see this working! but in the meantime, maybe it would be better to add a notice about the problems here in the support page so people know it's not quite there yet...

more debug info:

$ gphoto2 --auto-detect
Modèle                        Port                                             
----------------------------------------------------------
Fuji Fujifilm X-T2             usb:002,034     

HTH!

@jbreiden

This comment has been minimized.

Copy link
Author

commented Jul 18, 2018

I haven't used gphoto2 for a while, but I did write some other software that happily talks to the X-T2 on a daily basis. Will take a look when I have the chance.

SET UP > CONNECTION SETTING > PC SHOOT MODE : USB AUTO

@msmeissn

This comment has been minimized.

Copy link
Contributor

commented Jul 19, 2018

I used a colleagues XT-2 soem days ago, it was working fine with capture :/

@darix

This comment has been minimized.

Copy link

commented Jul 21, 2018

@jbreiden Where is your software?

@jbreiden

This comment has been minimized.

Copy link
Author

commented Jul 21, 2018

@darix proprietary

@anarcat

This comment has been minimized.

Copy link

commented Jul 22, 2018

SET UP > CONNECTION SETTING > PC SHOOT MODE : USB AUTO

Duh. I didn't remember I had set that to "USB card" mode or something. Obviously, it works with that, although live view doesn't which is kind of annoying.. But thanks!

@darix

This comment has been minimized.

Copy link

commented Jul 22, 2018

live view will probably work in master. you can grab the tarball from here https://build.opensuse.org/package/show/graphics/libgphoto2 or pull it via github and build that. that should give you all the improvements from the hackweek, where @msmeissn tested with my x-t2

@darix

This comment has been minimized.

Copy link

commented Jul 22, 2018

@jbreiden pity :P

@anarcat

This comment has been minimized.

Copy link

commented Jul 22, 2018

@jbreiden

This comment has been minimized.

Copy link
Author

commented Jul 23, 2018

I'm attaching an annotated transcript of exactly what I send to the Fuji X-T2 with my own progam. Hope it helps, and happy to discuss with @msmeissn or @elijahparker. I have never attempted setting either d38c or d202.

EDIT: I just tried setting d38c on an Fuji X-T2 with ancient firmware, and didn't get an error. As far as I can tell, it didn't actually do anything. Not sure what d202 is even supposed to do.

transcript.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants
You can’t perform that action at this time.