class OBDConnection(object):
    """
    Class for OBD connection. Use a thread for connection.
    """

    def __init__(self):
        self.obdCap = OBD_Capture()

    def get_capture(self):
        return self.obdCap

    # Start a thread to connect to available BT/USB serial port
    def connect(self):
        self.t = Thread(target=obd_connect, args=(self.obdCap,))
        self.t.start()

    def is_connected(self):
        return self.obdCap.is_connected()

    def get_output(self):
        if self.obdCap and self.obdCap.is_connected():
            return self.obdCap.capture_data()
        return ""

    def get_port(self):
        return self.obdCap.is_connected()

    def get_port_name(self):
        if self.obdCap:
            port = self.obdCap.is_connected()
            if port:
                try:
                    return port.port.name
                except:
                    pass
        return None

    def get_sensors(self):
        sensors = []
        if self.obdCap:
            sensors = self.obdCap.getSupportedSensorList()
        return sensors
Exemple #2
0
class OBDConnection(object):
    """
    Class for OBD connection. Use a thread for connection.
    """

    def __init__(self):
        print("Class " + type(self).__name__)
        self.obd_capture = OBD_Capture()

    def get_capture(self):
        return self.obd_capture

    def connect(self):
        self.thread = Thread(target=obd_connect, args=(self.obd_capture,))
        self.thread.start()

    def is_connected(self):
        return self.obd_capture.is_connected()

    def get_output(self):
        if self.obd_capture and self.obd_capture.is_connected():
            return self.obd_capture.capture_data()
        return ""

    def get_port(self):
        return self.obd_capture.is_connected()

    def get_port_name(self):
        if self.obd_capture:
            port = self.obd_capture.is_connected()
            if port:
                try:
                    return port.port.name
                except:
                    pass
        return None

    def get_sensors(self):
        sensors = []
        if self.obd_capture:
            sensors = self.obd_capture.getSupportedSensorList()
        return sensors
Exemple #3
0
class OBDConnection(object):
    """
    Class for OBD connection. Use a thread for connection.
    """
    
    def __init__(self):
        self.c = OBD_Capture()

    def get_capture(self):
        return self.c

    def connect(self):
        self.t = Thread(target=obd_connect, args=(self.c,))
        self.t.start()

    def is_connected(self):
        return self.c.is_connected()

    def get_output(self):
        if self.c and self.c.is_connected():
            return self.c.capture_data()
        return ""

    def get_port(self):
        return self.c.is_connected()

    def get_port_name(self):
        if self.c:
            port = self.c.is_connected()
            if port:
                try:
                    return port.PortName
                except:
                    pass
        return None
    
    def get_sensors(self):
        sensors = []
        if self.c:
            sensors = self.c.getSupportedSensorList()
        return sensors
Exemple #4
0
from obd_capture import OBD_Capture

cap = OBD_Capture()
cap.connect()
obddata = cap.capture_data()
print(obddata)