From: Mikko Rasa Date: Mon, 28 Oct 2013 20:20:28 +0000 (+0200) Subject: Send at least four S88 data octets per packets if possible X-Git-Url: http://git.tdb.fi/?p=model-railway-devices.git;a=commitdiff_plain;h=dfe51654709d752ac19ecfcca5d6d1f1e605ce52 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. --- 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