Hi, Foremost, Nikon documents large parts of the PTP opcodes, properties, etc in their NIKON Camera SDK which is free for download (after registering).
Check this out. On Tue, Sep 27, 2022 at 09:10:07AM +0000, Omri Sarig via Gphoto-devel wrote: > Hello, > > I'm very new to libgphoto2 development, and would greatly appreciate some > help or references. > > In short: > I'm missing some functionality with my camera that I believe to be provided > through unparsed PTP options. I'm looking into parsing the unknown PTP > options to try and understand what option is relevant for the command I'm > missing and add it. > > Full description: > > I have a camera (Nikon > Z9<https://www.nikonusa.com/en/nikon-products/product/mirrorless-cameras/z-9.html>) > that I'm trying to control remotely using a Linux machine. > > Using libgphoto2 (both by writing my own code or the gphoto2 frontend), I can > connect to the camera, print information about it and do basic actions (such > as taking pictures or videos and doing file operations). > > However, there is functionality that I'm missing. > The camera has a switch that controls the mode it is in (video or photos), > the camera cannot take pictures while in video mode, and cannot take videos > while in photos mode. When I'm using the camera's provided software (camera > control pro > 2<https://downloadcenter.nikonimglib.com/en/products/165/Camera_Control_Pro_2.html>, > available only for Windows), I can change this mode, however, I cannot do it > using libgphoto2. > My assumption is that one of the unknown PTP codes contains the command to > change this mode. > > When looking at the log of a connection to the camera (provided), I can see > that there are quite a lot of PTP options that are unknown to libgphoto2 > (lines 473 to 600). I want to try and understand what these options are in > practice, and use the ones relevant to my needs. > I could not find any reference for the full commands, so I assume they were > reverse-engineered out of the cameras? Are there any full documents that > might include these commands? > My thoughts for reverse engineering the PTP commands: > > * Bruteforcing - Since I know the option I want to change is binary, > trying to send all the unknown commands as a command with a single parameter, > changing this parameter and seeing whether I can see the change that I want > in the camera. > * Sniffing - Using the windows program that changes this option while > sniffing the USB communication, trying to figure out what command is sent > while changing this option. Yes, usually you can sniff the USB Traffic under Windows and then work your way from there. > My main questions: > > * As stated above, can there be any relevant documents that describe > these commands, so I won't have to reverse-engineer them? See above, Nikon SDK for the Z9. > * Is there a standard operation for reverse engineering of PTP options? > Are there any more solutions to figure out how these PTP options are set and > can be controlled? I am using usbpcap for sniffing and then wireshark to display / extract top text if I really need to sniff USB traffic. > * How likely it is that I'm barking at the wrong tree? Meaning that there > might be another layer of communication between the windows program and the > camera, which is not through PTP commands, or that some of my assumptions are > wrong, or I missed something fundamental and basic with libgphoto2 usage. We might have implemented the option already, it just might be named in a non-standard way. e.g. "cameramode" "applicationmode" or similar. So - study the Z9 SDK - sniff usb traffic Ciao, Marcus _______________________________________________ Gphoto-devel mailing list Gphoto-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gphoto-devel