|
Lydia - Printhead
|
Arduino class library for communicating with Modbus devices over USB/RS232/485 (via RTU protocol). More...
#include <ModbusRtu.h>
Public Member Functions | |
| void | begin () |
| void | begin (long u32speed) |
| Initialize class object. | |
| void | begin (long u32speed, uint8_t u8config) |
| Initialize class object. | |
| void | begin (SoftwareSerial *sPort, long u32speed) |
| Initialize class object. | |
| void | clearError () |
| void | end () |
| finish any communication and release serial communication port | |
| uint16_t | getErrCnt () |
| error counter | |
| uint8_t | getID () |
| get slave ID between 1 and 247 | |
| uint16_t | getInCnt () |
| number of incoming messages | |
| uint8_t | getLastError () |
| get last error message | |
| uint16_t | getOutCnt () |
| number of outcoming messages | |
| uint8_t | getState () |
| uint16_t | getTimeOut () |
| get communication watch-dog timer value | |
| boolean | getTimeOutState () |
| get communication watch-dog timer state | |
| bool | isLocked () |
| Modbus () | |
| Default Constructor for Master through Serial. | |
| Modbus (uint8_t u8id) | |
| Modbus (uint8_t u8id, uint8_t u8serno) | |
| Modbus (uint8_t u8id, uint8_t u8serno, uint8_t u8txenpin) | |
| int8_t | poll () |
| cyclic poll for master | |
| int8_t | poll (uint16_t *regs, uint8_t u8size) |
| cyclic poll for slave | |
| int8_t | query (modbus_t telegram) |
| only for master | |
| void | setID (uint8_t u8id) |
| write new ID for the slave | |
| void | setTimeOut (uint16_t u16timeout) |
| write communication watch-dog timer | |
Public Attributes | |
| bool | debugSend |
| uint8_t | rxBuffer [MAX_BUFFER] |
| uint8_t | rxSize |
Private Member Functions | |
| void | buildException (uint8_t u8exception) |
| This method builds an exception message. | |
| uint16_t | calcCRC (uint8_t u8length) |
| This method calculates CRC. | |
| void | get_FC1 () |
| void | get_FC3 () |
| int8_t | getRxBuffer () |
| This method moves Serial buffer data to the Modbus au8Buffer. | |
| void | init (uint8_t u8id) |
| void | init (uint8_t u8id, uint8_t u8serno, uint8_t u8txenpin) |
| int8_t | process_FC1 (uint16_t *regs, uint8_t u8size) |
| This method processes functions 1 & 2 This method reads a bit array and transfers it to the master. | |
| int8_t | process_FC15 (uint16_t *regs, uint8_t u8size) |
| This method processes function 15 This method writes a bit array assigned by the master. | |
| int8_t | process_FC16 (uint16_t *regs, uint8_t u8size) |
| This method processes function 16 This method writes a word array assigned by the master. | |
| int8_t | process_FC3 (uint16_t *regs, uint8_t u8size) |
| This method processes functions 3 & 4 This method reads a word array and transfers it to the master. | |
| int8_t | process_FC5 (uint16_t *regs, uint8_t u8size) |
| This method processes function 5 This method writes a value assigned by the master to a single bit. | |
| int8_t | process_FC6 (uint16_t *regs, uint8_t u8size) |
| This method processes function 6 This method writes a value assigned by the master to a single word. | |
| void | sendTxBuffer () |
| This method transmits au8Buffer to Serial line. Only if u8txenpin != 0, there is a flow handling in order to keep the RS485 transceiver in output state as long as the message is being sent. This is done with UCSRxA register. The CRC is appended to the buffer before starting to send it. | |
| uint8_t | validateAnswer () |
| This method validates master incoming messages. | |
| uint8_t | validateRequest () |
| This method validates slave incoming messages. | |
Private Attributes | |
| uint16_t * | au16regs |
| uint8_t | au8Buffer [MAX_BUFFER] |
| modbus_t * | currentQuery |
| HardwareSerial * | port |
| Pointer to Serial class object. | |
| SoftwareSerial * | softPort |
| Pointer to SoftwareSerial class object. | |
| uint16_t | u16errCnt |
| uint16_t | u16InCnt |
| uint16_t | u16OutCnt |
| uint16_t | u16timeOut |
| uint32_t | u32time |
| uint32_t | u32timeOut |
| uint8_t | u8BufferSize |
| uint8_t | u8id |
| 0=master, 1..247=slave number | |
| uint8_t | u8lastError |
| uint8_t | u8lastRec |
| uint8_t | u8regsize |
| uint8_t | u8serno |
| serial port: 0-Serial, 1..3-Serial1..Serial3; 4: use software serial | |
| uint8_t | u8state |
| uint8_t | u8txenpin |
| flow control pin: 0=USB or RS-232 mode, >0=RS-485 mode | |
Arduino class library for communicating with Modbus devices over USB/RS232/485 (via RTU protocol).
Definition at line 152 of file ModbusRtu.h.
Definition at line 245 of file ModbusRtu.h.
Definition at line 263 of file ModbusRtu.h.
| Modbus::Modbus | ( | uint8_t | u8id | ) |
Definition at line 282 of file ModbusRtu.h.
| void Modbus::begin | ( | ) |
Definition at line 450 of file ModbusRtu.h.
| void Modbus::clearError | ( | ) |
Definition at line 550 of file ModbusRtu.h.
| void Modbus::end | ( | ) |
finish any communication and release serial communication port
| uint16_t Modbus::getTimeOut | ( | ) |
get communication watch-dog timer value
Definition at line 890 of file ModbusRtu.h.
Definition at line 879 of file ModbusRtu.h.
| bool Modbus::isLocked | ( | ) |
Definition at line 344 of file ModbusRtu.h.
|
private |
Definition at line 165 of file ModbusRtu.h.
|
private |
Definition at line 162 of file ModbusRtu.h.
|
private |
Definition at line 178 of file ModbusRtu.h.
| bool Modbus::debugSend |
Definition at line 214 of file ModbusRtu.h.
|
private |
Pointer to Serial class object.
Definition at line 155 of file ModbusRtu.h.
| uint8_t Modbus::rxBuffer[MAX_BUFFER] |
Definition at line 217 of file ModbusRtu.h.
| uint8_t Modbus::rxSize |
Definition at line 216 of file ModbusRtu.h.
|
private |
Pointer to SoftwareSerial class object.
Definition at line 156 of file ModbusRtu.h.
|
private |
Definition at line 166 of file ModbusRtu.h.
|
private |
Definition at line 166 of file ModbusRtu.h.
|
private |
Definition at line 166 of file ModbusRtu.h.
|
private |
Definition at line 167 of file ModbusRtu.h.
|
private |
Definition at line 168 of file ModbusRtu.h.
|
private |
Definition at line 168 of file ModbusRtu.h.
|
private |
Definition at line 163 of file ModbusRtu.h.
|
private |
0=master, 1..247=slave number
Definition at line 157 of file ModbusRtu.h.
|
private |
Definition at line 161 of file ModbusRtu.h.
|
private |
Definition at line 164 of file ModbusRtu.h.
|
private |
Definition at line 169 of file ModbusRtu.h.
|
private |
serial port: 0-Serial, 1..3-Serial1..Serial3; 4: use software serial
Definition at line 158 of file ModbusRtu.h.
|
private |
Definition at line 160 of file ModbusRtu.h.
|
private |
flow control pin: 0=USB or RS-232 mode, >0=RS-485 mode
Definition at line 159 of file ModbusRtu.h.