gphoto / libgphoto2

The libgphoto2 camera access and control library.
GNU Lesser General Public License v2.1
1.02k stars 322 forks source link

Support for Pentax K-50 #31

Open travnick opened 8 years ago

travnick commented 8 years ago

I'm not able shot photo with Pentax K-50:

from gphoto --shell --debug:

gphoto2: {.../gphototest/piggyphoto} /> capture-image
393.856012 gp_camera_init              (2): Initializing camera...
393.856045 gp_port_set_error [gphoto2-port.c:1186](0): The supplied vendor or product id (0x0,0x0) is not valid.
393.856086 gp_libusb1_find_device_by_class_lib(2): Looking for USB device (class 0x6, subclass, 0x1, protocol 0x1)...
393.856099 gp_libusb1_find_device_by_class_lib(2): Found USB class device (class 0x6, subclass, 0x1, protocol 0x1)
393.856109 gp_libusb1_find_device_by_class_lib(2): inep to look for is 81
393.856116 gp_libusb1_find_device_by_class_lib(2): Detected defaults: config 1, interface 0, altsetting 0, idVendor ID 25fb, idProduct 0161, inep 81, outep 02, intep 83
393.856121 gp_camera_init              (2): Loading '/usr/lib/libgphoto2/2.5.8/ptp2'...
393.856443 gp_port_open                (2): Opening USB port...
393.856451 gp_libusb1_open             (2): ()
393.856515 gp_libusb1_open             (2): claiming interface 0
393.860132 camera_init                 (2): maxpacketsize 512
393.860175 gp_port_set_timeout         (2): Setting port timeout to 8000 milliseconds.
393.860248 ptp                         (2): PTP: Opening session
393.860269 ptp_usb_sendreq             (2): Sending PTP_OC 0x1002 / Open session request...
393.860303 gp_port_write               (3): Writing 16 = 0x10 bytes to port...
393.860505 gp_port_write               (3): Wrote   16 = 0x10 bytes to port: (hexdump of 16 bytes)
0000  10 00 00 00 01 00 02 10-00 00 00 00 01 00 00 00  ................

393.860519 ptp_usb_getresp             (2): Reading PTP_OC 0x1002 response...
393.860529 gp_port_read                (3): Reading 1024 = 0x400 bytes from port...
393.860720 gp_port_read                (3): Read    12 = 0xc out of 1024 bytes from port: (hexdump of 12 bytes)
0000  0c 00 00 00 03 00 01 20-00 00 00 00              ....... ....    

393.860734 gp_port_set_timeout         (2): Setting port timeout to 20000 milliseconds.
393.860749 ptp_usb_sendreq             (2): Sending PTP_OC 0x1001 / get device info request...
393.860759 gp_port_write               (3): Writing 12 = 0xc bytes to port...
393.860839 gp_port_write               (3): Wrote   12 = 0xc bytes to port: (hexdump of 12 bytes)
0000  0c 00 00 00 01 00 01 10-01 00 00 00              ............    

393.860877 ptp_usb_getdata             (2): Reading PTP_OC 0x1001 / get device info data...
393.860888 gp_port_read                (3): Reading 1024 = 0x400 bytes from port...
393.861118 gp_port_read                (3): Read    245 = 0xf5 out of 1024 bytes from port: (hexdump of 245 bytes)
0000  f5 00 00 00 02 00 01 10-01 00 00 00 64 00 06 00  ............d...
0010  00 00 64 00 24 6d 00 69-00 63 00 72 00 6f 00 73  ..d.$m.i.c.r.o.s
0020  00 6f 00 66 00 74 00 2e-00 63 00 6f 00 6d 00 2f  .o.f.t...c.o.m./
0030  00 44 00 65 00 76 00 69-00 63 00 65 00 53 00 65  .D.e.v.i.c.e.S.e
0040  00 72 00 76 00 69 00 63-00 65 00 73 00 3a 00 20  .r.v.i.c.e.s.:. 
0050  00 31 00 2e 00 30 00 3b-00 20 00 00 00 00 00 16  .1...0.;. ......
0060  00 00 00 01 10 02 10 03-10 04 10 05 10 06 10 07  ................
0070  10 08 10 09 10 0a 10 0b-10 0c 10 0d 10 0f 10 14  ................
0080  10 15 10 16 10 1b 10 01-98 02 98 03 98 05 98 04  ................
0090  00 00 00 03 40 04 40 05-40 02 40 05 00 00 00 01  ....@.@.@.@.....
00a0  50 11 50 06 d4 07 d4 03-d3 00 00 00 00 07 00 00  P.P.............
00b0  00 01 30 06 30 0a 30 0d-30 01 38 00 38 00 30 07  ..0.0.0.0.8.8.0.
00c0  50 00 45 00 4e 00 54 00-41 00 58 00 00 00 05 4b  P.E.N.T.A.X....K
00d0  00 2d 00 35 00 30 00 00-00 05 31 00 2e 00 30 00  .-.5.0....1...0.
00e0  31 00 00 00 08 36 00 31-00 36 00 39 00 38 00 37  1....6.1.6.9.8.7
00f0  00 33 00 00 00         -                         .3...           

393.861151 ptp_usb_getresp             (2): Reading PTP_OC 0x1001 response...
393.861161 gp_port_read                (3): Reading 1024 = 0x400 bytes from port...
393.861343 gp_port_read                (3): Read    12 = 0xc out of 1024 bytes from port: (hexdump of 12 bytes)
0000  0c 00 00 00 03 00 01 20-01 00 00 00              ....... ....    

393.861372 print_debug_deviceinfo      (2): Device info:
393.861381 print_debug_deviceinfo      (2): Manufacturer: PENTAX
393.861389 print_debug_deviceinfo      (2):   Model: K-50
393.861397 print_debug_deviceinfo      (2):   device version: 1.01
393.861405 print_debug_deviceinfo      (2):   serial number: '6169873'
393.861413 print_debug_deviceinfo      (2): Vendor extension ID: 0x00000006
393.861421 print_debug_deviceinfo      (2): Vendor extension version: 100
393.861429 print_debug_deviceinfo      (2): Vendor extension description: microsoft.com/DeviceServices: 1.0; 
393.861437 print_debug_deviceinfo      (2): Functional Mode: 0x0000
393.861445 print_debug_deviceinfo      (2): PTP Standard Version: 100
393.861452 print_debug_deviceinfo      (2): Supported operations:
393.861463 print_debug_deviceinfo      (2):   0x1001 (get device info)
393.861472 print_debug_deviceinfo      (2):   0x1002 (Open session)
393.861481 print_debug_deviceinfo      (2):   0x1003 (Close session)
393.861490 print_debug_deviceinfo      (2):   0x1004 (Get storage IDs)
393.861499 print_debug_deviceinfo      (2):   0x1005 (Get storage info)
393.861508 print_debug_deviceinfo      (2):   0x1006 (Get number of objects)
393.861518 print_debug_deviceinfo      (2):   0x1007 (Get object handles)
393.861526 print_debug_deviceinfo      (2):   0x1008 (Get object info)
393.861535 print_debug_deviceinfo      (2):   0x1009 (Get object)
393.861544 print_debug_deviceinfo      (2):   0x100a (Get thumbnail)
393.861553 print_debug_deviceinfo      (2):   0x100b (Delete object)
393.861562 print_debug_deviceinfo      (2):   0x100c (Send object info)
393.861571 print_debug_deviceinfo      (2):   0x100d (Send object)
393.861580 print_debug_deviceinfo      (2):   0x100f (Format storage)
393.861590 print_debug_deviceinfo      (2):   0x1014 (Get device property description)
393.861599 print_debug_deviceinfo      (2):   0x1015 (Get device property value)
393.861609 print_debug_deviceinfo      (2):   0x1016 (Set device property value)
393.861618 print_debug_deviceinfo      (2):   0x101b (Get partial object)
393.861627 print_debug_deviceinfo      (2):   0x9801 (Get object properties supported)
393.861637 print_debug_deviceinfo      (2):   0x9802 (Get object property description)
393.861646 print_debug_deviceinfo      (2):   0x9803 (Get object property value)
393.861655 print_debug_deviceinfo      (2):   0x9805 (Get object property list)
393.861662 print_debug_deviceinfo      (2): Events Supported:
393.861671 print_debug_deviceinfo      (2):   0x4003
393.861678 print_debug_deviceinfo      (2):   0x4004
393.861686 print_debug_deviceinfo      (2):   0x4005
393.861693 print_debug_deviceinfo      (2):   0x4002
393.861700 print_debug_deviceinfo      (2): Device Properties Supported:
393.861708 print_debug_deviceinfo      (2):   0x5001
393.861715 print_debug_deviceinfo      (2):   0x5011
393.861722 print_debug_deviceinfo      (2):   0xd406
393.861729 print_debug_deviceinfo      (2):   0xd407
393.861737 print_debug_deviceinfo      (2):   0xd303
393.861745 ptp_list_folder             (2): (storage=0xffffffff, handle=0xffffffff)
393.861753 ptp_list_folder             (2): Listing ... 
393.861763 ptp_usb_sendreq             (2): Sending PTP_OC 0x1007 / Get object handles request...
393.861773 gp_port_write               (3): Writing 24 = 0x18 bytes to port...
393.861839 gp_port_write               (3): Wrote   24 = 0x18 bytes to port: (hexdump of 24 bytes)
0000  18 00 00 00 01 00 07 10-02 00 00 00 ff ff ff ff  ................
0010  00 00 00 00 ff ff ff ff-                         ........        

393.861854 ptp_usb_getdata             (2): Reading PTP_OC 0x1007 / Get object handles data...
393.861863 gp_port_read                (3): Reading 1024 = 0x400 bytes from port...
393.862477 gp_port_read                (3): Read    20 = 0x14 out of 1024 bytes from port: (hexdump of 20 bytes)
0000  14 00 00 00 02 00 07 10-02 00 00 00 01 00 00 00  ................
0010  00 40 00 04            -                         .@..            

393.862496 ptp_usb_getresp             (2): Reading PTP_OC 0x1007 response...
393.862505 gp_port_read                (3): Reading 1024 = 0x400 bytes from port...
393.862589 gp_port_read                (3): Read    12 = 0xc out of 1024 bytes from port: (hexdump of 12 bytes)
0000  0c 00 00 00 03 00 01 20-02 00 00 00              ....... ....    

393.862604 ptp_list_folder             (2): adding new objectid 0x04004000 (nrofobs=0,j=0)
393.862623 ptp_usb_sendreq             (2): Sending PTP_OC 0x1004 / Get storage IDs request...
393.862632 gp_port_write               (3): Writing 12 = 0xc bytes to port...
393.862714 gp_port_write               (3): Wrote   12 = 0xc bytes to port: (hexdump of 12 bytes)
0000  0c 00 00 00 01 00 04 10-03 00 00 00              ............    

393.862727 ptp_usb_getdata             (2): Reading PTP_OC 0x1004 / Get storage IDs data...
393.862736 gp_port_read                (3): Reading 1024 = 0x400 bytes from port...
393.862839 gp_port_read                (3): Read    20 = 0x14 out of 1024 bytes from port: (hexdump of 20 bytes)
0000  14 00 00 00 02 00 04 10-03 00 00 00 01 00 00 00  ................
0010  01 00 01 00            -                         ....            

393.862855 ptp_usb_getresp             (2): Reading PTP_OC 0x1004 response...
393.862864 gp_port_read                (3): Reading 1024 = 0x400 bytes from port...
393.862966 gp_port_read                (3): Read    12 = 0xc out of 1024 bytes from port: (hexdump of 12 bytes)
0000  0c 00 00 00 03 00 01 20-03 00 00 00              ....... ....    

393.862979 ptp_list_folder             (2): (storage=0x00010001, handle=0xffffffff)
393.862987 ptp_list_folder             (2): Listing ... 
393.862998 ptp_usb_sendreq             (2): Sending PTP_OC 0x1007 / Get object handles request...
393.863007 gp_port_write               (3): Writing 24 = 0x18 bytes to port...
393.863088 gp_port_write               (3): Wrote   24 = 0x18 bytes to port: (hexdump of 24 bytes)
0000  18 00 00 00 01 00 07 10-04 00 00 00 01 00 01 00  ................
0010  00 00 00 00 ff ff ff ff-                         ........        

393.863102 ptp_usb_getdata             (2): Reading PTP_OC 0x1007 / Get object handles data...
393.863111 gp_port_read                (3): Reading 1024 = 0x400 bytes from port...
393.863613 gp_port_read                (3): Read    20 = 0x14 out of 1024 bytes from port: (hexdump of 20 bytes)
0000  14 00 00 00 02 00 07 10-04 00 00 00 01 00 00 00  ................
0010  00 40 00 04            -                         .@..            

393.863630 ptp_usb_getresp             (2): Reading PTP_OC 0x1007 response...
393.863636 gp_port_read                (3): Reading 1024 = 0x400 bytes from port...
393.863714 gp_port_read                (3): Read    12 = 0xc out of 1024 bytes from port: (hexdump of 12 bytes)
0000  0c 00 00 00 03 00 01 20-04 00 00 00              ....... ....    

393.863724 ptp_list_folder             (2): adding old objectid 0x04004000 (nrofobs=1,j=0)
393.863738 gp_context_error            (0): Sorry, your camera does not support generic capture

*** Error ***              
Sorry, your camera does not support generic capture
393.863759 gp_camera_capture [gphoto2-camera.c:1032](0): 'camera->functions->capture (camera, type, path, context)' failed: -6
ERROR: Could not capture image.
ERROR: Could not capture.
*** Error (-6: 'Unsupported operation') ***

I'm familiar with C++ programming so maybe I'm able to help you with bringing support of this camera to libgphoto2

msmeissn commented 8 years ago

The pentax can not capture in PTP mode, but in the other (mass storage mode).

However ... We have some support for other Pentax cameras, but so far not the K50 :(

Blueshawk commented 7 years ago

I'm following up on this as I'd also like to see the K-50 supported by Gphoto. In my case for use with Indilib/Ekos for astronomy. I'd like to suggest comparing and integrating code from the more active and up to date PKtriggercord. While also based on Pkremote, PKtriggercord has been actively updating and is currently functional on the k50 for capture,iso and exposure. Perusing the newer routines might reduce the work needed to bring that library up to speed with the newer cameras.
I'd also put myself and "Pentax the Red!"(magic tavern reference) up as testers for this purpose. I would take a naive stab at hacking the two together myself [--and have now gotten the thing to compile.]

Blueshawk commented 7 years ago

I notice that the issue has been picked up, and know just how busy you folks are from the email digest (lurking). I've been busy working on other problems myself but have every intention of being available when the time comes. When you get time to look it over just let me know if there's anything I can do to help.

msmeissn commented 7 years ago

(currently not working on this due to lack of time and lack of testhardware to verify ... mostly due to lack of time :( )

Blueshawk commented 7 years ago

I understand Marcus, it's no problem. I'll be around if you get into it. I worked out a way to cut power to the Pentax instantly if it decides to go unstable as has happened a few times in the past. Is there any easy way to enable the k-50 for testing? If I could get it recognized I might be able to debug a bit on my own. I poked around in the source a bit and tried replacing the k30 references with k50 as I had read they were similar but failed to get it to register.

I've been watching the action by way of the email list and there are lots of things going on already, so I figured I'd have to be patient. This project would help a ton of Pentaxians get tethered too.

msmeissn commented 7 years ago

Would you be able to build and test libgphoto2 git?

i tried a port integrating pktriggercord and it was not so bad as I feared. But it will probably need some test turnarounds.

Blueshawk commented 7 years ago

I'll get right on it!

Blueshawk commented 7 years ago

Just to be sure, I made a fresh directory clone of current git and compiled from that but I don't see any new work at git master. Has master been updated, or am I showing my newbness in pulling from the wrong place? (so excited! and off work today too) edit: [found updates in libary.c from today]

Blueshawk commented 7 years ago

Here's the debug file I missed in previous post. Starting without a settings file in msc mode: Error
Could not detect any camera Error (-105: 'Unknown model')
k50test1.txt

msmeissn commented 7 years ago

i was not yet readsy there. ;)

can you checkout the pentax branch and check that out?

ig you have a checkout, just do "git checkout pentax" and then make

What USB ID does it have in MSC mode, this probably the first thing to add

Blueshawk commented 7 years ago

I had no notebook today as I forgot it this morning. Home now, and will check it out.

(DST sucks)

Blueshawk commented 7 years ago

Git still throws me for a loop sometimes but I got it eventually. - Just for anyone following along, I did $ git checkout -b pentax to get on the branch then $ git pull https://github.com/gphoto/libgphoto2 pentax ...to update it. seemed to do the trick, lots of new code. :)

Still no joy on the camera ID in msc. Here's the usb info on the camera trimmed from lsusb -v. Bus 001 Device 099: ID 25fb:0160 idVendor 0x25fb idProduct 0x0160 The rest is here if needed: k50info.txt

And another debug just in case: k50debug.txt

msmeissn commented 7 years ago

can you git pull again, remake, reinstall.

grep K50D camlibs/pentax/library.c should now show it.

see if that helped?

Blueshawk commented 7 years ago

Got it, built on my notebook at work and tested during a break. It found the camera, and even worked the shutter with --captture-image-and-download but only after declaring an error. lots of err. info is going to screen but for some reason isn't picked up by bash/xterminal to grab from scrollback. I'll get some files up and corral that info when I get home. I noticed --config worked some too. which should be in the capture/debug I'll get in a while. good progress! note this is on my acer notebook running 16.04 xubuntu k50d-test1.txt debug.output to file.txt

config.log.txt

edit: I think the screen output stuff is pktriggercord --debug info via dprint. I've also been working with that code trying to figure out the bug in the bulb mode and recognized it after getting an explanation of dprint outputting to error, then realized it wasn't gphoto debug! confusing. :-P

msmeissn commented 7 years ago

i need to hook up the bulk support i think, its not there yet.

I changed the dbeugging in git to log to the gphoto2 logfile (my hookin code was incorrect)

msmeissn commented 7 years ago

it would be nice to see what fails with capture-image :)

Blueshawk commented 7 years ago

Much quieter to screen now. Still gives an error but went ahead and worked the shutter. No capture file is apparent on the drive or sdcard. I got this to screen when I did the test.

0x0000 | 00 00 00 02 00 00 00 00 01 00 02 10 00 00 00 00
0x0010 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0020 | 00 00 00 0f 00 00 00 02 00 00 00 00 00 00 00 00
0x0030 | 00 00 01 00 00 00 00 03 00 00 00 0a 00 00 00 50
0x0040 | 00 00 00 0a 00 00 00 00 00 00 00 0a 00 00 00 00
0x0050 | 00 00 00 03 00 00 00 0a 00 00 00 00 00 00 00 03
0x0060 | 00 00 00 00 00 00 00 00 00 00 03 20 00 00 00 64
0x0070 | 00 00 0c 80 00 00 00 00 00 00 00 07 00 00 00 07
0x0080 | 00 00 00 02 00 00 00 00 00 00 00 00 00 00 00 01
0x0090 | 00 00 00 00 00 00 00 04 00 00 00 04 00 00 00 04
0x00a0 | 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 01
0x00b0 | 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 02
0x00c0 | 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 02
0x00d0 | 00 00 00 00 00 00 00 03 00 00 00 07 00 00 00 01
0x00e0 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01
0x00f0 | 00 00 00 01 00 00 00 00 00 00 13 88 00 00 00 04
0x0100 | 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 03
0x0110 | 00 00 00 0a 00 00 00 50 00 00 00 0a 00 00 00 00
0x0120 | 00 00 00 0a 00 00 00 00 00 00 00 0a 00 00 00 00
0x0130 | 00 00 00 00 00 00 03 20 00 00 00 00 00 00 00 01
0x0140 | 00 00 00 00 00 00 00 00 00 00 00 0a 00 00 00 00
0x0150 | 00 00 00 0a 00 00 00 02 00 00 00 00 00 00 00 50
0x0160 | 00 00 00 0a 00 00 00 00 00 00 00 00 00 00 02 50
0x0170 | 00 00 03 77 00 00 02 fd 00 00 00 00 00 00 00 00
0x0180 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0190 | 00 00 00 87 00 00 00 00 00 00 00 00 00 00 00 ca
0x01a0 | 00 00 0b f7 00 00 00 64 00 00 00 3c ff ff ff d8
0x01b0 | 00 00 00 00 00 00 00 00 00 00 00 0f 00 00 00 3f
0x01c0 | 00 00 00 00 00 00 00 00
ERROR: Could not capture image. ERROR: Could not capture. I got a couple of segfaults but then was able to get this on the third try: Here's a config.txt of --list-all-config > config.txt Here's the debug file from the second try. First try appended an old file and I realized it was getting big. k50debug1.txt

msmeissn commented 7 years ago

I added some more debugging to git. if you can rebuild and rerun the test? I think the image type is not correctly detected, but it was not debug priunted.

I also added "bulb" as config option, so --bulb seconds should produce some form of result, but it will probably encounter a failure similar to capture-image still.

Blueshawk commented 7 years ago

I think you are right about image type. I changed it to .jpg only and it captured a file on camera. I often use raw+ which makes one of each, or just raw for post processing. --bulb=45 appears to have set the camera exposure to 30 seconds, but also had the effect of never finishing. I also saw similar with pktriggercord in the past however so that may be "next tier" problem.

Rebuilt and tested with capture-image: k50d-test2.txt

Tested with --capture-image --bulb=10 ...no shutter , waited then ctrl-c out. k50d-bulbtest1.txt

msmeissn commented 7 years ago

so, the format your camera is set to RAW_PLUS. I added code similar to handling RAW (DNG?)

I also add a shutter release in bulb support. Can you check both again?

Blueshawk commented 7 years ago

Yes. It saves RAW format as .DNG and the + setting makes it go ahead and develop a .JPG file of the same name. I usually shoot raw or raw+ for astronomy. The bulb test was similar to before with the process stopping just after showing the bulb value and the hex dump. I let it run a bit before breaking out. The camera engaged the shutter when I did and it dropped out when I turned the camera power off. I suspect this may be the problem I was working on in pktriggercord last week. I had the idea that it might procedural problem and started learning the code but haven't isolated it. I was reading both Gphoto and Pktriggercord code when it occurred to me that this project might be a thing worth trying(still excited!). The k-50 has a menu item that sets bulb type to hold button or push on/off that may be offsetting the command from protocol somehow - just a hunch. I'd really like to get that working though as it's the number one thing we use in long exposure astrophotography(AP). It might also be worth noting that PKtriggercord usage was different and would dump photo code to terminal if you didn't give it a file name. Might be some weirdness involved there to check out.

I switched the dial to bulb mode for this with no change. k50d-bulb2.txt

The capture-image test still reported capture error, worked the shutter, and no file report. I made sure it was in raw+ and dialed to user mode with M(manual) k50d-test3.txt

msmeissn commented 7 years ago

Ok , I forgot some break; statements. that should cure the --capture-image cases now.

will check bulb later

Blueshawk commented 7 years ago

Failed to finish. Looks like it got stuck at the file type parsing again for some reason as log shows. did not report capture error to screen this time though. k50d-test4.txt

Blueshawk commented 7 years ago

Appreciate all the attention. :) I've had my k50 at the workbench with me all day while I work on PLC's in a windows vm so I could just bang out tests.

msmeissn commented 7 years ago

i am trying to move this a bit forward ;)

I now added a commit handling RAW_PLUS to the save function. (the single image capture modes should work already, RAW_PLUS needs a bit work)

Blueshawk commented 7 years ago

Oh rats. I found a problem on my end. The dirty bit got set on the card at some point. I'll get that cleaned up and retest. I have it set to not mount but probably failed to eject it after checking at some point then repowered the camera.

Blueshawk commented 7 years ago

Cleared card formatted with camera(easiest solution) and retested. Switched to .JPG to test. It still reports ERROR: Could not capture image. ERROR: Could not capture. New file is in location /capt0001.dng on the camera But it isn't to be found. I tried --capture-image-and-download and it worked okay, then deleted the photo from camera. The file reads okay, shows a pic of junk on my desk.

ERROR: Could not capture image. ERROR: Could not capture. New file is in location /capt0001.jpg on the camera File capt0001.jpg exists. Overwrite? [y|n] n Specify new filename? [y|n] y Enter new filename: capt0002 Saving file as capt0002 Deleting file /capt0001.jpg on the camera

Last couple tests. sorry about the size/stacking in it. I'll do more when I get home.

k50d-test5.txt

First file to pc viewer! woot!

msmeissn commented 7 years ago

yeah, capture-image-and-download is needed, as the file is only in temporary memory on the camera and in libgphoto2. I changed capture-image hopefully to also return an image already, so hopefully this error goes away.

Blueshawk commented 7 years ago

Ah, that explains the missing file.
Guess who left the only working pentax cable sitting on the workbench at work. :1st_place_medal: I saw some updates so blundering forward with another test this morning. Got a jpg on the first try: k50d-test6-jpg.txt

Raw+ test downloaded a .DNG file but raw readers would not open it. No jpg was found. and looked like this: hawk@hawk-Aspire-R3-131T:~/libgphoto2$ gphoto2 --debug --debug-logfile=k50d-test6-rawpl.txt --capture-image-and-download 0x0000 | 00 00 00 02 00 00 00 00 01 00 02 10 00 00 00 00
0x0010 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0020 | 00 00 00 0f 00 00 00 02 00 00 00 00 00 00 00 00
0x0030 | 00 00 01 00 00 00 00 01 00 00 00 0d 00 00 00 32
0x0040 | 00 00 00 0a 00 00 00 00 00 00 00 0a 00 00 00 00
0x0050 | 00 00 00 03 00 00 00 0a 00 00 00 00 00 00 00 03
0x0060 | 00 00 00 00 00 00 00 00 00 00 03 20 00 00 00 64
0x0070 | 00 00 0c 80 00 00 00 00 00 00 00 07 00 00 00 07
0x0080 | 00 00 00 02 00 00 00 00 00 00 00 00 00 00 00 01
0x0090 | 00 00 00 00 00 00 00 04 00 00 00 04 00 00 00 04
0x00a0 | 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 01
0x00b0 | 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 02
0x00c0 | 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 02
0x00d0 | 00 00 00 00 00 00 00 03 00 00 00 07 00 00 00 01
0x00e0 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01
0x00f0 | 00 00 00 01 00 00 00 00 00 00 13 88 00 00 00 04
0x0100 | 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 01
0x0110 | 00 00 00 0d 00 00 00 32 00 00 00 0a 00 00 00 00
0x0120 | 00 00 00 0a 00 00 00 00 00 00 00 0a 00 00 00 00
0x0130 | 00 00 00 00 00 00 03 20 00 00 00 00 00 00 00 00
0x0140 | 00 00 00 00 00 00 00 00 00 00 00 0a 00 00 00 00
0x0150 | 00 00 00 0a 00 00 00 02 00 00 00 00 00 00 00 50
0x0160 | 00 00 00 0a 00 00 00 00 00 00 00 00 00 00 02 50
0x0170 | 00 00 03 37 00 00 02 f0 00 00 00 00 00 00 00 00
0x0180 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0190 | 00 00 00 87 00 00 00 00 00 00 00 00 00 00 00 ca
0x01a0 | 00 00 0d ac 00 00 00 64 ff ff ff f6 ff ff ff d8
0x01b0 | 00 00 00 00 00 00 00 00 00 00 00 0f 00 00 00 3f
0x01c0 | 00 00 00 00 00 00 00 00
ERROR: Could not capture image. ERROR: Could not capture. New file is in location /capt0001.dng on the camera Saving file as capt0001.dng Deleting file /capt0001.dng on the camera

k50d-test6-rawpl.txt

The raw only test resulted in a 0 length .DNG file. after I said Y to overwrite. also after deleting the file and retrying. k50d-test6-raw.txt

msmeissn commented 7 years ago

k50d-test6-rawpl.txt

shows a JPEG file being downloaded, so capt0001.dng there might be .jpg instead... can you chek with "file capt0001.dng" ?

In the dual mode capture I need to detect the types better :/

k50d-test6-raw.txt only has a 0 byte files as you saw.

I added the status display code to --summary What you can try for instance:

gphoto2 --capture-image-and-download --summary

perhaps we can see something interesting there too

Blueshawk commented 7 years ago

I thought that might be the case too, because geeqie(which uses jpg/raw grouping for thumbnails) loaded it when rawtherapee and ufraw would not. Sure enough, renaming to .jpg loads in viewers right away. this may be related somehow to the dual(DNG+JPG) file output of raw+ mode. Heres the output of summary: Camera summary: Pentax K DSLR capture driver. Using code from pktriggercord by Andras Salamon. Collected Statatus Information: current iso : 800 current shutter speed : 1/13 camera max shutter speed : 1/6000 current aperture : 5.6 lens max aperture : 40.0 lens min aperture : 5.6 set shutter speed : 1/13 set aperture : 5.6 fixed iso : 800 auto iso : 100-3200 jpeg quality : 4 jpeg resolution : 16M jpeg image tone : Natural jpeg saturation : 4 jpeg contrast : 4 jpeg sharpness : 4 jpeg hue : 4 zoom : 47.50 mm focus : 0 color space : sRGB image format : RAW+ raw format : DNG light meter flags : 32 ec : 0.00 custom ev steps : 1/3 custom sensitivity steps : 0 exposure mode : 6 (NONE) user mode flag : 2 ae metering mode : Spot af mode : AF.S af point select : Auto-5 selected af point : 0 focused af point : 0 drive mode : SelfTimer-2 auto bracket mode : off auto bracket picture count : 0 auto bracket picture counter : 0 auto bracket ev : 0.30 shake reduction : off white balance mode : Auto white balance adjust : 0 flash mode : Manual flash exposure compensation : 0.00 manual mode ev : 1.30 lens : smc PENTAX-DA L 18-55mm F3.5-5.6 AL WR battery : 7.95V 7.23V 0.00V 0.00V

Here's the debug from that, file got pretty big. k50d-test7-rawpl.txt

I also ran raw only again: summary.txt k50d-test7-raw.txt

msmeissn commented 7 years ago

the raw only was empty, as the code did not handle raw downloads yet (only jpeg downloads).

I fixed that in GIT I hope.

I have some ideas for the dual-mode download.

msmeissn commented 7 years ago

(thats why the second trace for raw downlooad is so short... its 0 bytes, as there is no JPEG)

Blueshawk commented 7 years ago

I see. Okay I'll repeat the raw tests then. The raw+ did the same thing as previous, as expected? Never hurts to have a fresh debug: k50d-RAWpl.txt

The RAW only (DNG) shuttered okay, but failed to download a file. k50d-RAW.txt

msmeissn commented 7 years ago

I added some dual mode (rawplus) capture code now. you should be seeing both images being downloaded.

I need to add some waiting after delete I think, it currently returns some images twice

Blueshawk commented 7 years ago

I grabbed my camera soon as I noticed the message. :)

Here's a summary from the first test to show where I had things set: summary.txt

I had a little trouble and found that while it wasn't mounted, the msc drive being recognized seemed to be an issue. mounting then ejecting it in pcmanfm seemed to solve it and returned to expected operation. From console: " ERROR: Could not capture image. ERROR: Could not capture. New file is in location /capt0000.jpg on the camera ERROR: Could not get image. ERROR: Buggy libcanon.so? "

The raw+ test gave me 4 files as you mentioned, the raw is now actually a raw image and loaded right up in darktable, accepting a raw only command to filter noise(as a test). The jpg is okay as well. I did notice a slight exposure difference between the two but it was not reported in exif. I thought I heard a double shutter as if in bracket mode as well(which gives 3 images, I.e.+1,-1,0) but isn't when I tested it locally. May be related to the timing/delay issue you mentioned. More testing shows the shutter gets erratic in its timing, sometimes firing or working once before going ahead and doing the actual 2sec/remote delay shutter I usually use on the mount. It had been working okay with it but to be more sure I switched the camera to regular single mode and retested. k50-dngp.txt

This is output to console with the console hex dump omitted for clarity - repeating the command. hawk@hawk-Aspire-X1420:~/libgphoto2$ gphoto2 --capture-image-and-download --debug --debug-logfile=k50-dngp.txt ERROR: Could not capture image. ERROR: Could not capture. New file is in location /capt0000.jpg on the camera ERROR: Could not get image. ERROR: Buggy libcanon.so? hawk@hawk-Aspire-X1420:~/libgphoto2$ gphoto2 --capture-image-and-download --debug --debug-logfile=k50-dngp.txt New file is in location /capt0000.dng on the camera Saving file as capt0000.dng Deleting file /capt0000.dng on the camera New file is in location /capt0000.jpg on the camera Saving file as capt0000.jpg Deleting file /capt0000.jpg on the camera New file is in location /capt0001.dng on the camera Saving file as capt0001.dng Deleting file /capt0001.dng on the camera New file is in location /capt0001.jpg on the camera Saving file as capt0001.jpg Deleting file /capt0001.jpg on the camera

Debug of RAW only: k50-dng.txt I changed the debug level to "error" to help keep file size manageable, let me know if you need the really big (reporting 100+meg for some reason) version, though it may take a while to upload at home. probably wait till i'm at work to try, and zipping may help.

I managed to get the camera stuck twice breaking out of commands, and also managed to set the dirty bit again. Formatted with camera before the last couple tries.

Off to go Jupiter hunting with the new asi178 I just got! :)

msmeissn commented 7 years ago

I added some more waits to the capture function, so the errors should be gone now.

Blueshawk commented 7 years ago

Like a good bike saddle, nothing much to report when it works. I got the right files and right amounts of files this time in all tests jpg, raw, and raw+. :dancing_women: k50jpg.txt k50d-RAW.txt k50d-RAWpl.txt Might be time to look at some of the other config stuff?

I've been switching modes locally raw/etc. because the config takes the command but no change is made. Also that pesky bulb problem still eludes me - I stopped digging in the pktriggercord code once you started this since it seemed it might become redundant and your wisdom on this is going to be miles ahead of my meager efforts. the library called bulb correctly but it responded incorrectly as when I tried it with pktriggercord-cli. Before I stopped looking I thought the bulb setup might have been offset by a version change but I found a guy with a k30 who also reports having bulb press type 1-2 in the extra menus. I had noticed that the bulb setting I usually keep on 2 for press open-press closed changed to 1 after calling --bulb in pktirggercord. It seems to recognise the mode as bulb, and your code did get a shutter if I remember right, but never timed out or locked up. not sure which. I'll redo that test when I get home. Would a todo list help? I could do a more complete checkout of --config as well if needed.

Blueshawk commented 7 years ago

Running some tests at home, confirmed the proper downloads again on another computer. Nice! Also noted the internal 2 second shutter delay works correctly and does not interfere. I pulled something from my notes on pktriggercord that I thought might be of interest: " I think the return from status call may not be passing the string to status, but instead a number, presumably from the camera? ..so I did some more tests and ran through the dial collecting data." (note the gui mode [user1/2 dial position changes on screen in software] switch to also does not work) dialed exposure modes (read from status) 7 (none) = B Bulb 6 (none) = M Manual 5 (none) = Tav 4 (none) = Av 3 (none) = Tv 2 (none) = Sv 0 (none) = P 1 (STANDARD) = movie (movie camera icon) - odd,fired shutter during status 0 (MACRO) = green colored "auto" () shows submode 1 (LANDSCAPE) = "SCN" scene mode.() shows what scene is picked." when I put the number into the bulb function parse it acted more correctly, but I still hadn't gotten it to shutter. I think this may be related to several problems with mode changes.

Blueshawk commented 7 years ago

Bulb test with bulb mode1 and user1 set to bulb manually in camera gphoto2 --capture-image-and-download --bulb 5 --debug-loglevel=debug --debug-logfile=k50bulbjpg.txt Bulb mode enabled (exposure time: 5s). [omitted hex code console output]
pentax/pslr.c:869:get_status(p->fd) failed: 129 New file is in location /capt0000.jpg on the camera Saving file as capt0000.jpg Deleting file /capt0000.jpg on the camera pentax/pslr.c:869:get_status(p->fd) failed: 129

camera shuttered but photo has 1/25 second exposure. (press and hold probably not the method to use)

k50bulb.txt

Next I changed to mode 2, dial user1 and gui set bulb Camera opened shutter, errors came at time 5=seconds but had to break out and restart camera to close shutter. pentax/pslr.c:869:get_status(p->fd) failed: 129 pentax/pslr.c:869:get_status(p->fd) failed: 129 ^C Cancelling... ^C k50bulb2.txt

if you have other stuff i'll be glad to go in whatever order you like and as time allows of course. I figured it never hurts to send more data. :)

msmeissn commented 7 years ago

The shootingmode values should now match what is on the camera, I was using the wrong enum.

so switch the camera mode dial to "B", plug it in, then run:

gphoto2 --set-config bulb=1 --wait-event=5s --set-config bulb=0 --wait-event-and-download=5s

I now merged the pentax branch back into GIT "master" branch for further work and the next release. "git checkout master" and then "git pull" as usual...

Blueshawk commented 7 years ago

Good morning! This looks like a great thing to wake up to. :fireworks: Well it almost worked. The shutter opened but never closed. After waiting long enough, I manually pushed the shutter button and the routine then downloaded files but kept on going and the camera became unresponsive. After pulling power to reset it, I tried setting the extras menu item to bulb=1 (press and hold) and it worked the shutter/released the first time but not the second which seems right. looks to me like the camera didn't like bulb=0 command. Because I had to break out the debug may be incomplete. I can try some more ways if needed. k50bulb.txt

EDIT DOH! I did git pull and forgot to compile! ..morning indeed. ignore all that. Trying again!

Blueshawk commented 7 years ago

(head clearing) ..sorry bout that. When I did the command you sent I got a quick shutter open/close and then it waited, then downloaded the (very dark) picture. I checked and it was set to bulb mode 2 press/press so I changed it to mode 1 and tried again. It did similar to before with open shutter and time down but not close it. *** I tried something else which may be a clue. I set to mode 2 and changed the command to have the bulb 0 be another bulb 1 like this: libgphoto2$ gphoto2 --debug --debug-logfile=k50bulb.txt --debug-loglevel=debug --set-config bulb=1 --wait-event=5s --set-config bulb=1 --wait-event-and-download=5s And it triggered the shutter both times! I'm thinking maybe it toggled back on its own? Hope this helps.

Both commands landed in the one file. k50bulb.txt

In other tinkering, I got my first photo from the k50 in indilib/ekos last night! The exposure change doesn't work and the mode set causes issues as expected considering my previous report on it but it was neat to see it connect and give me results.

msmeissn commented 7 years ago

You need to send --set-config bulb=0 at the end of bulb capture.

It seems not be doing bulb capture though, as the bulb=0 reports some error back from the camera.

It seems to access the filesystem at least.

gphoto2 --debug --debug-logfile=k50bulb.txt --debug-loglevel=debug --set-config bulb=1 --wait-event-and-download=5s --set-config bulb=0 --wait-event-and-download=5s

I suspect it takes a regular non-bulb image for some reason :/

Blueshawk commented 7 years ago

hmm. Did my second try overwrite the first in the debug? I did it correctly the first time but did not change the file name on the second (experimental) try. I'll redo that test asap.

The camera did take a very short exposure image with the proper command. The bulb=1 may be changing back to 0 by itself in camera

My improper use version was a troubleshooting experiment. It shows that the command will toggle shutter each time bulb=1 is called. I noticed in the pktriggercord code that there is a shutter call if the bulb mode is not found, which leads me to believe that routine is not parsing bulb because it's getting a number instead of the name.

Blueshawk commented 7 years ago

Just to try to be clear I did it again and split things up better. :)

gphoto2 --debug --debug-logfile=k50bulb.txt --debug-loglevel=debug --set-config bulb=1 --wait-event-and-download=5s --set-config bulb=0 --wait-event-and-download=5s

Image exif shows 1/25s This one produced the file: k50bulb - 1 press and hold.txt

This one opens shutter and hangs. k50bulb-2 press start press stop.txt

msmeissn commented 7 years ago

Thanks... I looked at it and the bulb command gets a status of 0x81 ...

Good status would be 0x00 (ok) or 0x01 (busy, wait a bit) , but 0x81 seems to indicate something went wrong or was unexpected.

So it just executed the psl_shutter command, which then took a short picture.

The same thing works for my K10D, so the K50D seems to have a different thing going on.

Does bulb mode work on the camera itself?

Blueshawk commented 7 years ago

Bulb mode works. I use an IR remote to fire bulb on the telescope in press press mode. Does the k10D have the two different bulb modes in the menu?

Also, does the --summary for the k10D show numbers in exposure mode or command names?

msmeissn commented 7 years ago

I dont see any mention of bulb in the cameras menus. I can turn the dial to "B" but there seems no other modification possibility. Pressing the shutter button starts bulb, releasing it ends bulb capture.

Blueshawk commented 7 years ago

Ideas, theory and hypothesis:

Idea: Since the first command set config bulb=1 also locks the shutter open okay, maybe doing something like calling shutter directly I.E. shutter/time/shutter while menu bulb mode=2 (+dial set to bulb) would make it close and finish up..

Since the K10D is using the press and hold method (bulb=1/wait/bulb=0) then bulb=1 is shutter open in that model. My suspicion is that the later models bulb=1 sets the menu bulb input type. I'm pretty sure I saw bulb change from 2 to 1 in one of my early tests which made me suspect this. I saw it because I usually use mode 2 in normal(nighttime) use and found it had changed to 1 in the menu.

Hypothesis: Is bulb=1 acting on the menu instead of a set shuttering routine as in the earlier models? I'm out of time tonight but i'll try to verify that as soon as I get a chance.

If so, enabling the routine to --set-config bulb=2(which currently errors) for later models might prove useful in the long term, perhaps by being able to set the control mode at run time.

On another note, this article shows the K-30 also has the menu items. I think that model may be when things changed, The trick is going to be finding out just how they differ. [recently {9/17} discovered others, k-5 and k-7 also have bulb type in menus)