From f0f49dd7ecb27635906557267a733dd8bdb8a9f7 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sun, 10 Nov 2013 00:30:36 +0200 Subject: [PATCH] Avoid a race condition with the last bytes of an S88 read --- arducontrol/s88.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arducontrol/s88.c b/arducontrol/s88.c index 142455a..bd53deb 100644 --- a/arducontrol/s88.c +++ b/arducontrol/s88.c @@ -28,8 +28,11 @@ void s88_init(void) void s88_check(void) { + /* Check remaining read count before ringbuffer fill. If it is zero, no + more bytes are arriving in the buffer and the contents can be sent out. */ + uint8_t rc = s88_read_count; uint8_t count = ringbuffer_fill(s88_buffer); - if(count>=4 || (count>0 && !s88_read_count)) + if(count>=4 || (count>0 && !rc)) { uint8_t reply[10]; -- 2.45.2