Skip to content

Commit 361b653

Browse files
committed
Add unaligned attribute to suppress warning when not relevant.
1 parent 548797c commit 361b653

2 files changed

Lines changed: 15 additions & 6 deletions

File tree

docs/src/man/man1/mesambccc.1.adoc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,14 @@ Recognized '<commands>/<command>' attributes:
591591
should be emitted when it does. This differs from 'noanswer' in that a reply
592592
may be expected within the timeout period but not after the timeout expires.
593593
This may be required for flaky devices. Default false.
594+
*unaligned* [Boolean]::
595+
Set to true to suppress the alignment warning in multi-register reads or
596+
writes where 32-bit or 64-bit values are not aligned to their natural Modbus
597+
address boundaries. This is useful for devices that do not care about
598+
alignment or do not use Modbus addresses in conventional ways. +
599+
Setting 'unaligned' is purely a cosmetic attribute to suppress console
600+
clutter when compiling the mbccs file. It has no functional effect on the
601+
communication with the device. Default false.
594602
*writeflush* [Boolean]::
595603
The override the 'writeflush' value. See '<mesamodbus>[writeflush]' for
596604
details. Default '<mesamodbus>[writeflush]'.

src/hal/drivers/mesa-hostmot2/mesambccc.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -317,10 +317,10 @@ def mbtType(mtype):
317317
'txdelay', 'writeflush' ]
318318

319319
# Allowed attributes in <commands>/<command>
320-
CMDSATTRIB = [ 'address', 'bcanswer', 'clamp', 'count', 'delay',
321-
'device', 'disabled', 'function', 'haltype', 'interval',
322-
'modbustype', 'name', 'noanswer', 'resend', 'scale',
323-
'timeout', 'timeoutbits', 'timesout', 'writeflush' ]
320+
CMDSATTRIB = [ 'address', 'bcanswer', 'clamp', 'count', 'delay',
321+
'device', 'disabled', 'function', 'haltype', 'interval',
322+
'modbustype', 'name', 'noanswer', 'resend', 'scale',
323+
'timeout', 'timeoutbits', 'timesout', 'unaligned', 'writeflush' ]
324324

325325
# Allowed attributes in <commands>/<command>/<pin>
326326
PINSATTRIB = [ 'clamp', 'name', 'haltype', 'modbustype', 'scale' ]
@@ -1323,8 +1323,9 @@ def handleCommands(commands):
13231323

13241324
if ((mbtOrderSize(pmtype[0]) == 4 and 0 != ((address + regofs) & 1))
13251325
or (mbtOrderSize(pmtype[0]) == 8 and 0 != ((address + regofs) & 3))):
1326-
pwarn("Multi-register type '{0}' not aligned to natural boundary (address={1}/0x{1:04x}, regoffset={2}/0x{2:02x}) in {3}"
1327-
.format(MBNAMES[pmtype[0]], address, regofs, lpl))
1326+
if not getBoolean(cmd.attrib, 'unaligned'):
1327+
pwarn("Multi-register type '{0}' not aligned to natural boundary (address={1}/0x{1:04x}, regoffset={2}/0x{2:02x}) in {3}"
1328+
.format(MBNAMES[pmtype[0]], address, regofs, lpl))
13281329

13291330
pinlist.append({'pin': pintag, 'mtype': pmtype[0], 'htype': phtype, 'flags': pf, 'regofs': regofs})
13301331
pinlistall.append(pintag)

0 commit comments

Comments
 (0)