#150 PTP/IP events and minor fixes

Yifan Lu

I added some very basic event handling code for ptpip.c (in the ptp2 camlib). A more complete implementation would also handle Cancel_Transaction, Ping, and Pong and only return Event to the user. (Right now it ignores those other commands but it makes sure not to try to return them to the user).

In order for ptp_ptpip_event to work correctly, ptp_ptpip_check_event() should be removed, as right now it just dumps events. I did not remove it because it might break compatibility.

I also made a change in ptp_ptpip_getresp() from:
n = (dtoh32(hdr.length) - ptpip_resp_param1)/sizeof(uint32_t);
n = (dtoh32(hdr.length) - sizeof(hdr) - ptpip_resp_param1)/sizeof(uint32_t);

I believe the intent there was to get the number of paramaters based on the size of the header, however right now it seems to ignore the fact that hdr.length also contains the size of the header itself. I did not look too much into this so someone should double check this.

Finally in ptp_ptpip_connect(), I moved the connect() for evtfd above ptp_ptpip_init_command_request() because on the device I was working on (Playstation Vita), the commands socket refuses to send data until the events socket is also connected. I don't know if other devices may do this too or if it breaks any compatibility.

1 Attachments


    • assigned_to: Marcus Meissner
    • Group: -->
  • The - sizeof(hdr) is ok I think.

    I applied your patch, just replaced the // comment by / /

  • i applied this incremental patch to hook in the ptp_ptpip_check_event() better
    and let that one store the ptp events in the queue.

    I also rewrote the wait_event to timeout also in the non-fast case.

    can you test it?

  • Yifan Lu
    Yifan Lu

    It looks okay to me. I can't really test it right now since I'm using a modified ptp2 in my application without gphoto2, and my implementation waits for events and handles it instead of polling and deferring the handling. I'm considering changing it to be latter because of how Cancel_Transaction and Ping would have to be implemented, but it may be a while before I get the chance to make the change.

  • Yifan Lu
    Yifan Lu

    Okay, this is something really weird I'm running into on PTP/IP and I don't want to open a new ticket because I'm not sure if it's my fault or ptpip.c's. Anyways:

    I'm sending data that is 0x100008 bytes long. ptp_ptpip_senddata() should have broken it into "WRITE_BLOCKSIZE" (65536) byte messages, but it tried to send a single message of size 0x10000C. However, when I changed "WRITE_BLOCKSIZE" to a smaller number (32756), it works in sending chunks.

    Again I don't know if this is my problem or not, but I will look more into it when I have time. I just want to write it down somewhere so it isn't forgotten.

  • it will send messages of 0x1000c size ... looks closely similar, but one 0 less. perhaps you miscounted the 0s? :)

  • Cyrille Berger
    Cyrille Berger

    Hi. With a Nikon D600 and the wu-1b dongle. The move of the connect() for evtfd above ptp_ptpip_init_command_request() fails, it hangs in the call. While if I revert that part of the patch it connects.

  • Yifan Lu? Was there any reason to move the connect?

    • status: open --> closed-fixed
  • lets close.

    whoever finds issues with 2.5.5., open a new ticket please