     while(!writeQueue.isEmpty() && !error) {
         Message msg = writeQueue.pop();
 	if (msg.dispatch) {
-	    error = !sendMessage(msg, busses[msg.busId - 1]);
+	    error = !sendMessage(msg, &busses[msg.busId - 1]);
             // When TX Failure, add back to queue
             if (error) writeQueue.push(msg);
         }

/*
*  Load CAN Controller buffer and set send flag
*/
bool sendMessage( Message msg, CANBus bus )
{
    int ch = bus.getNextTxBuffer();
    if (ch < 0 || ch > 2) return false; // All TX buffers full

    digitalWrite(BOOT_LED, HIGH);
    bus.loadFullFrame(ch, msg.length, msg.frame_id, msg.frame_data );
    bus.transmitBuffer(ch);
    digitalWrite(BOOT_LED, LOW );

    return true;

#define WRITE_BUFFER_SIZE 10


CANBus busses[] = {
    CANBus(CAN1SELECT, CAN1RESET, 1, "Bus 1"),
    CANBus(CAN2SELECT, CAN2RESET, 2, "Bus 2"),
    CANBus(CAN3SELECT, CAN3RESET, 3, "Bus 3")
};

#include "Middleware.h"
#include "Settings.h"
