First off in Figure 1 below displays the given start screen.
Figure 1 |
Figure 2 |
obdThread = Thread(target=self.write_to_UI(obdValue), args = (self,obdValue))
obdEvent = Event()Figure 3 and 4 below display the running program.
obdThread.start()
Figure 4 |
Figure 3 |
def write_to_UI(self,values):
"""Updates the UI with new values"""
# receive [speed, rpm, intake, coolant, load]
self.ui.lcdNumber_speed.display(values[0])
self.ui.lcdNumber_rpm.display(values[1])
self.ui.lcdNumber_inTemp.display(values[2])
self.ui.lcdNumber_coolTemp.display(values[3])
self.ui.lcdNumber_load.display(values[4])
QtGui.QApplication.processEvents() #Writes all pending changes to QT
return
The guts behind the scanning thread is all in pySerial. The code below show how the scanner obtains values from the OBDII sensor. This example is the speed however the method is the same for all.
First a serial port is connected, "rfcomm0" at a baud rate of "38400".
(I apologize for that long run on sentence I hope you were able to follow)
------------------------------------------------------------------------------------------------------------------------------
There you have it the basic functionality of pi2go and how it works. Any feedback will be outstanding!
As always if you would like to follow/keep up on this blog or check out github. I have many new features to add.
**For those that care written in Python2.7 utilizing pyQt4 over pySerial. Issue tracker
First a serial port is connected, "rfcomm0" at a baud rate of "38400".
self.serialIO = serial.Serial('/dev/rfcomm0', 38400, timeout=1)Then using the serialport you send send a hexadecimal PID which can be found here. In this case we send "01", "0D" and want a return "\r". ("01" stands for the current value, "0D" is speed.)
self.serialIO.write("01 0D \r")The above line will return a list of 1 string "['410D1D\r\r>']" not including quotes. The bold values are what is needed. They are a hexadecimal value so the code below first pulls the needed values by treating the string as a list. Then converts (Using the example) from a string, '1D', to hex value '0x1D' to an integer, base zero, 29 to a float 29.0 The final answer being in Kph
(I apologize for that long run on sentence I hope you were able to follow)
speed_list = self.serialIO.readline().split(' ')I then converted the value to Mph and returned it in a list with other values.
speed_hex = speed_list[0][4:6]
speed_float = float(int("0x"+speed_hex, 0))
speed_float = speed_float*0.621371 #Comment out if you would rather have KphThe last feature I added in this version is the ability to clear error codes. It is placed in the setting tab as depicted in Figure 5.
return speed_float
Figure 5 |
This tab will have more options evenly and will have feedback to the clearing function.
------------------------------------------------------------------------------------------------------------------------------
There you have it the basic functionality of pi2go and how it works. Any feedback will be outstanding!
As always if you would like to follow/keep up on this blog or check out github. I have many new features to add.
**For those that care written in Python2.7 utilizing pyQt4 over pySerial. Issue tracker
No comments:
Post a Comment