 }
 
 
-bool readMsgFromBuffer(CANBus bus, byte bufferId, byte rx_status)
+bool readMsgFromBuffer(CANBus * bus, byte bufferId, byte rx_status)
 {
     if (readQueue.isFull()) return false;
     Message msg;
     msg.busStatus = rx_status;
-    msg.busId = bus.busId;
+    msg.busId = bus->busId;
     msg.dispatch = false;
-    bus.readFullFrame(bufferId, &msg.length, msg.frame_data, &msg.frame_id );  
+    bus->readFullFrame(bufferId, &msg.length, msg.frame_data, &msg.frame_id );  
     return readQueue.push(msg);
 }

#define WRITE_BUFFER_SIZE 10


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

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

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