Packet Length and Timeout

 

Transmit buffer and packet size

When an XRF receives serial data it goes into the memory.  As soon as there is one complete packets worth of data, it is sent out over the radio transmitter.  By defualt the buffer size is 12 characters.  If you send out longer messages it will simply split it up in to smaller packets.  For example,

See the quick brown fox jump over the lazy dogs.

-----1-----|----2------|----3------|----4------|

this message is split in to  4 packets and each one is transmitted in turn.

 

The packet length can be adjusted using the ATPK command (see http://openmicros.org/index.php/articles/84-xrf-basics/114-xrf-at-command-reference for more info on using AT commands).  This can be a useful setting to change: e.g. if you use a messaging scheme that always uses 30 characters, you could set ATPK 1E  (30 is 1E hex). This would mean as soon as 30 chars are received they will be sent without waiting for a timeout, thereby sending the packets in the most efficient way.

Note that both the transmitting and receiving XRFs must have the same packet length set.

 

 

Timeouts

If the data being sent is less than a packet (or less than a multiple of the packet length) it will wait in the transmit buffer for a timeout period before being sent.  By default this is 100ms for XRFs up to V0.41.  If nothing more is received in this time, the buffer is sent "as is".  For example;

Mary had a little lamb

-----1-----|----2------|

The first packet will be sent as soon as the 'l' of little is received.  The 'ittle lamb' will wait in the buffer for 100ms before being sent.  If each character takes, for example, 1ms to send (* actual), the first packet will take 12ms to send, and the second one 110ms (122ms total).

 

The timeout can be adjusted using the ATRO command.  For example, issuing the ATRO 10 would set the timeout to 16ms (16 is 10 in hex).

 

 

Efficient Use of Packet Length and Timeout

Depending on what kind of data you are transmitting, tweaking the ATPK and ATRO values can give you improved performance. If your data is of variable length, you might get better performance by simply padding out your messages to fill the buffer.  For example;

 

Mary had a little lamb++

-----1-----|----2------|

Each packet would be sent straight away; so, again assuming 1ms per character, the total transmission time would be 24ms.

 

* The actual time to send each character depends on the baudrate and we need to add in the stop/start bits. At 9600bps (default) each char is 1.04ms, at 115Kbps each char is 0.0868ms.