Add callback, callback doesnt fire
This commit is contained in:
parent
65a378a469
commit
b841132264
@ -65,16 +65,21 @@ struct hanvon {
|
||||
char phys[32];
|
||||
};
|
||||
|
||||
|
||||
void callback(struct libusb_transfer *transfer) {
|
||||
int i = 0;
|
||||
for(; i < 10; i++) {
|
||||
printf("%c, ", transfer -> buffer[i]);
|
||||
}
|
||||
printf("placeholder\n");
|
||||
}
|
||||
|
||||
libusb_device *FindHanvon( libusb_context **context);
|
||||
int HandleData( void );
|
||||
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
libusb_context **context;
|
||||
libusb_context *context;
|
||||
libusb_device *device;
|
||||
libusb_device_handle *handle;
|
||||
|
||||
@ -82,7 +87,7 @@ int main()
|
||||
if( state != STATE_SUCCESS )
|
||||
return state;
|
||||
|
||||
device = FindHanvon( context );
|
||||
device = FindHanvon(& context );
|
||||
if( device == NULL )
|
||||
return STATE_NOT_FOUND;
|
||||
|
||||
@ -92,7 +97,28 @@ int main()
|
||||
|
||||
|
||||
// Wait and handle interrupts?
|
||||
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,
|
||||
handle,
|
||||
ENDPOINT_ADDR,
|
||||
buffer,
|
||||
LEN,
|
||||
callback,
|
||||
NULL,
|
||||
130); // milliseconds
|
||||
|
||||
state = libusb_submit_transfer(&tx);
|
||||
if( state != STATE_SUCCESS )
|
||||
return state;
|
||||
|
||||
for(;;) {
|
||||
libusb_handle_events(context);
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user