libgphoto2
libgphoto2 copied to clipboard
`gp_camera_exit` returns `-1: Unspecified error` for Fujifilm X100V
Describe the bug
Function gp_camera_exit
returns -1: Unspecified error
for Fujifilm X100V
This bug manifested itself in my workflow originally via the rapid-photo-downloader
tool. There is a bug report here: https://github.com/damonlynch/rapid-photo-downloader/issues/117
I was able to reproduce the original problem using with a C program linking only to libgphoto2 (see below)
Name the camera Camera name as shown by gphoto2 --auto-detect or USB IDs
Model Port
----------------------------------------------------------
Fuji Fujifilm X100V usb:001,014
libgphoto2 and gphoto2 version output of: gphoto2 --version
gphoto2 2.5.28
Copyright (c) 2000-2021 Marcus Meissner 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.28 gcc, popt(m), exif, cdk, aa, jpeg, readline
libgphoto2 2.5.28 standard camlibs (SKIPPING docupen lumix), gcc, no ltdl, EXIF
libgphoto2_port 0.12.0 iolibs: disk ptpip serial usb usbdiskdirect usbscsi, gcc, no ltdl, EXIF, USB, serial without locking
To Reproduce
Steps to reproduce the behavior:
Compile the following C program:
#include <stdio.h>
#include "gphoto2/gphoto2.h"
#include "gphoto2/gphoto2-version.h"
int test() {
Camera* camera = NULL;
CameraWidget* config = NULL;
int error = GP_OK;
printf("gp_camera_new\n");
error = gp_camera_new(&camera);
if (error) return error;
printf("gp_camera_init\n");
error = gp_camera_init(camera, NULL);
if (error) return error;
printf("get_camera_get_config\n");
error = gp_camera_get_config(camera, &config, NULL);
if (error) return error;
printf("gp_camera_exit\n");
error = gp_camera_exit(camera, NULL);
if (error) return error;
printf("gp_camera_unref\n");
error = gp_camera_unref(camera);
return error;
}
int main() {
printf("libgphoto2 version %s\n", *gp_library_version(0));
int result = test();
printf("result: %d: %s\n", result, gp_result_as_string(result));
return 0;
}
with
gcc test.c -lgphoto2
In my case, I'm testing with a locally installed copy of libgphoto2:
gcc test.c -I/home/ciaron/opt/libgphoto2/2.5.28/include/gphoto2 -L/home/ciaron/opt/libgphoto2/2.5.28/lib -lgphoto2 -lgphoto2_port -lm
but the error exists with the standard apt-installed version.
Output is:
libgphoto2 version 2.5.28
gp_camera_new
gp_camera_init
get_camera_get_config
gp_camera_exit
result: -1: Unspecified error
expected output:
libgphoto2 version 2.5.28
gp_camera_new
gp_camera_init
get_camera_get_config
gp_camera_exit
gp_camera_unref
result: 0: No error
Workaround
The error seems to have been introduced by the addition of the Fujifilm X100V model to the codebase at version 2.5.28.
By removing the relevant line (2605) in camlibs/ptp2/library.c (the FujiFilm X100V ID), and recompiling, I was able to run the test code without error.
Let me know if I can help with testing any patches etc.
this happens in camera_exit encounters a protocol error or so.
can you reproduce this with gphoto2 and capture a debugtrace?
From the code it looks like gphoto2 --reset
calls gp_camera_exit
. I did this but it didn't trigger the error. (debug trace attached)
debug.txt
well actually reset does not call the camera driver. can you try this with --summary ?
Here is the output from --summary
with the camera in "USB Card Reader" mode:
Camera summary:
Manufacturer: FUJIFILM
Model: X100V
Version: 3.01
Serial Number: 593535383034210209CB0030218FC7
Vendor Extension ID: 0xe (1.0)
Vendor Extension Description: fujifilm.co.jp: 1.0;
Capture Formats:
Display Formats: JPEG, JFIF
Device Capabilities:
File Download, File Deletion, File Upload
No Image Capture, No Open Capture, No vendor specific capture
Storage Devices Summary:
store_10000001:
StorageDescription: External Memory
VolumeLabel: 000000000000000000000000000000000000000000000000
Storage Type: Removable RAM (memory card)
Filesystemtype: Digital Camera Layout (DCIM)
Access Capability: Read-Write
Maximum Capability: 127865454592 (121942 MB)
Free Space (Bytes): 127421251584 (121518 MB)
Free Space (Images): -1
Device Property Summary:
Battery Level(0x5001):(read only) (type=0x2) Range [0 - 10, step 1] value: 10% (10)
Property 0xd303:(read only) (type=0x2) 1
Property 0xd406:(readwrite) (type=0xffff) ''
Property 0xd407:(read only) (type=0x6) 1
Exposure Time(0x500d): error 200a on query.
F-Number(0x5007): error 200a on query.
LensZoomPosCaps(0xd38c): error 200a on query.
FocusPosition(0xd171): error 200a on query.
Property 0xd21c: error 200a on query.
Focus Point(0xd347): error 200a on query.
LensZoomPos(0xd170): error 200a on query.
BatteryLevel(0xd242): error 200a on query.
LiveViewImageSize(0xd174): error 200a on query.
VideoOutOnOff(0xd168): error 200a on query.
LiveViewImageQuality(0xd173): error 200a on query.
ForceMode(0xd230): error 200a on query.
Property 0xd16e: error 200a on query.
FocusArea1(0xd372): error 200a on query.
FaceDetectionMode(0xd020): error 200a on query.
RawCompression(0xd022): error 200a on query.
GrainEffect(0xd023): error 200a on query.
SetEyeAFMode(0xd024): error 200a on query.
FocusPoints(0xd025): error 200a on query.
MFAssistMode(0xd026): error 200a on query.
InterlockAEAFArea(0xd027): error 200a on query.
Shadowing(0xd029): error 200a on query.
CropMode(0xd16f): error 200a on query.
TNumber(0xd02f): error 200a on query.
FocusArea4(0xd395): error 200a on query.
HighLightTone(0xd320): error 200a on query.
ShadowTone(0xd321): error 200a on query.
LongExposureNR(0xd322): error 200a on query.
FullTimeManualFocus(0xd323): error 200a on query.
LensISSwitch(0xd346): error 200a on query.
InstantAFMode(0xd34a): error 200a on query.
PreAFMode(0xd34b): error 200a on query.
LMOMode(0xd34d): error 200a on query.
ISMode(0xd351): error 200a on query.
FocusCheckMode(0xd35e): error 200a on query.
LiveViewImageQuality(0xd173): error 200a on query.
FileNamePrefix1(0xd365): error 200a on query.
FileNamePrefix2(0xd366): error 200a on query.
FocusArea3(0xd374): error 200a on query.
TotalShotCount(0xd310): error 200a on query.
ExposurePreview(0xd359): error 200a on query.
FrameGuideGridInfo1(0xd375): error 200a on query.
FrameGuideGridInfo2(0xd376): error 200a on query.
CustomDispInfo(0xd36e): error 200a on query.
ViewMode1(0xd33f): error 200a on query.
CustomAutoPowerOff(0xd364): error 200a on query.
LockButtonMode(0xd34e): error 200a on query.
WideDynamicRange(0xd02e): error 200a on query.
LensNameAndSerial(0xd36d): error 200a on query.
LensUnknownData(0xd38a): error 200a on query.
BatteryInfo1(0xd36a): error 200a on query.
BatteryInfo2(0xd36b): error 200a on query.
FunctionLockCategory1(0xd36f): error 200a on query.
FunctionLockCategory2(0xd370): error 200a on query.
SensitivityFineTune1(0xd222): error 200a on query.
SensitivityFineTune2(0xd223): error 200a on query.
LensZoomPosCaps(0xd38c): error 200a on query.
LensFNumberList(0xd38d): error 200a on query.
LensFocalLengthList(0xd38e): error 200a on query.
Property 0xd17b: error 200a on query.
In "USB Raw Conv. / Backup Restore" mode (which requires Fuji-specific software on the PC side, as far as I can tell) I get different output:
Camera summary:
Manufacturer: FUJIFILM
Model: X100V
Version: 3.01
Serial Number: 593535383034210209CB0030218FC7
Vendor Extension ID: 0xe (1.0)
Vendor Extension Description: fujifilm.co.jp: 1.0;
Capture Formats: JPEG Defined Type Unknown(b103) TIFF
Display Formats: JPEG, Unknown(5000), Unknown(f802), Defined Type, Unknown(b103), TIFF
Device Capabilities:
File Download, File Deletion, No File Upload
Generic Image Capture, Open Capture, No vendor specific capture
Storage Devices Summary:
store_10000001:
StorageDescription: Still
VolumeLabel: 1593535383034210209CB0030218FC7
Storage Type: Builtin RAM
Filesystemtype: Generic Hierarchical
Access Capability: Read Only with Object deletion
Maximum Capability: 18446744073709551615 (17592186044415 MB)
Free Space (Bytes): 18446744073709551615 (17592186044415 MB)
Free Space (Images): -1
store_10000002:
StorageDescription: Live
VolumeLabel: 2593535383034210209CB0030218FC7
Storage Type: Builtin RAM
Filesystemtype: Generic Hierarchical
Access Capability: Read Only with Object deletion
Maximum Capability: 18446744073709551615 (17592186044415 MB)
Free Space (Bytes): 18446744073709551615 (17592186044415 MB)
Free Space (Images): -1
Device Property Summary:
Property 0xd183:(readwrite) (type=0x4) Enumeration [0,1] value: 65535
IOPCode(0xd184): error 200a on query.
Property 0xd185: error 200a on query.
TetherRawConditionCode(0xd186): error 200a on query.
TetherRawCompatibilityCode(0xd187): error 200a on query.
Property 0xd1a5: error 200a on query.
Property 0xd18c: error 200a on query.
Property 0xd18d: error 200a on query.
Property 0xd18e: error 200a on query.
Property 0xd18f: error 200a on query.
Property 0xd190: error 200a on query.
Property 0xd191: error 200a on query.
Property 0xd192: error 200a on query.
Property 0xd193: error 200a on query.
Property 0xd194: error 200a on query.
Property 0xd195: error 200a on query.
Property 0xd196: error 200a on query.
Property 0xd197: error 200a on query.
Property 0xd199: error 200a on query.
Property 0xd19a: error 200a on query.
Property 0xd19b: error 200a on query.
Property 0xd19c: error 200a on query.
Property 0xd19d: error 200a on query.
Property 0xd19e: error 200a on query.
Property 0xd19f: error 200a on query.
Property 0xd1a0: error 200a on query.
Property 0xd1a1: error 200a on query.
Property 0xd1a2: error 200a on query.
Property 0xd1a3: error 200a on query.
Property 0xd1a4: error 200a on query.
Property 0xd16e: error 200a on query.
BatteryInfo1(0xd36a):(read only) (type=0x6) Range [0 - 16777215, step 1] value: 12
BatteryInfo2(0xd36b):(read only) (type=0xffff) '92,0,0'
DeviceName(0xd20b):(readwrite) (type=0xffff) ''
Property 0xd21c:(readwrite) (type=0x4) Enumeration [0,1,2,3,4,5,6,7,8,9,10,11] value: 3
Property 0xd17b:(readwrite) (type=0x4) Enumeration [1] value: 1
Property 0xd208:(readwrite) (type=0x4) Enumeration [260,512,4,772,1280,12,32768,40960,6,36864,2,37120,1,37632,5,14,37376] value: 772
CurrentState(0xd212): error 201b on query.
Quality(0xd018):(readwrite) (type=0x4) Enumeration [1,2,3,4,5,6,7] value: 4
DRangeMode(0xd007):(readwrite) (type=0x4) Enumeration [65535,100,200,400,800] value: 400
WideDynamicRange(0xd02e):(readwrite) (type=0x4) Enumeration [0,1,2,3,32768] value: 0
Film Simulation(0xd001):(readwrite) (type=0x4) Enumeration [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17] value: 1
BlackImageTone(0xd104):(readwrite) (type=0x3) Range [-180 - 180, step 10] value: 0
Property 0xd031:(readwrite) (type=0x3) Range [-180 - 180, step 10] value: 0
GrainEffect(0xd023):(readwrite) (type=0x4) Enumeration [1,2,3,4,5,6,7] value: 6
Shadowing(0xd029):(readwrite) (type=0x4) Enumeration [1,2,3] value: 1
Property 0xd030:(readwrite) (type=0x4) Enumeration [1,2,3] value: 1
White Balance(0x5005):(readwrite) (type=0x4) Enumeration [2,4,6,8,32769,32770,32771,32774,32775,32776,32777,32778] value: Automatic (2)
WhitebalanceTune1(0xd00b):(readwrite) (type=0x3) Range [-9 - 9, step 1] value: 0
WhitebalanceTune2(0xd00c):(readwrite) (type=0x3) Range [-9 - 9, step 1] value: 0
Color Temperature(0xd017):(readwrite) (type=0x4) Enumeration [2500,2510,2520,2530,2540,2550,2560,2570,2580,2590,2600,2610,2620,2630,2640,2650,2660,2670,2680,2690,2700,2710,2720,2730,2740,2750,2760,2770,2780,2790,2800,2810,2820,2830,2840,2850,2860,2870,2880,2890,2900,2910,2920,2930,2940,2950,2960,2970,2980,2990,3000,3010,3020,3030,3040,3050,3060,3070,3080,3090,3100,3110,3120,3130,3140,3150,3160,3170,3180,3190,3200,3210,3220,3230,3240,3250,3260,3270,3280,3290,3300,3310,3320,3330,3340,3350,3360,3370,3380,3390,3400,3410,3420,3430,3440,3450,3460,3470,3480,3490,3500,3510,3520,3530,3540,3550,3560,3570,3580,3590,3600,3610,3620,3630,3640,3650,3660,3670,3680,3690,3700,3710,3720,3730,3740,3750,3760,3770,3780,3790,3800,3810,3820,3830,3840,3850,3860,3870,3880,3890,3900,3910,3920,3930,3940,3950,3960,3970,3980,3990,4000,4010,4020,4030,4040,4050,4060,4070,4080,4090,4100,4110,4120,4130,4140,4150,4160,4170,4180,4190,4200,4210,4220,4230,4240,4250,4260,4270,4280,4290,4300,4310,4320,4330,4340,4350,4360,4370,4380,4390,4400,4410,4420,4430,4440,4450,4460,4470,4480,4490,4500,4510,4520,4530,4540,4550,4560,4570,4580,4590,4600,4610,4620,4630,4640,4650,4660,4670,4680,4690,4700,4710,4720,4730,4740,4750,4760,4770,4780,4790,4800,4810,4820,4830,4840,4850,4860,4870,4880,4890,4900,4910,4920,4930,4940,4950,4960,4970,4980,4990,5000,5010,5020,5030,5040,5050,5060,5070,5080,5090,5100,5110,5120,5130,5140,5150,5160,5170,5180,5190,5200,5210,5220,5230,5240,5250,5260,5270,5280,5290,5300,5310,5320,5330,5340,5350,5360,5370,5380,5390,5400,5410,5420,5430,5440,5450,5460,5470,5480,5490,5500,5510,5520,5530,5540,5550,5560,5570,5580,5590,5600,5610,5620,5630,5640,5650,5660,5670,5680,5690,5700,5710,5720,5730,5740,5750,5760,5770,5780,5790,5800,5810,5820,5830,5840,5850,5860,5870,5880,5890,5900,5910,5920,5930,5940,5950,5960,5970,5980,5990,6000,6010,6020,6030,6040,6050,6060,6070,6080,6090,6100,6110,6120,6130,6140,6150,6160,6170,6180,6190,6200,6210,6220,6230,6240,6250,6260,6270,6280,6290,6300,6310,6320,6330,6340,6350,6360,6370,6380,6390,6400,6410,6420,6430,6440,6450,6460,6470,6480,6490,6500,6510,6520,6530,6540,6550,6560,6570,6580,6590,6600,6610,6620,6630,6640,6650,6660,6670,6680,6690,6700,6710,6720,6730,6740,6750,6760,6770,6780,6790,6800,6810,6820,6830,6840,6850,6860,6870,6880,6890,6900,6910,6920,6930,6940,6950,6960,6970,6980,6990,7000,7010,7020,7030,7040,7050,7060,7070,7080,7090,7100,7110,7120,7130,7140,7150,7160,7170,7180,7190,7200,7210,7220,7230,7240,7250,7260,7270,7280,7290,7300,7310,7320,7330,7340,7350,7360,7370,7380,7390,7400,7410,7420,7430,7440,7450,7460,7470,7480,7490,7500,7510,7520,7530,7540,7550,7560,7570,7580,7590,7600,7610,7620,7630,7640,7650,7660,7670,7680,7690,7700,7710,7720,7730,7740,7750,7760,7770,7780,7790,7800,7810,7820,7830,7840,7850,7860,7870,7880,7890,7900,7910,7920,7930,7940,7950,7960,7970,7980,7990,8000,8010,8020,8030,8040,8050,8060,8070,8080,8090,8100,8110,8120,8130,8140,8150,8160,8170,8180,8190,8200,8210,8220,8230,8240,8250,8260,8270,8280,8290,8300,8310,8320,8330,8340,8350,8360,8370,8380,8390,8400,8410,8420,8430,8440,8450,8460,8470,8480,8490,8500,8510,8520,8530,8540,8550,8560,8570,8580,8590,8600,8610,8620,8630,8640,8650,8660,8670,8680,8690,8700,8710,8720,8730,8740,8750,8760,8770,8780,8790,8800,8810,8820,8830,8840,8850,8860,8870,8880,8890,8900,8910,8920,8930,8940,8950,8960,8970,8980,8990,9000,9010,9020,9030,9040,9050,9060,9070,9080,9090,9100,9110,9120,9130,9140,9150,9160,9170,9180,9190,9200,9210,9220,9230,9240,9250,9260,9270,9280,9290,9300,9310,9320,9330,9340,9350,9360,9370,9380,9390,9400,9410,9420,9430,9440,9450,9460,9470,9480,9490,9500,9510,9520,9530,9540,9550,9560,9570,9580,9590,9600,9610,9620,9630,9640,9650,9660,9670,9680,9690,9700,9710,9720,9730,9740,9750,9760,9770,9780,9790,9800,9810,9820,9830,9840,9850,9860,9870,9880,9890,9900,9910,9920,9930,9940,9950,9960,9970,9980,9990,10000] value: 10000
HighLightTone(0xd320):(readwrite) (type=0x3) Range [-20 - 40, step 10] value: 0
ShadowTone(0xd321):(readwrite) (type=0x3) Range [-20 - 40, step 10] value: 0
ColorMode(0xd008):(readwrite) (type=0x3) Range [-40 - 40, step 10] value: 0
Sharpness(0x5015):(readwrite) (type=0x3) Range [-40 - 40, step 10] value: 0
NoiseReduction(0xd01c):(readwrite) (type=0x4) Enumeration [0,4096,8192,12288,16384,20480,24576,28672,32768] value: 8192
Property 0xd032:(readwrite) (type=0x3) Range [-50 - 50, step 10] value: 0
LMOMode(0xd34d):(readwrite) (type=0x4) Enumeration [1,2] value: 1
ColorSpace(0xd00a):(readwrite) (type=0x4) Enumeration [1,2] value: 1
Exposure Time(0x500d): error 200a on query.
F-Number(0x5007): error 200a on query.
LensZoomPosCaps(0xd38c): error 200a on query.
FocusPosition(0xd171): error 200a on query.
Property 0xd21c:(readwrite) (type=0x4) Enumeration [0,1,2,3,4,5,6,7,8,9,10,11] value: 3
Focus Point(0xd347): error 200a on query.
LensZoomPos(0xd170): error 200a on query.
BatteryLevel(0xd242): error 200a on query.
LiveViewImageSize(0xd174): error 200a on query.
VideoOutOnOff(0xd168): error 200a on query.
LiveViewImageQuality(0xd173): error 200a on query.
ForceMode(0xd230): error 200a on query.
Property 0xd16e: error 200a on query.
FocusArea1(0xd372): error 200a on query.
FaceDetectionMode(0xd020): error 200a on query.
RawCompression(0xd022): error 200a on query.
GrainEffect(0xd023):(readwrite) (type=0x4) Enumeration [1,2,3,4,5,6,7] value: 6
SetEyeAFMode(0xd024): error 200a on query.
FocusPoints(0xd025): error 200a on query.
MFAssistMode(0xd026): error 200a on query.
InterlockAEAFArea(0xd027): error 200a on query.
Shadowing(0xd029):(readwrite) (type=0x4) Enumeration [1,2,3] value: 1
CropMode(0xd16f): error 200a on query.
TNumber(0xd02f): error 200a on query.
FocusArea4(0xd395): error 200a on query.
HighLightTone(0xd320):(readwrite) (type=0x3) Range [-20 - 40, step 10] value: 0
ShadowTone(0xd321):(readwrite) (type=0x3) Range [-20 - 40, step 10] value: 0
LongExposureNR(0xd322): error 200a on query.
FullTimeManualFocus(0xd323): error 200a on query.
LensISSwitch(0xd346): error 200a on query.
InstantAFMode(0xd34a): error 200a on query.
PreAFMode(0xd34b): error 200a on query.
LMOMode(0xd34d):(readwrite) (type=0x4) Enumeration [1,2] value: 1
ISMode(0xd351): error 200a on query.
FocusCheckMode(0xd35e): error 200a on query.
LiveViewImageQuality(0xd173): error 200a on query.
FileNamePrefix1(0xd365): error 200a on query.
FileNamePrefix2(0xd366): error 200a on query.
FocusArea3(0xd374): error 200a on query.
TotalShotCount(0xd310): error 200a on query.
ExposurePreview(0xd359): error 200a on query.
FrameGuideGridInfo1(0xd375): error 200a on query.
FrameGuideGridInfo2(0xd376): error 200a on query.
CustomDispInfo(0xd36e): error 200a on query.
ViewMode1(0xd33f): error 200a on query.
CustomAutoPowerOff(0xd364): error 200a on query.
LockButtonMode(0xd34e): error 200a on query.
WideDynamicRange(0xd02e):(readwrite) (type=0x4) Enumeration [0,1,2,3,32768] value: 0
LensNameAndSerial(0xd36d): error 200a on query.
LensUnknownData(0xd38a): error 200a on query.
BatteryInfo1(0xd36a):(read only) (type=0x6) Range [0 - 16777215, step 1] value: 12
BatteryInfo2(0xd36b):(read only) (type=0xffff) '92,0,0'
FunctionLockCategory1(0xd36f): error 200a on query.
FunctionLockCategory2(0xd370): error 200a on query.
SensitivityFineTune1(0xd222): error 200a on query.
SensitivityFineTune2(0xd223): error 200a on query.
LensZoomPosCaps(0xd38c): error 200a on query.
LensFNumberList(0xd38d): error 200a on query.
LensFocalLengthList(0xd38e): error 200a on query.
Property 0xd17b:(readwrite) (type=0x4) Enumeration [1] value: 1
Does this happen with ligphoto2 2.5.31 ?
Does this happen with ligphoto2 2.5.31 ?
Yes it does.
attaching output from gphoto2 --summary --debug
gphoto2-summary-output.txt
I think your commit 5f9f6c8, plus the same change in camera_unprepare_capture
(see below) works fixes the error.
index 80d528e24..1fdea073c 100644
--- a/camlibs/ptp2/config.c
+++ b/camlibs/ptp2/config.c
@@ -628,8 +628,10 @@ camera_unprepare_capture (Camera *camera, GPContext *context)
params->inliveview = 0;
}
- propval.u16 = 0x0001;
- C_PTP (ptp_setdevicepropvalue (params, PTP_DPC_FUJI_PriorityMode, &propval, PTP_DTC_UINT16));
+ if (have_prop(camera, params->deviceinfo.VendorExtensionID, PTP_DPC_FUJI_PriorityMode)) {
+ propval.u16 = 0x0001;
+ C_PTP (ptp_setdevicepropvalue (params, PTP_DPC_FUJI_PriorityMode, &propval, PTP_DTC_UINT16));
+ }
return GP_OK;
}
break;
I've been able to use this patched version with gphoto2 -P
to download from the camera and with RapidPhotoDownloader to get images off the camera without problems.
The camera doesn't, as far as I can tell, support tethering so I haven't used any of the capture commands.