Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions obd_capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ def __init__(self):
localtime = time.localtime(time.time())

def connect(self):
portnames = scanSerial()
#portnames = scanSerial()
portnames = ['/dev/ttyUSB0']
print portnames
for port in portnames:
self.port = obd_io.OBDPort(port, None, 2, 2)
Expand All @@ -41,12 +42,14 @@ def capture_data(self):
self.unsupportedSensorList = []

# loop through PIDs binary
for i in range(0, len(self.supp)):
#for i in range(0, len(self.supp)):
for i in range(0, min(len(self.supp), len(obd_sensors.SENSORS)-1)):
if self.supp[i] == "1":
# store index of sensor and sensor object
self.supportedSensorList.append([i+1, obd_sensors.SENSORS[i+1]])
else:
self.unsupportedSensorList.append([i+1, obd_sensors.SENSORS[i+1]])
pass

for supportedSensor in self.supportedSensorList:
print "supported sensor index = " + str(supportedSensor[0]) + " " + str(supportedSensor[1].shortname)
Expand All @@ -69,12 +72,15 @@ def capture_data(self):
log_string += name + " = " + str(value) + " " + str(unit) + "\n"

print log_string,
f.write(log_string)
time.sleep(0.5)

except KeyboardInterrupt:
self.port.close()
print("stopped")

f = open("/home/drive/data/obd", "a")

if __name__ == "__main__":

o = OBD_Capture()
Expand Down
2 changes: 1 addition & 1 deletion obd_recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def calculate_gear(self, rpm, speed):


logitems = ["rpm", "speed", "throttle_pos", "load"]
o = OBD_Recorder('/home/pi/logs/', logitems)
o = OBD_Recorder('/home/drive/logs/', logitems)
o.connect()
if not o.is_connected():
print "Not connected"
Expand Down
2 changes: 1 addition & 1 deletion pyobd
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ class MyApp(wx.App):
else:
self.configfilepath=os.environ['HOME']+'/.pyobdrc'
if self.config.read(self.configfilepath)==[]:
self.COMPORT="/dev/ttyACM0"
self.COMPORT="/dev/ttyUSB0"
self.RECONNATTEMPTS=5
self.SERTIMEOUT=2
else:
Expand Down