watlowlib.maintenance¶
Persistent-write helpers for one-shot device configuration:
change_baud, change_modbus_address, change_stdbus_address,
change_protocol_mode. All require confirm=True; protocol-mode flips
additionally gate on the SKU's comms-code support. See
Safety and Troubleshooting.
Public surface¶
watlowlib.maintenance ¶
Confirmed, port-level maintenance operations.
One-shot helpers that open a transport, perform a single confirmed
reconfiguration, verify the result, and close — for callers who do not
want to hold a live :class:~watlowlib.devices.controller.Controller
session. Off the normal :func:~watlowlib.open_device path; every
function here mutates persistent device state and refuses without
confirm=True.
Surfaces, per design doc §6:
- :func:
change_baud— write parameter 17002 (Modbus baud) with the enum encoding for the new rate, then reopen at the new baud and identify. - :func:
change_modbus_address— write parameter 17007 (Modbus address) and reopen at the new slave address. - :func:
change_stdbus_address— write parameter 17001 (Standard Bus address) and reopen at the new MS/TP MAC. - :func:
change_protocol_mode— write parameter 17009 (Protocol) with the wide-enum encoding for Standard Bus (1286) or Modbus (1057), then reopen at the new framing and identify.
All four return the post-change :class:DeviceInfo from the verify
pass. On verification failure the underlying transport is closed and
the helper re-raises the underlying error after logging a recovery
hint at WARNING — the device may require a power-cycle before the
new comm config takes effect on some firmware revisions.
change_baud
async
¶
change_baud(
port,
*,
target_baud,
current_protocol=ProtocolKind.MODBUS_RTU,
address=1,
serial_settings=None,
timeout=None,
confirm=False,
)
Open port, change the Modbus baud rate, reopen, identify.
Watlow PM exposes baud-rate configuration only on the Modbus side (parameter 17002). Std Bus baud is fixed at the factory default (38400) and is not maintenance-configurable from the host.
The host opens at current_protocol / serial_settings (the
current framing, before the change), writes the new code, closes,
waits _VERIFY_DELAY_S, then reopens at the new baud and
identifies. target_baud must be one of the keys in
:data:MODBUS_BAUD_CODES.
Returns:
| Type | Description |
|---|---|
DeviceInfo
|
The post-change :class: |
Raises:
| Type | Description |
|---|---|
WatlowConfirmationRequiredError
|
|
WatlowConfigurationError
|
|
Source code in src/watlowlib/maintenance.py
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 | |
change_modbus_address
async
¶
change_modbus_address(
port,
*,
target_address,
current_address=1,
serial_settings=None,
timeout=None,
confirm=False,
)
Open port over Modbus, write parameter 17007, reopen, identify.
Modbus slave addresses are 1..247.
Returns:
| Type | Description |
|---|---|
DeviceInfo
|
The post-change :class: |
Raises:
| Type | Description |
|---|---|
WatlowConfirmationRequiredError
|
|
WatlowConfigurationError
|
|
Source code in src/watlowlib/maintenance.py
change_protocol_mode
async
¶
change_protocol_mode(
port,
*,
target,
current_protocol=ProtocolKind.AUTO,
address=1,
serial_settings=None,
timeout=None,
confirm=False,
)
Open port, write parameter 17009 (Protocol), reopen, identify.
The on-wire encoding (per :data:PROTOCOL_MODE_CODES) is:
- :attr:
ProtocolKind.STDBUS->1286 - :attr:
ProtocolKind.MODBUS_RTU->1057
Before issuing the write, the helper opens the port on
current_protocol and runs :meth:Controller.identify. If the
captured part number's comms position-8 character indicates the
target protocol is not present in the SKU's hardware (e.g.
PM3R1CA-AAAAAAA is Std-Bus-only), the helper raises
:class:WatlowConfigurationError before the EEPROM write —
avoiding the silent-failure mode where 17009 persists but the
runtime stack never carries the new protocol.
The verify pass after the write opens at the target protocol's
factory framing (38400 8-N-1 for Std Bus, 9600 8-E-1 for Modbus
RTU) rather than inheriting the caller's pre-switch
serial_settings — without this substitution, a Std-Bus →
Modbus switch would try to talk Modbus at the Std-Bus 38400 8-N-1
framing and time out even when the switch worked.
Returns the post-change :class:DeviceInfo once the device responds
over the new protocol.
Raises:
| Type | Description |
|---|---|
WatlowConfirmationRequiredError
|
|
WatlowConfigurationError
|
|
Source code in src/watlowlib/maintenance.py
337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 | |
change_stdbus_address
async
¶
change_stdbus_address(
port,
*,
target_address,
current_address=1,
serial_settings=None,
timeout=None,
confirm=False,
)
Open port over Std Bus, write parameter 17001, reopen, identify.
Std Bus accepts MS/TP MAC values 1..16 (mapped to 0x10..0x1F on
the wire).
Returns:
| Type | Description |
|---|---|
DeviceInfo
|
The post-change :class: |
Raises:
| Type | Description |
|---|---|
WatlowConfirmationRequiredError
|
|
WatlowConfigurationError
|
|