Skip to content

Commit c3eb2f5

Browse files
author
Brendan Whitfield
committed
consistent naming convention for scan_serial()
1 parent cbd160d commit c3eb2f5

5 files changed

Lines changed: 16 additions & 11 deletions

File tree

‎docs/Connections.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
After installing the library, simply `import obd`, and create a new OBD connection object. By default, python-OBD will scan for Bluetooth and USB serial ports (in that order), and will pick the first connection it finds. The port can also be specified manually by passing a connection string to the OBD constructor. You can also use the scanSerial helper retrieve a list of connected ports.
2+
After installing the library, simply `import obd`, and create a new OBD connection object. By default, python-OBD will scan for Bluetooth and USB serial ports (in that order), and will pick the first connection it finds. The port can also be specified manually by passing a connection string to the OBD constructor. You can also use the `scan_serial` helper retrieve a list of connected ports.
33

44
```python
55
import obd
@@ -12,7 +12,7 @@ connection = obd.OBD("/dev/ttyUSB0") # create connection with USB 0
1212

1313
# OR
1414

15-
ports = obd.scanSerial() # return list of valid USB or RF ports
15+
ports = obd.scan_serial() # return list of valid USB or RF ports
1616
print ports # ['/dev/ttyUSB0', '/dev/ttyUSB1']
1717
connection = obd.OBD(ports[0]) # connect to the first port in the list
1818
```

‎docs/Troubleshooting.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,12 @@ This is likely a problem with the serial connection between the OBD-II adapter a
8080
- you are connecting to the right port in `/dev` (or that there is any port at all)
8181
- you have the correct permissions to write to the port
8282

83-
You can use the `scanSerial()` helper function to determine which ports are available for writing.
83+
You can use the `scan_serial()` helper function to determine which ports are available for writing.
8484

8585
```python
8686
import obd
8787

88-
ports = obd.scanSerial() # return list of valid USB or RF ports
88+
ports = obd.scan_serial() # return list of valid USB or RF ports
8989
print ports # ['/dev/ttyUSB0', '/dev/ttyUSB1']
9090
```
9191

‎obd/__init__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,5 @@
4343
from .OBDCommand import OBDCommand
4444
from .OBDResponse import OBDResponse, Unit
4545
from .protocols import ECU
46-
from .utils import scanSerial, OBDStatus
46+
from .utils import scan_serial, scanSerial, OBDStatus # TODO: scanSerial() deprecated
4747
from .debug import debug

‎obd/obd.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
from .elm327 import ELM327
3535
from .commands import commands
3636
from .OBDResponse import OBDResponse
37-
from .utils import scanSerial, OBDStatus
37+
from .utils import scan_serial, OBDStatus
3838
from .debug import debug
3939

4040

@@ -63,8 +63,8 @@ def __connect(self, portstr, baudrate, protocol):
6363
"""
6464

6565
if portstr is None:
66-
debug("Using scanSerial to select port")
67-
portnames = scanSerial()
66+
debug("Using scan_serial to select port")
67+
portnames = scan_serial()
6868
debug("Available ports: " + str(portnames))
6969

7070
if not portnames:
@@ -258,7 +258,7 @@ def __build_command_string(self, cmd):
258258
if self.fast and cmd.fast:
259259
cmd_string += str(len(self.port.ecus()))
260260

261-
# if we sent this last time, just send
261+
# if we sent this last time, just send
262262
if self.fast and (cmd_string == self.__last_command):
263263
cmd_string = ""
264264

‎obd/utils.py‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def try_port(portStr):
131131
return False
132132

133133

134-
def scanSerial():
134+
def scan_serial():
135135
"""scan for available ports. return a list of serial names"""
136136
available = []
137137

@@ -156,5 +156,10 @@ def scanSerial():
156156
for port in possible_ports:
157157
if try_port(port):
158158
available.append(port)
159-
159+
160160
return available
161+
162+
# TODO: deprecated, remove later
163+
def scanSerial():
164+
print("scanSerial() is deprecated, use scan_serial() instead")
165+
return scan_serial()

0 commit comments

Comments
 (0)