Submit transfer works, callbacks work. Need to interpret data

This commit is contained in:
surkeh 2020-09-15 16:27:29 -07:00
parent 7769e7ef8c
commit 1ccf002bbf

View File

@ -68,7 +68,7 @@ struct hanvon {
void callback(struct libusb_transfer *transfer) {
int i = 0;
for(; i < 10; i++) {
printf("%c, ", transfer -> buffer[i]);
printf("0x%x, ", transfer -> buffer[i]);
}
printf("placeholder\n");
}
@ -149,32 +149,32 @@ int main()
return 0;
}
printf("Got to this point\n");
// Wait and handle interrupts?
struct libusb_transfer tx;
struct libusb_transfer *tx;
const int ENDPOINT_ADDR = 0x81; // bEndpointAddress from lsusb -v
const unsigned int LEN = 10; // wMaxPacketSize from lsusb -v
unsigned char buffer[LEN];
// assign timeout of 1s, for any action is too much as is
libusb_fill_interrupt_transfer( &tx,
// Allocate memory for transfer, configure, then submit
tx = libusb_alloc_transfer(0);
libusb_fill_interrupt_transfer( tx,
h,
ENDPOINT_ADDR,
buffer,
LEN,
callback,
NULL,
130); // milliseconds
130); // timeout in milliseconds
do {
state = libusb_submit_transfer(tx);
if (state < 0 ) {
return state;
}
libusb_handle_events(NULL);
} while (1);
state = libusb_submit_transfer(&tx);
if (state < 0 ) {
return state;
}
for(;;) {
libusb_handle_events(NULL);
}
return state;
}