fix hw status (and USB comm in general) (#434)

* don't ignore ReadLine() errors (Windows)
* lock CmdBuffer with Mutex
* refactor WaitForResponseTimeoutW
This commit is contained in:
pwpiwi 2017-10-24 07:48:38 +02:00 committed by GitHub
commit 23af9327a5
3 changed files with 25 additions and 12 deletions

View file

@ -73,12 +73,11 @@ static void *uart_receiver(void *targ) {
while (arg->run) {
rxlen = 0;
if (uart_receive(sp, prx, sizeof(UsbCommand) - (prx-rx), &rxlen)) {
if (uart_receive(sp, prx, sizeof(UsbCommand) - (prx-rx), &rxlen) && rxlen) {
prx += rxlen;
if (prx-rx < sizeof(UsbCommand)) {
continue;
}
UsbCommandReceived((UsbCommand*)rx);
}
prx = rx;