Repository navigation
Unify driver send()/run_sequence() and add a transmit priority - #161
Open
markus-becker-tridonic-com wants to merge 2 commits into
Open
markus-becker-tridonic-com wants to merge 2 commits into
markus-becker-tridonic-com wants to merge 2 commits into
Conversation
The serial DriverSerialBase previously had both a per-frame send() and a run_sequence() that drove a sequence generator. These collapse into a single send() that accepts either a bare Command or a sequence: a bare Command is wrapped in a trivial one-shot sequence and runs through the same transaction loop, so a single command still returns its Response. EnableDeviceType auto-prefixing for non-zero device types now happens in that one loop, covering bare commands as well as sequences, which removes the need for trivial device-type wrapper sequences. send() takes an optional priority (IEC 62386-101 Table 22, values 2..5; anything else raises ValueError). The first forward frame of the transaction is sent at that priority and every subsequent frame at priority 1, forming a 101 §9.3 transaction. For LUBA this replaces the old class-based isinstance() priority guess with the caller's intent (see 103 §9.14); SCI has no wire priority field, so it accepts and ignores the value. The per-frame transmit is now the private _send_frame(cmd, *, priority). run_sequence() stays as a deprecated alias of send() so existing callers keep working with a DeprecationWarning.
Mirror the serial driver change in the hid base class shared by the tridonic and hasseb USB masters: send() now accepts a bare Command or a sequence, wrapping a bare Command in a trivial one-shot sequence and running everything through one transaction loop that auto-prefixes EnableDeviceType. run_sequence() becomes a deprecated alias of send(). send() validates priority against the IEC 62386-101 Table 22 range 2..5 (raising ValueError otherwise) for a uniform driver API, but HID dongles transmit at a fixed priority, so the value has no effect on the wire. The CommunicationError retry behaviour and the exceptions_on_send override are preserved per frame.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Collapse the two driver entry points —
send()(one frame) andrun_sequence()(a sequence) — into a singlesend()that accepts either a bareCommandor a sequence, and add an optional transmitpriority.This implements the driver-API changes we discussed: EnableDeviceType belongs in the driver, one method runs both commands and sequences, and priority is chosen by the caller's intent (IEC 62386-101 Table 22 / 103 §9.14) rather than guessed from the command class.
Details
send(msg, *, priority=5, progress=None)wraps a bareCommandin a trivial one-shot sequence and runs it through the same transaction loop, so a single command still returns itsResponse. The per-frame transmit is now the private_send_frame(cmd, *, priority).EnableDeviceTypefor any command with a non-zero device type — now for bare commands too, not just sequences. This removes the need for trivial device-type wrapper sequences.prioritymust be in2..5(anything else raisesValueError, as requested). The first forward frame of the transaction goes at that priority and every subsequent frame at priority 1, forming a 101 §9.3 transaction. For LUBA this replaces the old class-basedisinstance()guess with the caller's value on the wire; SCI has no wire priority field, so it accepts and ignores it. HID dongles transmit at a fixed priority, so there it is validated but has no wire effect.run_sequence()stays as a deprecated alias ofsend()emittingDeprecationWarning.tridonic/hasseb). The legacy sync/async drivers indali/driver/base.py,tridonic.py,usb.py,hasseb.pyare intentionally untouched.Tests
dali/tests/test_dummy.pygains coverage via the serial fake (which now records(command, priority)per frame): bare-command EnableDeviceType auto-prefix, no prefix for device-type 0, priority rejection outside2..5, priority acceptance for2..5, first-frame-priority / continuation-priority-1, and therun_sequencedeprecation warning. Full suite: 123 passed.