mirror of
https://github.com/erjiang/usbscale.git
synced 2025-06-28 00:50:59 -06:00
Read and discard old packet
This commit is contained in:
parent
97d0d7a109
commit
7ca9725b91
15
usbscale.c
15
usbscale.c
@ -166,6 +166,21 @@ int main(void)
|
||||
int continue_reading = 0;
|
||||
int scale_result = -1;
|
||||
|
||||
//
|
||||
// For some reason, we get old data the first time, so let's just get that
|
||||
// out of the way now. It can't hurt to grab another packet from the scale.
|
||||
//
|
||||
r = libusb_interrupt_transfer(
|
||||
handle,
|
||||
//bmRequestType => direction: in, type: class,
|
||||
// recipient: interface
|
||||
LIBUSB_ENDPOINT_IN | //LIBUSB_REQUEST_TYPE_CLASS |
|
||||
LIBUSB_RECIPIENT_INTERFACE,
|
||||
data,
|
||||
WEIGH_REPORT_SIZE, // length of data
|
||||
&len,
|
||||
10000 //timeout => 10 sec
|
||||
);
|
||||
//
|
||||
// We read data from the scale in an infinite loop, stopping when
|
||||
// **print_scale_data** tells us that it's successfully gotten the weight
|
||||
|
Loading…
x
Reference in New Issue
Block a user