class CANSerialConnection:
    def __init__(self, serial, debugAllControls):
        self.serial = serial
        self.canMonitor = None
        self.debugAllControls = debugAllControls

    def connectToCar(self, canCar):
        self.canMonitor = CANBusMonitor(CANBus(self.serial))
        self.canMonitor.setup()
        self.canMonitor.startCANMonitor(canCar.getSenders(self.debugAllControls), canCar.processMessage)
        return canCar

    def destroy(self):
        if self.canMonitor:
            self.canMonitor.destroy()
        if self.serial:
            self.serial.close()
            print "Serial connection closed"
 def connectToCar(self, canCar):
     self.canMonitor = CANBusMonitor(CANBus(self.serial))
     self.canMonitor.setup()
     self.canMonitor.startCANMonitor(canCar.getSenders(self.debugAllControls), canCar.processMessage)
     return canCar