Example #1
0
    def connect(self):
        portnames = scan_serial()
        #portnames = ['COM8']
        print portnames
        for port in portnames:
            self.port = pyobdlib.io.OBDDevice(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
Example #2
0
    def connect(self):
        portnames = scan_serial()
		#portnames = ['COM6']
        print portnames
        for port in portnames:
            self.port = pyobdlib.io.OBDDevice(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
Example #3
0
    def connect(self, portname = None):
        if portname is None:
            # Scan ports and try connecting
            portnames = scan_serial()
            print portnames
            for port in portnames:
                self.port = pyobdlib.io.OBDPort(port, None, 2, 2)
                if(self.port.state == 0):
                    self.port.close()
                    self.port = None
                else:
                    break
        else:
            # Connect to the specified port
            self.port = pyobdlib.io.OBDDevice(portname, None, 2, 2)
            if(self.port.state == 0):
                self.port.close()
                self.port = None

        if(self.port):
            print "Connected to "+self.port.port.name
Example #4
0
    def Configure(self,e = None):
        id = 0
        diag = wx.Dialog(self.frame, id, title="Configure")
        sizer = wx.BoxSizer(wx.VERTICAL)
        
        ports = scan_serial()
        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'))
Example #5
0
    def Configure(self, e=None):
        id = 0
        diag = wx.Dialog(self.frame, id, title="Configure")
        sizer = wx.BoxSizer(wx.VERTICAL)

        ports = scan_serial()
        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'))