forked from peterh/pyobd
-
Notifications
You must be signed in to change notification settings - Fork 136
/
obd_utils.py
executable file
·32 lines (30 loc) · 941 Bytes
/
obd_utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import serial
import platform
def scanSerial():
"""scan for available ports. return a list of serial names"""
available = []
# Enable Bluetooh connection
for i in range(10):
try:
s = serial.Serial("/dev/rfcomm"+str(i))
available.append( (str(s.port)))
s.close() # explicit close 'cause of delayed GC in java
except serial.SerialException:
pass
# Enable USB connection
for i in range(256):
try:
s = serial.Serial("/dev/ttyUSB"+str(i))
available.append(s.portstr)
s.close() # explicit close 'cause of delayed GC in java
except serial.SerialException:
pass
# Enable obdsim
#for i in range(256):
#try: #scan Simulator
#s = serial.Serial("/dev/pts/"+str(i))
#available.append(s.portstr)
#s.close() # explicit close 'cause of delayed GC in java
#except serial.SerialException:
#pass
return available