Library Help Please!

Hi all,

Does anyone have experience with the arduino-buffered-serial library. It allows you to send packets with check sum which is perfect for my application. However, I can only find very limited documentation on it. I am a novice so my confusion is probably silly, but hopefully it can be easily resolved. I understand the process of sending a packet I believe, but I don't understand how you would go about reading the contents of a received packet. Any insights would be greatly appreciated. Here is a link to the library: GitHub - siggiorn/arduino-buffered-serial: Automatically exported from

Thanks in advance for the help and patience,


but I don't understand how you would go about reading the contents of a received packet.

Received where? From what?

In setup() the example program has:


Further down they declare a handler function for arrived packets:

void handlePacket(ByteBuffer* packet){
     // Fetch data from the packet

It looks like you use packet.get() to read a byte. They have other 'get' functions corresponding to the various 'put' functions used for sending:

     packet.get(); // char
     packet.getInt();    // int
     packet.getLong(); // long int
     packet.getFloat(); // float

If they don't have 'unsigned' versions of the integer types you can cast the signed versions:

     (unsigned char) packet.get();               // char
     (unsigned int) packet.getInt();              // int
     (unsigned long int) packet.getLong();  // long int


Received where? From what?

The packets will be sent from another arduino using the same library. Right now the data is being sent via jumper cables connecting the rx and tx of the two boards. However, soon I will be attempting to use two xbees in AT mode to transmit the data.

Thanks! That is very helpful. So when I call say... packet.getInt(); , will it return the first valid int stored in the packet? How might I go about parsing and reading five pieces of data stored in a packet?

Thanks to you both for the replies!!


I think it assumes you know what order the fields are in the packet. If you call packet.getInt() I think it takes the next two bytes from the packet and returns them as an int. Because of that you might want to put a protocol version number at the beginning of your packets. That way if you decide to change the type, number, or order of data items in your packet you can detect the incompatibility. You can also make the new code backward compatible with the older protocol.

If you are not sending the same set of data every time you may want the packet to start with a packet type ID. That way the receiver can choose the right routine for interpreting the data.

Okay, that makes sense I believe. So if I wrote:

packet.getInt() = int variableOne;
packet.getInt() = int variableTwo;

it would set variableOne to the value of bytes 1 and 2 and variableTwo to the value of bytes 3 and 4(this is just a possible example)?

As of right now, my packets all have the same format, but if that changes I will add an ID.

Thanks for the assistance!


int variableOne = packet.getInt(); 
int variableTwo = packet.getInt();

Yeah except you might want to write it the right way round.