Add serial parity option (M575 F) for device/Modbus mode#1244
Merged
Conversation
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>
|
All contributors have signed the CLA ✍️ ✅ |
Author
|
I have read the Duet3D CLA v2.0 and I hereby sign it |
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. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
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 aSerialParity(none/even/odd) and applies it inSetMode()by selectingMode_8N1/8E1/8O1when callingAsyncSerial::begin(baudRate, config).M575: in device mode, parses a newFparameter —F0none/8N1 (default),F1even/8E1,F2odd/8O1. The parameter is applied on every device-mode M575, so omittingFgives 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
AsyncSerialalready defines theMode_8E1/8O1framing constants.Fdoesn't clash with any existing M575 parameter.