Remove the code to purge the input buffer
Trying to purge the input buffer by reading and discarding data packets, results in an annoying and confusing error message if no data packet is received. To avoid this error, the functionality should be integrated in the USB HID code, either automatically during initialization or by implementing the purge function. But since there seems to be no evidence that this is actually necessary, let's remove this code.
This commit is contained in:
parent
5344f3926a
commit
43f196b804
@ -565,23 +565,8 @@ initialize_eonsteel(suunto_eonsteel_device_t *eon)
|
||||
{
|
||||
dc_status_t rc = DC_STATUS_SUCCESS;
|
||||
const unsigned char init[] = {0x02, 0x00, 0x2a, 0x00};
|
||||
unsigned char buf[64];
|
||||
struct eon_hdr hdr;
|
||||
|
||||
dc_iostream_set_timeout(eon->iostream, 10);
|
||||
|
||||
/* Get rid of any pending stale input first */
|
||||
for (;;) {
|
||||
size_t transferred = 0;
|
||||
rc = dc_iostream_read(eon->iostream, buf, sizeof(buf), &transferred);
|
||||
if (rc != DC_STATUS_SUCCESS)
|
||||
break;
|
||||
if (!transferred)
|
||||
break;
|
||||
}
|
||||
|
||||
dc_iostream_set_timeout(eon->iostream, 5000);
|
||||
|
||||
rc = send_cmd(eon, CMD_INIT, sizeof(init), init);
|
||||
if (rc != DC_STATUS_SUCCESS) {
|
||||
ERROR(eon->base.context, "Failed to send initialization command");
|
||||
@ -634,6 +619,12 @@ suunto_eonsteel_device_open(dc_device_t **out, dc_context_t *context, unsigned i
|
||||
goto error_free;
|
||||
}
|
||||
|
||||
status = dc_iostream_set_timeout(eon->iostream, 5000);
|
||||
if (status != DC_STATUS_SUCCESS) {
|
||||
ERROR (context, "Failed to set the timeout.");
|
||||
goto error_close;
|
||||
}
|
||||
|
||||
status = initialize_eonsteel(eon);
|
||||
if (status != DC_STATUS_SUCCESS) {
|
||||
ERROR(context, "unable to initialize device");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user