Improve the communication with Darwin Air devices.

We received a report of a Darwin Air device which has a very high error
rate. The majority of the echo packets is incorrect, but since this
doesn't seem to have any effect on the actual data packet, we can just
ignore this error. If there happens to be a more serious error, it will
be detect in the data packet.

Sometimes there were also a some garbage bytes received at startup.
Adding a small delay seems to fix this.
This commit is contained in:
Jef Driesen 2012-03-05 21:20:07 +01:00
parent 1ccd786493
commit d4b94cb77c
2 changed files with 4 additions and 1 deletions

View File

@ -152,7 +152,6 @@ mares_common_packet (mares_common_device_t *device, const unsigned char command[
// Verify the echo.
if (memcmp (echo, command, csize) != 0) {
WARNING ("Unexpected echo.");
return DEVICE_STATUS_PROTOCOL;
}
}
@ -196,6 +195,9 @@ mares_common_transfer (mares_common_device_t *device, const unsigned char comman
// Abort if the maximum number of retries is reached.
if (nretries++ >= MAXRETRIES)
return rc;
// Discard any garbage bytes.
serial_flush (device->port, SERIAL_QUEUE_INPUT);
}
return rc;

View File

@ -158,6 +158,7 @@ mares_darwin_device_open (device_t **out, const char* name, unsigned int model)
}
// Make sure everything is in a sane state.
serial_sleep (100);
serial_flush (device->base.port, SERIAL_QUEUE_BOTH);
// Override the base class values.