Modbus RTU Programming - nthallen/monarch GitHub Wiki
Modbus::RTU
Devices
Creating a Driver for First off, consider taking a look at these working example(s).
Basic Structure
As with most device drivers, a Modbus::RTU
based driver usually will support
3 interfaces:
- A
TM_data_sndr
for submitting device data to telemetry - A
Cmd_reader
for receiving commands from the command server - A
Modbus::RTU
interface to the device(s) themselves
The first two should be discussed elsewhere (and there are many examples).
Getting Modbus::RTU
to work with your device involves creating a
subclass of Modbus::RTU::modbus_device
.
Research
The first step is to understand the device and the features that are accessible via the Modbus interface. You need to map out the features you wish to expose and the appropriate Modbus::RTU request that will be required to access them.
There are generally two basic types of requests in a device driver:
- Regular polling to report the state of the device
- Asynchronous command requests
The enqueue_requests()
method of the modbus_device
subclass is used to
define the first set of requests.