From dfe51654709d752ac19ecfcca5d6d1f1e605ce52 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Mon, 28 Oct 2013 22:20:28 +0200 Subject: [PATCH] Send at least four S88 data octets per packets if possible Each packet has three bytes of overhead, which is pretty significant if only a single data byte is sent. Grouping them in larger units increases throughput and only produces a negligible increase in latency. --- arducontrol/s88.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/arducontrol/s88.c b/arducontrol/s88.c index 1ce5740..bce0a2a 100644 --- a/arducontrol/s88.c +++ b/arducontrol/s88.c @@ -28,14 +28,18 @@ void s88_init(void) void s88_check(void) { - // Only send one packet per check to avoid blocking - if(ringbuffer_fill(s88_buffer)>0) + uint8_t count = ringbuffer_fill(s88_buffer); + if(count>=4 || (count>0 && !s88_read_count)) { - uint8_t reply[3]; + uint8_t reply[10]; + uint8_t i; + reply[0] = S88_DATA; - reply[1] = s88_out_index++; - reply[2] = ringbuffer_pop(s88_buffer); - interface_send(reply, sizeof(reply)); + reply[1] = s88_out_index; + for(i=0; i