Skip to content

Test harness #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

Test harness #46

wants to merge 10 commits into from

Conversation

alextingle
Copy link

Uses a loopback stream to set up communication between a master and slave on the same machine. Exercises various MODBUS functions, and tests that the results are correct. Test failures are reported to Serial, labelled "FAIL".

Also contains a couple of bug-fixes, which ensure that junk is not included in the MODBUS messages. (Found by the test harness.)

The motivation is to prepare for future code changes. Having a working test harness will help to ensure that changes have not broken anything.

Alex Tingle added 10 commits June 3, 2019 21:12
New macro USE_SOFTWARE_SERIAL may be set to 0 (default, hardware)
or 1 (software) to select software/hardware serial implementation
at compile time.
Replace overloaded methods with default parameter values.
Eliminate duplicate code by having initialisation methods
call each other, rather than replicate code.

Preserves all possible ways that users might be contructing a
working ModbusRtu object.
Eliminate any dependence upon SoftwareSerial class.
ModbusRtu now just refers to the base class Stream, which
is the parent of both HardwareSerial and SoftwareSerial.

The only function that is not in the base class is begin().
Ideally, users will call this function on their port object
directly, and then call the new ModbusRtu::start() function.

I've added in a couple of template begin() methods that
enable existing code to work without modification. These should
be deprecated, to encourage users to begin() their port objects
directly.

This approach also fixes Issue smarmengol#44 - "how to setup Serial
settings: parity, stop bits".
This will create a warning in users' build output, which
will encourage them to switch to the new, simpler constructor.

Changed the documentation to describe how to upgrade.
Uses a loopback stream to set up communication between a master
and slave on the same machine. Exercises various MODBUS functions,
and tests that the results are correct.

Test failures are reported to Serial, labelled "FAIL".
Modbus::get_FC1() - the code used to preserve old data in the
high byte of au16regs words. So, if a single coil is returned
from the slave, au16regs[0]'s high byte was left with junk in it.

Modbus::process_FC1() - make sure that the data returned to the
master is clean. Unused bits should be zeroed, according to the
spec.
@alextingle
Copy link
Author

(Includes, and depends upon the Serial changes I already put in the other pull request.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant