def initCommunication(self): self.port = obd_io.OBDPort(self.portName, self._notify_window, self.SERTIMEOUT, self.RECONNATTEMPTS) if self.port.State == 0: #Cant open serial port return None self.active = [] self.supp = self.port.sensor(0)[1] #read supported PIDS self.active.append(1) #PID 0 is always supported wx.PostEvent(self._notify_window, ResultEvent([0, 0, "X"])) wx.PostEvent(self._notify_window, DebugEvent([1, "Communication initialized..."])) for i in range(1, len(self.supp)): if self.supp[i - 1] == "1": #put X in coloum if PID is supported self.active.append(1) wx.PostEvent(self._notify_window, ResultEvent([i, 0, "X"])) else: self.active.append(0) wx.PostEvent(self._notify_window, ResultEvent([i, 0, ""])) return "OK"
def connect(self): try: '----------------verbindung obd to serial-------------' port_status = "OBD_not" value_obd = bluethooth_obd_connect.connect_bluetooth_obd() port_status = "OBD_open" print value_obd port_no = value_obd[0] """while port_no=="error_bluethooth_obd": port_no=bluethooth_obd_connect.connect_bluetooth_obd() """ '-------------------------------------------------------' port = "/dev/rfcomm" + str(port_no) self.port = obd_io.OBDPort(port, None, 2, 2) port_status = "port_open" if (self.port): print "Connected to " + self.port.port.name except: if port_status == "port_open": print "error bluetooth connection_1" self.port.close() self.port = None elif port_status == "OBD_open": print "error bluetooth connection_2" elif port_status == "OBD_not": print "error bluetooth connection_3"
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
def open_port(self, scr): port = 0 try: self.port = obd_io.OBDPort(port) except "PortFailed": self.port = None self.popup("Could not open port %d" % port, scr) else: self.sensorqueue = self.sensorProducer(self.port)
def openport(self): try: self.port = obd_io.OBDPort(self.options.port) self.sensorReader = obd_io.sensorReader(self.port) self.sensorReader.start() self.sensorReader.refresh() self.sensorresults = {} self.infolines = ['port opened'] except Exception as e: raise (e) self.infolines = ['port open failed ...']
def OpenPort(self, e): print "OpenPort called" self.port = obd_io.OBDPort(self.COMPORT) if self.senprod: # signal current producers to finish self.senprod.stop() self.senprod = self.sensorProducer(self.port, self.sensors) self.sensthread = threading.Thread(None, self.senprod.start, None, ()) self.sensthread.start() self.sensor_control_on()
def connect(self): self.port = obd_io.OBDPort(self.portname, None, 2, 2) if self.port.State == 0: self.port.close() self.port = None else: # ARGUABLE try: print self.port.get_dtc() except: pass
def connect(self): portnames = self.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): portnames = ['/dev/ttyUSB0'] 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 "
def connect(self, port): self.port = obd_io.OBDPort(port, None, 2, 2) if (self.port.State == 0): # Failed to connect. self.port.close() self.port = None else: break if (self.port): print(("Connected to " + self.port.PortName)) return True return False
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 if self.port: print("Connected to " + self.port.port.name)
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
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)
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
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 "
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)
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")
def Prepare_ObdRead(): global OBD_port, sensorlist OBD_port = None sensorlist = [] serialPort = '/dev/ttyUSB0' log_items = ["rpm", "speed", "throttle_pos", "load", "fuel_status"] #conecto el interfaz OBD_port = obd_io.OBDPort(serialPort, None, 2, 2) if (OBD_port.State == 0): OBD_port.close() OBD_port = None print "OBD Not connected" #anado los elementos a monitorizar print "HardCoded Sensor List: " for item in log_items: addSensor(item) if config['OBD2AutoDetect'] == 1: rescanSensorlist()
ID_CONFIG = 500 ID_CLEAR = 501 ID_GETC = 502 ID_RESET = 503 ID_LOOK = 504 ALL_ON = 505 ALL_OFF = 506 ID_DISCONNECT = 507 ID_HELP_ABOUT = 508 ID_HELP_VISIT = 509 ID_HELP_ORDER = 510 # call("sudo rfcomm connect /dev/rfcomm0 00:1D:A5:02:12:18 1",shell=True) # time.sleep(4) # Sleeping More Than Necessary, better to wait for shell response port = obd_io.OBDPort("/dev/rfcomm0", None, 5, 0) print("Consider Using A Window") def initCommunication(): #call("sudo rfcomm connect 0 00:1D:A5:00:0F:A1 &>/dev/null",shell=True) if port.State == 0: return None active = [] supp = port.sensor(0)[1] print("Comm initialized") print(active) print(supp) for i in range(1, len(supp)): if supp[i - 1] == "1": #put X in coloum if PID is supported
def connect(self): self.port = obd_io.OBDPort("/dev/rfcomm0", None, 2, 2) if (self.port): print "Connected to " + str(self.port)