Skip to content

Add serial parity option (M575 F) for device/Modbus mode#1244

Merged
dc42 merged 1 commit into
Duet3D:3.7-devfrom
filippo-bosi:modbus-parity-3.7
Jul 17, 2026
Merged

Add serial parity option (M575 F) for device/Modbus mode#1244
dc42 merged 1 commit into
Duet3D:3.7-devfrom
filippo-bosi:modbus-parity-3.7

Conversation

@filippo-bosi

@filippo-bosi filippo-bosi commented Jul 16, 2026

Copy link
Copy Markdown

Implements #1196 (parity bit for RS485 Modbus).

What's changed

Aux serial ports in device (Modbus RTU) mode previously always opened as 8N1. Some Modbus devices require parity — e.g. OnRobot grippers need 8E1 — so this adds an optional parity setting to M575:

  • AuxDevice: stores a SerialParity (none/even/odd) and applies it in SetMode() by selecting Mode_8N1/8E1/8O1 when calling AsyncSerial::begin(baudRate, config).
  • M575: in device mode, parses a new F parameter — F0 none/8N1 (default), F1 even/8E1, F2 odd/8O1. The parameter is applied on every device-mode M575, so omitting F gives 8N1 exactly as before this option existed, rather than retaining a previously set parity.

Example: M575 P1 S7 B115200 F1 → Modbus RTU, 115200 baud, 8E1.

Notes

  • No core change needed: CoreN2G's AsyncSerial already defines the Mode_8E1/8O1 framing constants.
  • Default stays 8N1, so PanelDue/raw modes are unaffected.
  • F doesn't clash with any existing M575 parameter.
  • Parity is bus-wide (as suggested in the issue); per-slave parity via M260/M261 is not included in this PR.
  • I've been running this in production on 3.6.2-based builds integrating an OnRobot gripper (8E1); this PR is the same change rebased onto 3.7-dev.

Aux serial ports in device (Modbus RTU) mode previously always opened as
8N1. Some Modbus devices require parity - e.g. OnRobot grippers need 8E1 -
so add an optional parity setting (Duet3D#1196).

- AuxDevice: store a SerialParity (none/even/odd) and apply it in SetMode
  by selecting Mode_8N1/8E1/8O1 when calling AsyncSerial::begin(baudRate,
  config).
- M575: in device mode, parse the F parameter (F0 none/8N1, F1 even/8E1,
  F2 odd/8O1). The parameter is applied on every device-mode M575, so
  omitting F restores the previous behaviour (8N1) instead of retaining a
  previously set parity.

The core (CoreN2G AsyncSerial) already defines the Mode_8E1/8O1 framing,
so no core change is needed. Default stays 8N1, so PanelDue/raw modes are
unaffected.

Enables e.g.: M575 P1 S7 B115200 F1  (Modbus RTU, 115200, 8E1).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@filippo-bosi

Copy link
Copy Markdown
Author

I have read the Duet3D CLA v2.0 and I hereby sign it

@dc42
dc42 merged commit e5f6e87 into Duet3D:3.7-dev Jul 17, 2026
1 of 2 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 17, 2026
@dc42

dc42 commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Unfortunately this change broke the Duet 3 Mini build. To fix it I have had to refactor the change to move the hardware detail into CoreN2G. @filippo-bosi please integrate these changes into your fork and test that you are still able to use even parity on Modbus.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants