gphoto / libgphoto2

The libgphoto2 camera access and control library.
GNU Lesser General Public License v2.1
991 stars 317 forks source link

Nikon Z50 sometimes times out and failing capture #925

Open georgeman93 opened 9 months ago

georgeman93 commented 9 months ago

We have a Nikon Z50 camera (firmware version 2.3) connected to an Intel NUC via a Raspberry Pi and ethernet cable (using the Ethernet cable to provide a virtual USB bridge with the VirtualHere service.

We are running a simple unit test similar to the sample-capture.c example, attempting to capture images in a loop.

We are experiencing inconstant behaviour - sometimes it succeeds for hundreds of captures, recently one of our cameras would regularly fail on the 2nd attempt. Rebooting the camera didn't fix the issue - rather strangely the issue went away after we ran the code in the debugger once.

Swapping a new camera into the same ethenet USB bridge setup worked for 100+ captures so we are reasonably confident that the ethernet USB bridge isn't a showstopper.

Based on the log output, we believed that this was related to Bad handling of unhandled events in camera_nikon_capture · Issue #846 · gphoto/libgphoto2 · GitHub But we are using the newest mingw64 build which uses libgphoto2 2.5.31 libgphoto2_port 0.12.2

See our log output r4.log

It seems like we are continually receiving PTP_EC_DevicePropChanged events until we hit the 70 second timeout with param PTP_DPC_NIKON_ExposureIndicateStatus in other logs we have also seen PTP_DPC_NIKON_RecordingMedia PTP_DPC_NIKON_MovieRecFrameCount

I eventually get the following, this seems to make sense as I don't have an image to get info on. I0911 13:22:13.362910 16100 LogUtils.cpp:123] [Level: 0 | Domain: camera_nikon_capture [library.c:4239]] 'ptp_getobjectinfo (params, newobject, &oi)' failed: PTP Invalid Object Handle (0x2009) I0911 13:22:13.362910 16100 LogUtils.cpp:123] [Level: 0 | Domain: gp_camera_capture [gphoto2-camera.c:1324]] 'camera->functions->capture (camera, type, path, context)' failed: -1

Looking at the code in libgphoto2\libgphoto2\camlibs\ptp2\library.c for camera_capture(), it seems like we should receive PTP_EC_ObjectAdded (0x4002) or PTP_EC_CaptureComplete (0x400D) for the capture to succeed which we are not receiving. Oddly, I dont see these codes in the log for the initial successful capture.

I wonder what is really going on here, how we can prevent this in the future and if the camera gets into this state, how can we reset it without physically touching the camera (only libgphoto2 commands).

geeze123 commented 3 weeks ago

I have the same/similar symptoms on a Nikon D780. In this case, "capture-tethered" is used to fetch the files as they are created (SDRAM), and the photos are trigged via a trig cable.

libgphoto2 2.5.31 libgphoto2_port 0.12.2 gphoto2 2.5.28