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.
- // 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[10];
+ uint8_t i;
+
- 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<count; ++i)
+ reply[2+i] = ringbuffer_pop(s88_buffer);
+ interface_send(reply, 2+count);
+ s88_out_index += count;