TMI: Here's the rest of the code in my arduino script, which I omitted above for the sake of brevity.
#define BUFFERLEN 4
byte bufferLen = 0;
byte buffer[BUFFERLEN];
void pushBuffer(byte data){
buffer[bufferLen++] = data;
}
void clearBuffer(){
for (byte i=0; i < BUFFERLEN; i++)
buffer[i] = 0;
bufferLen = 0;
}