Skip to content

Commit

Permalink
Move request acknowledge to connection settings
Browse files Browse the repository at this point in the history
  • Loading branch information
alengwenus committed Sep 11, 2024
1 parent d25ad8d commit c640c17
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 3 additions & 1 deletion pypck/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,9 @@ def get_module_conn(
addr = LcnAddr(self.local_seg_id, addr.addr_id, addr.is_group)
address_conn = self.address_conns.get(addr, None)
if address_conn is None:
address_conn = ModuleConnection(self, addr)
address_conn = ModuleConnection(
self, addr, wants_ack=self.settings["ACKNOWLEDGE"]
)
if request_serials:
self.task_registry.create_task(address_conn.request_serials())
self.address_conns[addr] = address_conn
Expand Down
1 change: 1 addition & 0 deletions pypck/lcn_defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1386,6 +1386,7 @@ class AccessControlPeriphery(Enum):
# failed-state.
"SK_NUM_TRIES": 3, # Total number of segment coupler scan tries
"DIM_MODE": OutputPortDimMode.STEPS50,
"ACKNOWLEDGE": True, # modules request an acknowledge command
"PING_TIMEOUT": 600000, # The default timeout for pings sent to PCHK.
"DEFAULT_TIMEOUT_MSEC": 3500, # Default timeout for send command retries
"MAX_STATUS_EVENTBASED_VALUEAGE_MSEC": 600000, # Poll interval for
Expand Down
9 changes: 4 additions & 5 deletions pypck/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -751,10 +751,13 @@ def __init__(
activate_status_requests: bool = False,
has_s0_enabled: bool = False,
software_serial: int | None = None,
wants_ack: bool = True,
):
"""Construct ModuleConnection instance."""
assert not addr.is_group
super().__init__(conn, addr, software_serial=software_serial, wants_ack=True)
super().__init__(
conn, addr, software_serial=software_serial, wants_ack=wants_ack
)
self.activate_status_requests = activate_status_requests
self.has_s0_enabled = has_s0_enabled

Expand Down Expand Up @@ -796,10 +799,6 @@ def __init__(
if self.activate_status_requests:
self.task_registry.create_task(self.activate_status_request_handlers())

def set_wants_ack(self, wants_ack: bool) -> None:
"""Set request acknowledgement."""
self.wants_ack = wants_ack

async def send_command(self, wants_ack: bool, pck: str | bytes) -> bool:
"""Send a command to the module represented by this class.
Expand Down

0 comments on commit c640c17

Please sign in to comment.