Skip to content

Commit bc9f157

Browse files
committed
serial: update unit ID range to 0-31
1 parent 3057818 commit bc9f157

2 files changed

Lines changed: 9 additions & 14 deletions

File tree

absscpi/client.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ def open_serial(self, port: str, device_id: int):
288288
289289
Args:
290290
port: Serial port, such as "COM1" or "/dev/ttyS1."
291-
device_id: Device's serial ID, 0-255, or 256+ to address all units
291+
device_id: Device's serial ID, 0-31, or 32+ to address all units
292292
on the bus.
293293
294294
Raises:
@@ -319,7 +319,7 @@ def set_target_device_id(self, device_id: int):
319319
Only applies to RS-485 connections.
320320
321321
Args:
322-
device_id: Target device ID, 0-255, or 256+ to broadcast to all
322+
device_id: Target device ID, 0-31, or 32+ to broadcast to all
323323
units on the bus.
324324
325325
Raises:
@@ -1517,22 +1517,17 @@ def serial_discovery(
15171517
self,
15181518
port: str,
15191519
first_id: int = 0,
1520-
last_id: int = 255,
1520+
last_id: int = 31,
15211521
) -> list[AbsSerialDiscoveryResult]:
15221522
"""Use RS-485 to discover ABSes on the bus.
15231523
15241524
This function requires that the ScpiClient *not* be connected over
15251525
serial! This will interfere with opening the serial port.
15261526
1527-
Since this function operates by scanning all serial IDs in a range, it
1528-
can take upwards of 15 seconds to scan the full address space. It's
1529-
therefore recommended to limit the address range to the range you expect
1530-
devices to be in.
1531-
15321527
Args:
15331528
port: Serial port to use, such as COM1 or /dev/ttyS0.
1534-
first_id: First serial ID to check, 0-255.
1535-
last_id: Last serial ID to check (inclusive), 0-255. Must not be
1529+
first_id: First serial ID to check, 0-31.
1530+
last_id: Last serial ID to check (inclusive), 0-31. Must not be
15361531
less than first_id.
15371532
15381533
Returns:
@@ -1541,7 +1536,7 @@ def serial_discovery(
15411536
Raises:
15421537
ScpiClientError: An error occurred during discovery.
15431538
"""
1544-
if last_id < 0 or last_id > 255 or first_id < 0 or first_id > 255:
1539+
if last_id < 0 or last_id > 31 or first_id < 0 or first_id > 31:
15451540
raise ValueError("invalid ID")
15461541
elif last_id < first_id:
15471542
raise ValueError("last ID cannot be less than first ID")

examples/serial_id.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ def serial_ids_demo(port: str, ids: list[int]):
1313
ids: List of serial IDs to talk to.
1414
"""
1515
with ScpiClient() as client:
16-
# first, let's send a message to all units by addressing 256
17-
# (any number greater than 255 will work)
18-
client.open_serial(port, 256)
16+
# first, let's send a message to all units by addressing 32
17+
# (any number greater than 31 will work)
18+
client.open_serial(port, 32)
1919

2020
# set cell 1 to 1.5V on every device
2121
client.set_cell_voltage(0, 1.5)

0 commit comments

Comments
 (0)