Submit transfer works, callbacks work. Need to interpret data
This commit is contained in:
parent
7769e7ef8c
commit
1ccf002bbf
@ -68,7 +68,7 @@ struct hanvon {
|
|||||||
void callback(struct libusb_transfer *transfer) {
|
void callback(struct libusb_transfer *transfer) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for(; i < 10; i++) {
|
for(; i < 10; i++) {
|
||||||
printf("%c, ", transfer -> buffer[i]);
|
printf("0x%x, ", transfer -> buffer[i]);
|
||||||
}
|
}
|
||||||
printf("placeholder\n");
|
printf("placeholder\n");
|
||||||
}
|
}
|
||||||
@ -149,32 +149,32 @@ int main()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Got to this point\n");
|
|
||||||
|
|
||||||
|
|
||||||
// Wait and handle interrupts?
|
// Wait and handle interrupts?
|
||||||
struct libusb_transfer tx;
|
struct libusb_transfer *tx;
|
||||||
|
|
||||||
const int ENDPOINT_ADDR = 0x81; // bEndpointAddress from lsusb -v
|
const int ENDPOINT_ADDR = 0x81; // bEndpointAddress from lsusb -v
|
||||||
const unsigned int LEN = 10; // wMaxPacketSize from lsusb -v
|
const unsigned int LEN = 10; // wMaxPacketSize from lsusb -v
|
||||||
unsigned char buffer[LEN];
|
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,
|
h,
|
||||||
ENDPOINT_ADDR,
|
ENDPOINT_ADDR,
|
||||||
buffer,
|
buffer,
|
||||||
LEN,
|
LEN,
|
||||||
callback,
|
callback,
|
||||||
NULL,
|
NULL,
|
||||||
130); // milliseconds
|
130); // timeout in milliseconds
|
||||||
|
|
||||||
state = libusb_submit_transfer(&tx);
|
do {
|
||||||
|
state = libusb_submit_transfer(tx);
|
||||||
if (state < 0 ) {
|
if (state < 0 ) {
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
for(;;) {
|
|
||||||
libusb_handle_events(NULL);
|
libusb_handle_events(NULL);
|
||||||
}
|
} while (1);
|
||||||
|
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user