When using requestSendPTPCommand to send both commands and data simultaneously, the response timeout occurs and the length of the command and data in the response is 0, need help pls.

I am debugging ImageCaptureCore to communicate with external cameras.

When I called the PTP function below to send a command and add data, the response timed out for more than 5 seconds. After waiting for a period of time, I obtained the response. However, the response callback function obtained responsivData.length as zero and ptpResponseData.length as zero too.

  • (void)requestSendPTPCommand:(NSData *)ptpCommand outData:(NSData *)ptpData completion:(void (^)(NSData *responseData, NSData *ptpResponseData, NSError *error))completion;

data is below: Wrote 1 = 0x1 bytes PTP:send data: (hexdump of 1 bytes) [ ] I/PTP (14564): 0000 01 - .

Answered by DTS Engineer in 855608022

When I called the PTP function below to send a command and add data, the response timed out for more than 5 seconds. After waiting for a period of time, I obtained the response. However, the response callback function obtained responsivData.length as zero and ptpResponseData.length as zero too.

What were the full contents of ptpCommand (6 bytes) and ptpData (if applicable)? More generally, what command were you trying to send and what did you expect to happen?

I haven't looked at the PTP spec in any great detail, but what your describing sound like what happens if you sent the device a command it didn't handle "well".

__
Kevin Elliott
DTS Engineer, CoreOS/Hardware

When I called the PTP function below to send a command and add data, the response timed out for more than 5 seconds. After waiting for a period of time, I obtained the response. However, the response callback function obtained responsivData.length as zero and ptpResponseData.length as zero too.

What were the full contents of ptpCommand (6 bytes) and ptpData (if applicable)? More generally, what command were you trying to send and what did you expect to happen?

I haven't looked at the PTP spec in any great detail, but what your describing sound like what happens if you sent the device a command it didn't handle "well".

__
Kevin Elliott
DTS Engineer, CoreOS/Hardware

        struct {
            uint32_t length;
            uint16_t type;
            uint16_t code;
            uint32_t transactionId;
            uint32_t Param1;
        } __attribute__((packed)) ptpCommand;

        ptpCommand.length = 16;
        ptpCommand.type = 2;
        ptpCommand.code = 0x9205;
        ptpCommand.transactionId = 3;
        ptpCommand.Param1 = 0xD25A;

        NSData sendCommand = [NSData dataWithBytes:&ptpCommand length:16];

        unsigned char specialData = 1;
        NSData sendData = [NSData dataWithBytes:&specialData length:1];

[cam requestSendPTPCommand:sendCommand outData:sendData completion:^(NSData* responseData, NSData* ptpResponseData, NSError* err){

}];

I don't know if specialData needs to be placed in sendData or sendCommand. I have tried various data structures, but none of them work

The camera is Sony A7M3 (ILCE-7M3), and the camera supports the command for this setting properties. The transmitted command and data are also correct, and the expected return is data with a length of 12 for ptpResponseData

Getting back to this a bit late...

I don't know if specialData needs to be placed in sendData or sendCommand. I have tried various data structures, but none of them work.

Looking over your code, I see two things that concern me:

  1. First, I believe command type "2" is for command ack's, so I think that should be "1" instead.

  2. I don't think you're accounting for endian-ness. The ISO-15740 spec is written using big endian notation (sensible), but the actual endian format is transport defined (not sensible). In the case of USB, I believe that means everything is little endian.

Lastly, we have an old sample project named "PTPPassThrough" in the documentation archive. I'm not sure how hard it would be to get it working*, but it does provide an example of how to build commands.

*Shockingly, the only build error I got was that Xcode couldn't find the 10.6 SDK (yes, SnowLeopard!), but I don't have the hardware at hand to see if it actually "works".

__
Kevin Elliott
DTS Engineer, CoreOS/Hardware

Thank you for your reply.

I have previously referred to PTPPassThrough, but there is no example of sending the outData parameter, and I have not found it on Apple forums or online.

And I have also tried putting sendData into sendCommand, and sending the command and data in two separate requests, but none of them worked. I have tried changing the command type to 1, but it did not work. I think it should be 2 because it requires sending sendData, and another reason is that I have referenced other PTP libraries that use 2 to send data.

The command and data are using little endian, which should not be a problem because we have referenced other PTP libraries that also use little endian.

There are new developments or changes now, and I am using this camera. If there is no time limit for waiting for a response after sending a request, I will receive a normal response after more than 1 minute, which is a 12 byte length ptpResponseData. But obviously, normally I wouldn't wait that long. The timeout I set is 20 seconds.

I am currently annotating the request to send commands and data to prevent it from working. Some cameras can function normally, but other cameras may not, and any request that contains both commands and data cannot work. I have tested several brands of cameras, and some will respond with error messages in a short period of time, such as not being able to complete this request, while others will respond with empty commands. If some cameras really need to receive timely and correct responses after sending commands and data requests to work properly, then the business will be seriously affected.

When using requestSendPTPCommand to send both commands and data simultaneously, the response timeout occurs and the length of the command and data in the response is 0, need help pls.
 
 
Q