Skip to content

Commit

Permalink
made some parameters named only to avoid confusion
Browse files Browse the repository at this point in the history
  • Loading branch information
lobis committed Feb 21, 2024
1 parent a3c6f85 commit 9bbc404
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion examples/vsr53dl.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
log.setLevel(logging.INFO)
sensor_address = 1

with VSR53DL(dev_tty, sensor_address) as vacuum_sense:
with VSR53DL(dev_tty, address=sensor_address) as vacuum_sense:
vacuum_sense.get_device_type()
vacuum_sense.get_product_name()
vacuum_sense.get_serial_number_device()
Expand Down
2 changes: 1 addition & 1 deletion examples/vsr53usb.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
log.setLevel(logging.INFO)
sensor_address = 1

with VSR53USB(dev_tty, sensor_address) as vacuum_sense:
with VSR53USB(dev_tty, address=sensor_address) as vacuum_sense:
vacuum_sense.get_device_type()
vacuum_sense.get_product_name()
vacuum_sense.get_serial_number_device()
Expand Down
2 changes: 1 addition & 1 deletion src/vsr53/sys.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
if platform.system() == "Darwin":
dev_tty = "/dev/cu.usbserial-FT4VOTGK"
elif platform.system() == "Windows":
dev_tty = "COM6"
dev_tty = "COM5"
elif platform.system() == "Linux":
dev_tty = "/dev/ttyUSB0"
15 changes: 8 additions & 7 deletions src/vsr53/vsr53.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,14 +374,15 @@ class VSR53DL(VSR53):
Thyracont's VSR53DL vacuum sensor RS458 interface
"""

def __init__(self, device_label: str, address: int = 1, baudrate: int = 115200):
def __init__(self, port: str, *, address: int = 1, baudrate: int = 9600):
"""
Constructor will initiate serial port communication in rs485 mode and define address for device
:param device_label: Device label assigned by the operating system when the device is connected
Constructor will initiate serial port communication in rs485 mode and define address for device.
:param port: device label assigned by the operating system when the device is connected
:param address: Defined by the address switch mounted in the device from 1 to 16
:param baudrate: Baud rate for data transmission
"""
self._port = serial.rs485.RS485(
device_label,
port,
baudrate=baudrate,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
Expand All @@ -394,9 +395,9 @@ def __init__(self, device_label: str, address: int = 1, baudrate: int = 115200):


class VSR53USB(VSR53):
def __init__(self, device_label: str, address: int = 1, baudrate: int = 9600):
def __init__(self, port: str, *, address: int = 1, baudrate: int = 9600):
self._port = serial.Serial(
device_label,
port,
baudrate=baudrate,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
Expand All @@ -414,7 +415,7 @@ def __init__(self, device_label: str, address: int = 1, baudrate: int = 9600):
log.setLevel(logging.INFO)

sensor_address = 1
vacuum_sense = VSR53DL(dev_tty, sensor_address)
vacuum_sense = VSR53DL(dev_tty, address=sensor_address)
vacuum_sense.open_communication()

vacuum_sense.get_device_type()
Expand Down
2 changes: 1 addition & 1 deletion test/test_stress.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def stress_test():
from vsr53.sys import dev_tty

sensor_address = 1
vacuum_sense = VSR53DL(dev_tty, sensor_address)
vacuum_sense = VSR53DL(dev_tty, address=sensor_address)
vacuum_sense.open_communication()

filename = f"./results/Stress_test_results_{get_now_timestamp_str()}.csv"
Expand Down
2 changes: 1 addition & 1 deletion test/test_vsr53dl.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
@pytest.fixture()
def vacuum_sensor():
sensor_address = 1
vacuum_sense = VSR53DL(dev_tty, sensor_address)
vacuum_sense = VSR53DL(dev_tty, address=sensor_address)
vacuum_sense.open_communication()
yield vacuum_sense
vacuum_sense.close_communication()
Expand Down
2 changes: 1 addition & 1 deletion test/test_vsr53usb.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@pytest.fixture()
def vacuum_sensor():
sensor_address = 1
vacuum_sense = VSR53USB(dev_tty, sensor_address)
vacuum_sense = VSR53USB(dev_tty, address=sensor_address)
vacuum_sense.open_communication()
yield vacuum_sense
vacuum_sense.close_communication()
Expand Down

0 comments on commit 9bbc404

Please sign in to comment.