Skip to content

Commit bc386a6

Browse files
committed
mesa_modbus: Document fault and rate limiting pins, fix some pin name formats
Signed-off-by: andypugh <andy@bodgesoc.org>
1 parent bf1fe9b commit bc386a6

2 files changed

Lines changed: 33 additions & 4 deletions

File tree

docs/src/drivers/mesa_modbus.adoc

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,38 @@ module will create the following pins for each instance of the driver:
135135

136136
*modname.drive_delay* (default 0)
137137

138+
•modname.update-hz* (default 0)
139+
140+
*modname.fault* - indicates a fault with the device or comms
141+
142+
*modname.last-error* - indicates the error code that set the fault
143+
output.
144+
138145
These can be redefined at any time and will take effect the next time
139146
that a modbus packet is assembled.
140147

148+
*modname.update-hz* is provided to slow down the transaction rate for
149+
modbus devices that become unstable if polled too frequently. If you see
150+
fault 11 then try setting this to 0.1Hz or even 1Hz. If set to zero the
151+
system runs as fast as it can.
152+
153+
The fault codes returned in "last error" are
154+
155+
|===
156+
|Code|Fault
157+
|1|Illegal Function
158+
|2|Illegal Data Address
159+
|3|Illegal Data Value
160+
|4|Server Device Failure
161+
|5|Acknowledge
162+
|6|Server Device Busy
163+
|7|Negative Acknowledge
164+
|8|Memory Parity Error
165+
|9|Gateway Path Unavailable
166+
|10|Gateway Failed to Respond
167+
|11|Comm Timeout
168+
|===
169+
141170
Each module exports a single HAL function to be attached to a realtime
142171
thread. The function name is just the module name, with no distinction
143172
made between read and write cycles.

src/hal/drivers/mesa-hostmot2/modbus/mesa_modbus.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,8 @@ int rtapi_app_main(void){
347347
i, channels[c].name);
348348
retval = hal_pin_float_newf(HAL_IN,
349349
(hal_float_t**)&(inst->hal->scale[p]),
350-
comp_id, COMP_NAME".%02i.%s-%02i-scale",
351-
i, channels[c].name, j);
350+
comp_id, COMP_NAME".%02i.%s-scale",
351+
i, channels[c].name);
352352
retval = hal_pin_float_newf(dir,
353353
(hal_float_t**)&(inst->hal->pin2[p]),
354354
comp_id, COMP_NAME".%02i.%s-scaled",
@@ -380,11 +380,11 @@ int rtapi_app_main(void){
380380
retval = hal_pin_float_newf(HAL_IN,
381381
(hal_float_t**)&(inst->hal->scale[p]),
382382
comp_id, COMP_NAME".%02i.%s-scale",
383-
i, channels[c].name, j);
383+
i, channels[c].name);
384384
retval = hal_pin_float_newf(HAL_IN,
385385
(hal_float_t**)&(inst->hal->pin2[p]),
386386
comp_id, COMP_NAME".%02i.%s-offset",
387-
i, channels[c].name, j);
387+
i, channels[c].name);
388388
}
389389
*(inst->hal->scale[p]) = 1;
390390
p++;

0 commit comments

Comments
 (0)