-
Notifications
You must be signed in to change notification settings - Fork 37
Description
I am trying to use this library to implement a simple PTP (picture transfer protocol) to be able to control my DLSR using Trinket M0.
But no matter what, I never get any data from the camera when using the actual PTP.
I can get all the descriptors just fine, as that's done by the library itself. Using them I set up the device to use correct endpoints and config. But then, no matter what, when I tried to get "GetDeviceInfo" from the camera, both outTransfer and inTransfer return 0, but there are never any data coming from inTransfer.
Here is the function that I call when I press a button connected to pin 1 on my trinket.
void camPoll() {
int rcode;
uint16_t length = (sizeof(uint16_t)*2 + sizeof(uint32_t)*2); //dont care about the rest of the container
uint8_t data[length];
memset(data, 0, length);
//little endian
data[0] = 0x0C; //len 0
data[4] = 0x01; //type 0
data[6] = 0x01; //code 1
data[7] = 0x10; //code 0
//send command container
rcode = UsbH.outTransfer(1, ep_info[BULK_OUT].epAddr, length, data);
u8x8log.printf("RC: %d\n", rcode);
uint16_t read = 64;
uint8_t in_data[64];
memset(in_data, 0, 64);
//receive data
rcode = UsbH.inTransfer(1, ep_info[BULK_IN].epAddr, &read, in_data);
u8x8log.printf("RC: %d\n", rcode);
//print data
for (int i = 0; i < 64; i++) {
u8x8log.printf("%02x", in_data[i]);
if ((i + 1) % 8 == 0) u8x8log.printf("\n");
}
}
And every time, I get return code 0, but no data in "in_data".
Also, after 2 tries, I start to get return code 2 on outTransfer.
I have tried literally everything I could think of (different packet sizes, endians, endpoints), but nothing works.
Does anyone have any idea how to actually use this for PTP?
P.S.: I looked into some PTP libraries (libgphoto2, PTP2.0). I followed them as close as I could, but I never get anything from the camera.