Fix changing the OSTC settings

The command to change the OSTC settings has a variable length payload (1
to 4 bytes). Therefore, the expected number of bytes is only know after
evaluating the first option index byte. Due to the limited UART buffer
in the OSTC, sending the remainder of the packet immediately after the
first byte, can cause the OSTC to get out of sync.

Introduce a small delay between sending the option index and the
remaining parameters to avoid this problem.
This commit is contained in:
Jef Driesen 2022-03-30 20:52:07 +02:00
parent 0448ce686a
commit 0753f10661

View File

@ -318,11 +318,29 @@ hw_ostc3_transfer (hw_ostc3_device_t *device,
}
if (input) {
// Send the input data packet.
status = hw_ostc3_write (device, progress, input, isize);
if (status != DC_STATUS_SUCCESS) {
ERROR (abstract->context, "Failed to send the data packet.");
return status;
if (cmd == WRITE) {
// Send the first byte of the input data packet.
status = hw_ostc3_write (device, progress, input, 1);
if (status != DC_STATUS_SUCCESS) {
ERROR (abstract->context, "Failed to send the data packet.");
return status;
}
dc_iostream_sleep (device->iostream, 10);
// Send the reamainder of the input data packet.
status = hw_ostc3_write (device, progress, input + 1, isize - 1);
if (status != DC_STATUS_SUCCESS) {
ERROR (abstract->context, "Failed to send the data packet.");
return status;
}
} else {
// Send the input data packet.
status = hw_ostc3_write (device, progress, input, isize);
if (status != DC_STATUS_SUCCESS) {
ERROR (abstract->context, "Failed to send the data packet.");
return status;
}
}
}