Exemplo n.º 1
0
	def connect(self):
		dot = 0
		while self.port is None:
			portnames = scanSerial()
			self.showdisconnected()
			#if dot == 0:
			#	self.labels_collection['connecting'].setText('Connecting')
			#elif dot == 1 :
			#	self.labels_collection['connecting'].setText('Connecting.')
			#elif dot == 2:
			#	self.labels_collection['connecting'].setText('Connecting..')
			#else:
			#	self.labels_collection['connecting'].setText('Connecting...')
			time.sleep(.1)
			
			for port in portnames:
				self.port = obd_io.OBDPort(port, None, 2, 2)
				if(self.port.State == 0):
					self.port.close()
					self.port = None
				else:
					print 'Connected!'
					self.showconnected()
					break
			dot = dot+1 if dot<4 else 0
Exemplo n.º 2
0
    def connect(self):
        portnames = scanSerial()
        #portnames = ['COM10']
        print portnames
        for port in portnames:
            self.port = obd_io.OBDPort(port, None, 2, 2)
            if (self.port.State == 0):
                self.port.close()
                self.port = None
            else:
                localtime = datetime.now()
                current_time = str(localtime.hour) + ":" + str(
                    localtime.minute) + ":" + str(
                        localtime.second) + "." + str(localtime.microsecond)
                log_string = current_time
                logtime = "Time:" + str(
                    current_time) + "\t" + "The OBD Not connected"
                logtimenotcon = '/home/pi/Desktop/pyobd-pi/Score/' + "car-" + str(
                    localtime.hour) + ":" + str(localtime.minute) + ":" + str(
                        localtime.second) + ".log"
                logtime_file = open(logtimenotcon, "w", 128)
                logtime_file.write(logtime + "\n")
                break

        if (self.port):
            print "Connected to " + self.port.port.name
Exemplo n.º 3
0
    def connect(self):
        portnames = scanSerial()

        for port in portnames:
            self.port = obd_io.OBDPort(port, None, 2, 2)
            if(self.port.State == 0):
                self.port.close()
                self.port = None
            else:
                break
Exemplo n.º 4
0
	def connect(self):
		self.port = None
		port_names = scanSerial()
		port_names = ['/dev/tty.OBDII-Port','/dev/cu.OBDII_Port'] 
		for port in port_names:
			self.port = OBDPort(port, None, 2, 2)
			if self.port.State == 0:
				self.port.close()
				self.port = None  # no open ports close
			else:
				break  # break with connection
		if self.port:
			print "Connected "
Exemplo n.º 5
0
    def connect(self):
        port_names = scanSerial()  # Check all serial ports.
        print port_names  # print available ports
        for port in port_names:
            self.port = obd_io.OBDPort(port, None, 2, 2)
            if self.port.State == 0:
                self.port.close()
                self.port = None  # no open ports close
            else:
                break  # break with connection

        if self.port:
            print "Connected "
Exemplo n.º 6
0
    def connect(self):
        portnames = scanSerial()
        print portnames
        for port in portnames:
            self.port = obd_io.OBDPort(port, None, 2, 2)
            if(self.port.State == 0):
                self.port.close()
                self.port = None
            else:
                break

        if(self.port):
            print "Connected to "+self.port.port.name
Exemplo n.º 7
0
    def connect(self):
        portnames = scanSerial()
#	print "Available ports: " + portnames
        for port in portnames:
            self.port = obd_io.OBDPort(port, None, 2, 2)
            if(self.port.State == 0):
                self.port.close()
                self.port = None
            else:
                break

        if(self.port):
            print "Connected to OBD sensor on " + self.port.port.name
Exemplo n.º 8
0
    def connect(self):
        portnames = scanSerial()
        print portnames
        for port in portnames:
            self.port = obd_io.OBDPort(port, None, 2, 2)
            if(self.port.State == 0):
                self.port.close()
                self.port = None
            else:
                break

        if(self.port):
            print "Connected to "+self.port.port.name
    def connect(self):
        port_names = scanSerial()  # Check all serial ports.
        print port_names  # print available ports
        for port in port_names:
            self.port = obd_io.OBDPort(port, None, 2, 2)
            if self.port.State == 0:
                self.port.close()
                self.port = None  # no open ports close
            else:
                break  # break with connection

        if self.port:
            print "Connected "
Exemplo n.º 10
0
    def connect(self):
        """Try to connect to serial ports"""
        portnames = scanSerial()
        WriteToLog(portnames)
        for port in portnames:
            self.port = obd_io.OBDPort(port, None, 2, 2)
            if (self.port.State == 0):
                self.port.close()
                self.port = None
            else:
                break

        if (self.port):
            WriteToLog("Connected to " + self.port.port.name)
Exemplo n.º 11
0
    def connect(self):  # connects to ports for desired log items
        portnames = scanSerial()
        #portnames = ['COM10']gp
        print portnames
        for port in portnames:
            self.port = obd_io.OBDPort(port, None, 2, 2)
            if(self.port.State == 0):  #
                self.port.close()
                self.port = None
            else:
                break

        if(self.port):
            print "Connected to "+self.port.port.name
Exemplo n.º 12
0
    def connect(self):
        portnames = scanSerial()
        #portnames = ['COM10']
        print(portnames)
        for port in portnames:
            self.port = obd_io3.OBDPort(port, None, 2, 2)
            if(self.port.State == 0):
                self.port.close()
                self.port = None
            else:
                break

        if(self.port):
            print("Connected to OBD"+self.port.port.name)
Exemplo n.º 13
0
    def connect(self):  #여기부터 시작인듯
        portnames = scanSerial()  #사용 가능한 포트를 알아온다
        #portnames = ['COM10']
        print portnames
        for port in portnames:  #포트가 사용 가능한지 보고
            self.port = obd_io.OBDPort(port, None, 2, 2)
            if (self.port.State == 0):
                self.port.close()
                self.port = None
            else:  #사용가능하면 break
                break

        if (self.port):  #사용가능한 포트를 얻었으면 출력을 한번 한다.
            print "Connected to " + self.port.port.name
Exemplo n.º 14
0
	def connect(self):
		port_names = scanSerial()   #  if this breaks, use a different
		port_names = ['/dev/tty.OBDII-Port','/dev/cu.OBDII_Port'] #scanSerial()  # Check all serial ports.
		print port_names  # print available ports
		for port in port_names:
			self.port = obd_io.OBDPort(port, None, 2, 2)
			if self.port.State == 0:
				self.port.close()
				self.port = None  # no open ports close
			else:
				break  # break with connection

		if self.port:
			print "Connected "
Exemplo n.º 15
0
    def connect(self):
        port_names = scanSerial()  #  if this breaks, use a different
        port_names = ['/dev/tty.OBDII-Port', '/dev/cu.OBDII_Port'
                      ]  #scanSerial()  # Check all serial ports.
        print port_names  # print available ports
        for port in port_names:
            self.port = obd_io.OBDPort(port, None, 2, 2)
            if self.port.State == 0:
                self.port.close()
                self.port = None  # no open ports close
            else:
                break  # break with connection

        if self.port:
            print "Connected "
Exemplo n.º 16
0
    def connect(self):
        status_led("Loading", True)
        port_names = scanSerial()  # Check all serial ports.
        print(port_names)  # print available ports
        for port in port_names:
            self.port = obd_io.OBDPort(port, None, 2, 2)
            if self.port.State == 0:
                self.port.close()
                self.port = None  # no open ports close
            else:
                break  # break with connection

        if self.port:
            print("Connected ")
        status_led("Loading", False)
Exemplo n.º 17
0
    def connect(self):# Check all serial ports.
        portnames = scanSerial()# print available ports
        print portnames
        for port in portnames:
            self.port = obd_io.OBDPort(port, None, 2, 2)
            if (self.port.State == 0):
                self.port.close()
                self.port = None # no open ports close

            else:
                break # break with connection

        if (self.port):
            self.lcd.clear()
            self.lcd.message("Connected")
            print "Connected"
Exemplo n.º 18
0
 def connect(self):
     # Collect the list of all the open serial ports
     portnames = scanSerial()
     print portnames
     # Loop through the list of port names
     for port in portnames:
         # Create instance of OBDPort
         self.port = obd_io.OBDPort(port, None, 2, 2)
         # Verify that the serial port is connected
         if(self.port.State == 0):
             # If the serial port is not connected, close the port
             self.port.close()
             self.port = None
         # Else the serial port is connected break from the loop
         else:
             break
     # Verify the serial port is connected
     if(self.port):
         print "Connected to "+self.port.port.name
Exemplo n.º 19
0
    def connect(self):
        """
            Check all serial ports, print availible ports,
            close on no open ports.
        """
        port_names = scanSerial()
        print(port_names)
        for port in port_names:
            self.port = obd_io.OBDPort(port, None, 2, 2)
            if self.port.State == 0:
                self.port.close()
                self.port = None  # No open ports close
            else:
                break  # Break with connection

        if self.port:
            print("Connected")
            self.lcd_update("Connected", False)
        else:
            print("Not Connected")
            self.connection_error("Not connected")
Exemplo n.º 20
0
    def connect(self):
        """
            Check all serial ports, print availible ports,
            close on no open ports.
        """
        port_names = scanSerial()
        print(port_names)
        for port in port_names:
            self.port = obd_io.OBDPort(port, None, 2, 2)
            if self.port.State == 0:
                self.port.close()
                self.port = None  # No open ports close
            else:
                break  # Break with connection

        if self.port:
            print("Connected")
            self.lcd_update("Connected", False)
        else:
            print("Not Connected")
            self.connection_error("Not connected")
Exemplo n.º 21
0
    def scan_ports():
        ports = []
        ports.extend(scanSerial())
        ports.extend(scanBluetooth())

        return ports
Exemplo n.º 22
0
    def Configure(self, e=None):
        id = 0
        diag = wx.Dialog(self.frame, id, title="Configure")
        sizer = wx.BoxSizer(wx.VERTICAL)

        ports = scanSerial()
        rb = wx.RadioBox(diag,
                         id,
                         "Choose Serial Port",
                         choices=ports,
                         style=wx.RA_SPECIFY_COLS,
                         majorDimension=2)

        sizer.Add(rb, 0)

        #timeOut input control
        timeoutPanel = wx.Panel(diag, -1)
        timeoutCtrl = wx.TextCtrl(timeoutPanel,
                                  -1,
                                  '',
                                  pos=(140, 0),
                                  size=(35, 25))
        timeoutStatic = wx.StaticText(timeoutPanel,
                                      -1,
                                      'Timeout:',
                                      pos=(3, 5),
                                      size=(140, 20))
        timeoutCtrl.SetValue(str(self.SERTIMEOUT))

        #reconnect attempt input control
        reconnectPanel = wx.Panel(diag, -1)
        reconnectCtrl = wx.TextCtrl(reconnectPanel,
                                    -1,
                                    '',
                                    pos=(140, 0),
                                    size=(35, 25))
        reconnectStatic = wx.StaticText(reconnectPanel,
                                        -1,
                                        'Reconnect attempts:',
                                        pos=(3, 5),
                                        size=(140, 20))
        reconnectCtrl.SetValue(str(self.RECONNATTEMPTS))

        #web open link button
        self.OpenLinkButton = wx.Button(
            diag, -1, "Click here to order ELM-USB interface", size=(260, 30))
        diag.Bind(wx.EVT_BUTTON, self.OnHelpOrder, self.OpenLinkButton)

        #set actual serial port choice
        if (self.COMPORT != 0) and (self.COMPORT in ports):
            rb.SetSelection(ports.index(self.COMPORT))

        sizer.Add(self.OpenLinkButton)
        sizer.Add(timeoutPanel, 0)
        sizer.Add(reconnectPanel, 0)

        box = wx.BoxSizer(wx.HORIZONTAL)
        box.Add(wx.Button(diag, wx.ID_OK), 0)
        box.Add(wx.Button(diag, wx.ID_CANCEL), 1)

        sizer.Add(box, 0)
        diag.SetSizer(sizer)
        diag.SetAutoLayout(True)
        sizer.Fit(diag)
        r = diag.ShowModal()
        if r == wx.ID_OK:

            #create section
            if self.config.sections() == []:
                self.config.add_section("pyOBD")
            #set and save COMPORT
            self.COMPORT = ports[rb.GetSelection()]
            self.config.set("pyOBD", "COMPORT", self.COMPORT)

            #set and save SERTIMEOUT
            self.SERTIMEOUT = int(timeoutCtrl.GetValue())
            self.config.set("pyOBD", "SERTIMEOUT", self.SERTIMEOUT)
            self.status.SetStringItem(3, 1, self.COMPORT)

            #set and save RECONNATTEMPTS
            self.RECONNATTEMPTS = int(reconnectCtrl.GetValue())
            self.config.set("pyOBD", "RECONNATTEMPTS", self.RECONNATTEMPTS)

            #write configuration to cfg file
            self.config.write(open(self.configfilepath, 'wb'))
Exemplo n.º 23
0
    def Configure(self,e = None):
        id = 0
        diag = wx.Dialog(self.frame, id, title="Configure")
        sizer = wx.BoxSizer(wx.VERTICAL)
        
        ports = scanSerial()
        rb = wx.RadioBox(diag, id, "Choose Serial Port",
                        choices = ports, style = wx.RA_SPECIFY_COLS,
                        majorDimension = 2)
                        
        sizer.Add(rb, 0)

        #timeOut input control                
        timeoutPanel = wx.Panel(diag, -1)
        timeoutCtrl = wx.TextCtrl(timeoutPanel, -1, '',pos=(140,0), size=(35, 25))
        timeoutStatic = wx.StaticText(timeoutPanel,-1,'Timeout:',pos=(3,5),size=(140,20))
        timeoutCtrl.SetValue(str(self.SERTIMEOUT))
        
        #reconnect attempt input control                
        reconnectPanel = wx.Panel(diag, -1)
        reconnectCtrl = wx.TextCtrl(reconnectPanel, -1, '',pos=(140,0), size=(35, 25))
        reconnectStatic = wx.StaticText(reconnectPanel,-1,'Reconnect attempts:',pos=(3,5),size=(140,20))
        reconnectCtrl.SetValue(str(self.RECONNATTEMPTS))
        
        #web open link button
        self.OpenLinkButton = wx.Button(diag,-1,"Click here to order ELM-USB interface",size=(260,30))
        diag.Bind(wx.EVT_BUTTON,self.OnHelpOrder,self.OpenLinkButton)
        
        #set actual serial port choice
        if (self.COMPORT != 0) and (self.COMPORT in ports):
          rb.SetSelection(ports.index(self.COMPORT))
        
        
        sizer.Add(self.OpenLinkButton)
        sizer.Add(timeoutPanel,0)
        sizer.Add(reconnectPanel,0)
        
        box  = wx.BoxSizer(wx.HORIZONTAL)
        box.Add(wx.Button(diag,wx.ID_OK),0)
        box.Add(wx.Button(diag,wx.ID_CANCEL),1)

        sizer.Add(box, 0)
        diag.SetSizer(sizer)
        diag.SetAutoLayout(True)
        sizer.Fit(diag)
        r  = diag.ShowModal()
        if r == wx.ID_OK:
            
            #create section
            if self.config.sections()==[]:
              self.config.add_section("pyOBD")
            #set and save COMPORT
            self.COMPORT = ports[rb.GetSelection()]
            self.config.set("pyOBD","COMPORT",self.COMPORT) 
            
            #set and save SERTIMEOUT
            self.SERTIMEOUT = int(timeoutCtrl.GetValue())
            self.config.set("pyOBD","SERTIMEOUT",self.SERTIMEOUT)
            self.status.SetStringItem(3,1,self.COMPORT); 
            
            #set and save RECONNATTEMPTS
            self.RECONNATTEMPTS = int(reconnectCtrl.GetValue())
            self.config.set("pyOBD","RECONNATTEMPTS",self.RECONNATTEMPTS)
            
            #write configuration to cfg file
            self.config.write(open(self.configfilepath, 'wb'))
Exemplo n.º 24
0
from threading import Thread

from obd_capture import OBD_Capture
from obd_sensors import SENSORS
from obd_sensors import *
from obd_io import OBDPort
from render import Render

from obd_utils import scanSerial

import signal
import time
import sys

obd = None
portnames = scanSerial()
for port in portnames:
    obd = OBDPort(port, None, 2, 2)
    if (obd.State == 0):
        obd.close()
        obd.port = None
    else:
        break

RPM = 12
SPEED = 13
#MPG = 2
TEMP = 5

rpm_screen = Render(1)
speed_screen = Render(3)