Repository navigation
Conversation
|
This is definitely going to require some better documentation! I may be able to take a day to visit the British Library in London to consult IEC 62386-105 and improve the documentation in this pull request. (I'm not going to buy the standard, the relevant part of it is only 20 pages long and it would cost me £302!) Do you know how addressing is supposed to work — how do the short firmware addresses relate to short gear and device addresses, if at all? If not, how do bus units get short firmware addresses? |
Add dali.firmware with the commands of IEC 62386-105 Ed.2, and dali.firmware_sequences with the sequences that drive an image onto a bus unit and that find the units supporting transfer at all. Firmware transfer uses 32-bit forward frames which carry their destination in the most significant byte. Table 1 encodes that byte as 0AAAAAAx for short addressing, 1111110x for broadcast unaddressed and 1111111x for broadcast, where bit 24 selects the address space: 0 is control gear and 1 is control devices. Section 9.2 requires a bus unit to discard a short, broadcast or broadcast-unaddressed command whose bit 24 does not match its own type, so the addresses split into FirmwareGear* and FirmwareDevice* classes mirroring GearAddress and DeviceAddress. There is no group addressing, and an int is not accepted as a destination because a short address alone does not say which address space is meant. A firmware transfer short address is not a separate address space: nothing in part 105 assigns, programs or queries one, so a unit has one only because it already has a part 102 or part 103 short address. One bus unit may hold several logical units, and per section 4.2 starting an update affects all of them, so a product presenting both control gear and a control device answers in both address spaces but is updated once. The commands have not been run against hardware that accepts a firmware image; they are exercised by unit tests only. The drivers that carry 32-bit frames live in dali-drivers; this is the library half. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
9164bf9 to
aa86d3d
Compare
|
Updated according reviewers comment. |
Review feedback from sde1000 on the firmware transfer PR. There is no separate address space for firmware transfer: part 105 assigns, programs and queries no short address of its own, so GearShort(3) in a 32-bit frame is the same unit as GearShort(3) in a 16-bit one. The separate FirmwareGear* and FirmwareDevice* classes therefore said nothing that GearShort and DeviceShort did not already say, so they are gone. GearShort, GearBroadcast, GearBroadcastUnaddressed, DeviceShort, DeviceBroadcast and DeviceBroadcastUnaddressed now encode into and decode from 32-bit frames too, writing bit 24 to select the address space. Part 105 Table 1 defines no group address. With groups now reachable through the same base classes, check_destination() rejects GearGroup and DeviceGroup explicitly rather than relying on the type system to make them unrepresentable. Address.required_frame_size is removed. It had no readers anywhere, and the merge makes it untrue in any case: an address may now be valid in more than one frame size. FirmwareAddress.is_control_device goes with it; firmware_sequences tests isinstance against DeviceAddress instead. Also drop the address_obj indirection in check_destination(). It reached dali.device.Device.address_obj, which was last renamed in 0.5 and no longer exists. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
# Conflicts: # CHANGES.rst # dali/address.py # dali/tests/test_command.py
Drop the FirmwareDestination alias: check_destination() checks the destination at runtime anyway, so address.Address says everything the annotation needs to. Store only the address in FirmwareUpdateTarget. Its class already says which address space the unit was found in, and the short address is reachable through it, so the separate address and control_device members were restating what destination held. Correct the note about transactions in FirmwareUpdate: a driver does run the sequence as a transaction, but each sleep() in it breaks that transaction and lets other bus masters transmit. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
General comment: it's great that the docstrings of the commands refer to the section of Part 105 that they implement, but it would be good if they could also paraphrase the appropriate section so that someone without a copy of the standard has some hope of understanding what the commands do. |
Part 105 Table 2 defines two bits in the firmware update feature set: bit 0 reports whether CANCEL FW UPDATE is supported, and bit 1 an integrated bus power supply that is disabled for the duration of the update, so that the updating tool has to supply bus power itself. Bits 2 to 7 are reserved. Name them in a BitmapResponse subclass rather than handing back a bare integer, so callers can ask for the bit they mean. FirmwareUpdateTarget.features carries the response, and the progress messages list the features that are set instead of printing a hex byte. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
| Bit 1 means an integrated bus power supply is present and is | ||
| disabled for the duration of the update, so the updating tool has | ||
| to supply bus power itself; 0 means either that there is none, or | ||
| that its state is left alone throughout. Bits 2 to 7 are | ||
| reserved, and are not listed here. |
There was a problem hiding this comment.
This comment is confusing and seems to be conflating bits 0 and 1?
| Part 105 sections 9.6 and 11.4.1. Discarded while the firmware | ||
| update process is enabled. |
There was a problem hiding this comment.
What is discarded while the firmware update process is enabled?
PR 3 — python-dali: firmware transfer (IEC 62386-105)
Open at: https://github.com/tridonic-com/python-dali/pull/new/pr-firmware
Base:
sde1000/python-dali:master←tridonic-com:pr-firmwareScope: 7 files · independent of the other two python-dali PRs
Split out of #171 as requested — "a major new feature and needs considering on
its own". It is now genuinely standalone: rebased straight onto
master, withno dependency on the
EnableDeviceType(0)PR.Status
The first version of this PR was written without a copy of the standard, and
said so: it listed the properties of the commands that had been inferred rather
than read. I have since read IEC 62386-105 Ed.2 (FDIS) and reconciled the
code with it. What was wrong has been fixed, and what was right is now cited
against the clause that says so rather than hedged.
It still has not been run against hardware that accepts a firmware image —
the commands and their framing are exercised by unit tests only.
What the standard changed
Addressing — this was wrong, and is the substantive fix. Table 1 encodes the
address byte as
0AAAAAAx/1111110x/1111111x, and footnote a says thatbit 24 selects the address space: 0 is control gear, 1 is control devices.
Section 9.2 requires a bus unit to discard a short, broadcast or
broadcast-unaddressed command whose bit 24 does not match its own type.
The first version hard-coded bit 24 to zero everywhere, on the theory that a
32-bit frame addresses a "bus unit" without distinguishing gear from devices. It
does distinguish them, so that version could only ever reach control gear, and
FindFirmwareUpdateTargetscould not have found a control device despite sayingit did. The address family now mirrors the existing gear/device split:
FirmwareGearShortFirmwareDeviceShortFirmwareGearBroadcastFirmwareDeviceBroadcastFirmwareGearBroadcastUnaddressedFirmwareDeviceBroadcastUnaddressedA bare
intis no longer accepted as a destination: a short address on its owndoes not say which address space is meant. There is no group addressing — part
105 Table 1 does not define one.
Two further points worth knowing, both now in the module docstrings:
in part 105 assigns, programs or queries one, so a unit has one only because
it already has a part 102 or part 103 short address.
FirmwareGearShort(3)isthe unit
GearShort(3)addresses.update affects all of them, and the part 105 variables are shared. So a
product presenting both control gear and a control device answers in both
address spaces but is updated once, not twice. The scan reports such a pair
and the example warns about it.
Confirmed, previously only inferred:
0xfbmarker byte match Table 6, and0xcb/0xbdmatch Table 7;
sendtwice = Falsethroughout was right;
QUERY BLOCK INCOMPLETE OR FAULTafter each complete data block for blocks 1 and up; 11.4.3 describespolling
QUERY FW UPDATE RECEIVER READYwhile the unit writes flash; Annex Cnotes that some units restart by themselves after
FINISH FW UPDATEwhileothers need
RESTART FW.Naming: every class is named after the command it sends, with the standard's
abbreviations spelled out —
QUERY FW TRANSFER VERSIONisQueryFirmwareTransferVersion,QUERY BLOCK INCOMPLETE OR FAULTisQueryBlockIncompleteOrFault. Each docstring names the command and the clauseof part 105 that defines it.
The change
dali.address— the sixFirmware*classes above, underFirmwareAddressdali.firmware— the commands, registered through__init_subclass__(theremoved
Command._register_subclass()is not used)dali.firmware_sequences— sequences that drive an image onto a unit and thatfind the units supporting transfer at all
devicetypeis irrelevant to a 32-bit frame, and the tests assert that decodingone does not depend on whatever device type was last enabled — so this PR reads
the same before and after the
EnableDeviceType(0)change.Not included
FirmwareUpdate()transfers an image that is already in the part 105 Annex Aupdate file format, block 0 included; it does not build that file or compute the
Annex B CRC16.
The worked example lives in the companion
dali-driversPR, since examplesmoved to that project in ce885e7. The drivers that actually carry 32-bit frames
are in that PR too; this is the library half.
Testing
pytest dali/— 174 passedmypy --strict dali/— clean, 49 filesflake8 dali— 0New tests cover the Table 1 encoding in both address spaces, that the gear and
device forms of an address differ only in bit 24, that both spaces are scanned
by default, and that an
intdestination is refused.🤖 Generated with Claude Code