jim-easterbrook / python-gphoto2

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

Error 105 Unknown model for Nikon D40 #18

Closed Steboss closed 7 years ago

Steboss commented 8 years ago

Hi!

I have install gphoto2 and now I was trying to deal with the python interface I am trying to detect the camera but by using a simple code like this:

gp.check_result(gp.use_python_logging()) context = gp.gp_context_new() camera = gp.check_result(gp.gp_camera_new()) gp.check_result(gp.gp_camera_init(camera, context))

I got an error message "Unknwon model[105]" when my camera is a Nikon D40, which is in the list

If I use the terminal interface with:

gphoto2 --auto-detect

the camera is correctly detected

Where is my mistake?

Thank you

Stefano

jim-easterbrook commented 8 years ago

As far as I can tell this should work. Is the camera visible with the lsusb command immediately before and after Python fails to detect it?

Steboss commented 8 years ago

lsubs gives me this output both before and after Python failure: Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 001 Device 003: ID 8087:07dc Intel Corp. Bus 001 Device 002: ID 04f2:b446 Chicony Electronics Co., Ltd Bus 001 Device 006: ID 04b0:0414 Nikon Corp. Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Could me a permission error? I mean gphoto2 is trying to read the camera mounted (where?) and it cannot access

jim-easterbrook commented 8 years ago

libgphoto2 (and hence the gphoto2 program and the Python interface) accesses a camera via libusb so it shouldn't be mounted. You could test permissions by using sudo to run your Python script. Are you able to write a short C program to detect the camera using libgphoto2? If this fails then I think it might be worth asking on the gphoto2 mailing list.

Steboss commented 8 years ago

Good idea for the sudo python, but nothing changes

I wrote a c code like this one:

#include <stdio.h>
#include <fcntl.h>

#include <gphoto2/gphoto2-camera.h>

int main(int argc, char **argv) {
    Camera      *camera;
    int     ret;
    char        *owner;
    GPContext   *context;
    CameraText  text;

  context = gp_context_new();
    gp_camera_new (&camera);

    ret = gp_camera_init (camera, context);
    if (ret < GP_OK) {
        printf("No camera auto detected.\n");
        gp_camera_free (camera);
        return 0;
    }
}

and the output is "No camera detected" :s but I am not totally sure I have used the correct headers from gphoto2

jim-easterbrook commented 8 years ago

That looks the right sort of thing. I think the only include required is gphoto2/gphoto2.h. You could print out the value of ret to check it's -105.

Steboss commented 8 years ago

Argh, I have a "Segmentation fault (core dumped)" error

jim-easterbrook commented 8 years ago

Sorry, I've not tried using libgphoto2 from C. (And I'm not much of a C programmer.) I don't know what else to suggest now.

Steboss commented 8 years ago

No problems :) I will find it out I think I messed up gphoto2 with two different installation I'll check and uninstall and install finger cross :) Thanks for your help!

jim-easterbrook commented 8 years ago

The ldd command should show which version of libgphoto2 the Python modules are using and which version the gphoto2 command is using, if it's dynamically linked.

Steboss commented 8 years ago

So I have re-installed everything and now I got this error after

gp.check_result(gp.gp_camera_init(camera, context))
(foreach_func [gphoto2-port-info-list.c:237]) Error during assembling of port list: 'Unspecified error' (-1).
(gp_port_serial_close [unix.c:461]) Invalid parameters: 'path' is NULL/FALSE.
(gp_context_error) Could not detect any camera
jim-easterbrook commented 8 years ago

The first two error messages are typical of libgphoto2's excessive (in my view) verbosity. I'm not sure if they are really errors as I get them although everything appears to be working OK. The last is what it says - your camera is not being detected. (I'm on holiday at present, so I'm not able to give the same level of support as usual.)