liblightmodbus 3.0
A lightweight, header-only, hardware-agnostic Modbus RTU/TCP library
|
Master's functions for building requests and parsing responses (implementation) More...
Go to the source code of this file.
Functions | |
ModbusErrorInfomodbusParseResponse01020304 (ModbusMaster *status, uint8_t address, uint8_t function, const uint8_t *requestPDU, uint8_t requestLength, const uint8_t *responsePDU, uint8_t responseLength) | |
Parses response to requests 01, 02, 03 and 04. | |
ModbusErrorInfomodbusParseResponse0506 (ModbusMaster *status, uint8_t address, uint8_t function, const uint8_t *requestPDU, uint8_t requestLength, const uint8_t *responsePDU, uint8_t responseLength) | |
Parses response to requests 05 and 06. | |
ModbusErrorInfomodbusParseResponse1516 (ModbusMaster *status, uint8_t address, uint8_t function, const uint8_t *requestPDU, uint8_t requestLength, const uint8_t *responsePDU, uint8_t responseLength) | |
Parses response to requests 15 and 16 (write mutliple regsiters/coils) | |
ModbusErrorInfomodbusParseResponse22 (ModbusMaster *status, uint8_t address, uint8_t function, const uint8_t *requestPDU, uint8_t requestLength, const uint8_t *responsePDU, uint8_t responseLength) | |
Parses response to request 22. | |
ModbusErrorInfomodbusBuildRequest01020304 (ModbusMaster *status, uint8_t function, uint16_t index, uint16_t count) | |
Read mutiple coils/discrete inputs/holding registers/input registers. | |
ModbusErrorInfomodbusBuildRequest0506 (ModbusMaster *status, uint8_t function, uint16_t index, uint16_t value) | |
Write single coil/holding register. | |
ModbusErrorInfomodbusBuildRequest15 (ModbusMaster *status, uint16_t index, uint16_t count, const uint8_t *values) | |
Write multiple coils. | |
ModbusErrorInfomodbusBuildRequest16 (ModbusMaster *status, uint16_t index, uint16_t count, const uint16_t *values) | |
Write multiple holding registers. | |
ModbusErrorInfomodbusBuildRequest22 (ModbusMaster *status, uint16_t index, uint16_t andmask, uint16_t ormask) | |
Mask write register request. | |
Master's functions for building requests and parsing responses (implementation)
ModbusErrorInfomodbusBuildRequest01020304 | ( | ModbusMaster * | status, |
uint8_t | function, | ||
uint16_t | index, | ||
uint16_t | count ) |
Read mutiple coils/discrete inputs/holding registers/input registers.
function | 1 to read coils, 2 to read discrete inputs, 3 to read holding registers, 4 to read input registers |
index | Index of the register to be read |
count | Number of registers to be read |
value | New value for the register/coil |
ModbusErrorInfomodbusBuildRequest0506 | ( | ModbusMaster * | status, |
uint8_t | function, | ||
uint16_t | index, | ||
uint16_t | value ) |
Write single coil/holding register.
function | 5 to write a coil, 6 to write a holding register |
index | Index of the register/coil to be written |
value | New value for the register/coil |
function
is not 5 or 6 ModbusErrorInfomodbusBuildRequest15 | ( | ModbusMaster * | status, |
uint16_t | index, | ||
uint16_t | count, | ||
const uint8_t * | values ) |
Write multiple coils.
index | Index of the first coil to be written |
count | Number of coils to be written |
values | Pointer to array containing count coil values (each bit corresponds to one coil value) |
count
is zero or too large ModbusErrorInfomodbusBuildRequest16 | ( | ModbusMaster * | status, |
uint16_t | index, | ||
uint16_t | count, | ||
const uint16_t * | values ) |
Write multiple holding registers.
index | Index of the first register to be written |
count | Number of registers to be written |
values | Pointer to array containing count register values. Each 16-bit word corresponds to one register value |
count
is zero or too large ModbusErrorInfomodbusBuildRequest22 | ( | ModbusMaster * | status, |
uint16_t | index, | ||
uint16_t | andmask, | ||
uint16_t | ormask ) |
Mask write register request.
index | Register ID |
andmax | AND mask |
ormask | OR mask |
ModbusErrorInfomodbusParseResponse01020304 | ( | ModbusMaster * | status, |
uint8_t | address, | ||
uint8_t | function, | ||
const uint8_t * | requestPDU, | ||
uint8_t | requestLength, | ||
const uint8_t * | responsePDU, | ||
uint8_t | responseLength ) |
Parses response to requests 01, 02, 03 and 04.
address | Address of the slave |
function | Response function code |
requestPDU | pointer to the PDU section of the request frame |
requestLength | request PDU section length |
responsePDU | pointer to the PDU section of the response frame |
responseLength | response PDU section length |
function
is not one of: 01, 02, 03, 04 ModbusErrorInfomodbusParseResponse0506 | ( | ModbusMaster * | status, |
uint8_t | address, | ||
uint8_t | function, | ||
const uint8_t * | requestPDU, | ||
uint8_t | requestLength, | ||
const uint8_t * | responsePDU, | ||
uint8_t | responseLength ) |
Parses response to requests 05 and 06.
address | Address of the slave |
function | Response function code |
requestPDU | pointer to the PDU section of the request frame |
requestLength | request PDU section length |
responsePDU | pointer to the PDU section of the response frame |
responseLength | response PDU section length |
ModbusErrorInfomodbusParseResponse1516 | ( | ModbusMaster * | status, |
uint8_t | address, | ||
uint8_t | function, | ||
const uint8_t * | requestPDU, | ||
uint8_t | requestLength, | ||
const uint8_t * | responsePDU, | ||
uint8_t | responseLength ) |
Parses response to requests 15 and 16 (write mutliple regsiters/coils)
address | Address of the slave |
function | Response function code |
requestPDU | pointer to the PDU section of the request frame |
requestLength | request PDU section length |
responsePDU | pointer to the PDU section of the response frame |
responseLength | response PDU section length |
ModbusErrorInfomodbusParseResponse22 | ( | ModbusMaster * | status, |
uint8_t | address, | ||
uint8_t | function, | ||
const uint8_t * | requestPDU, | ||
uint8_t | requestLength, | ||
const uint8_t * | responsePDU, | ||
uint8_t | responseLength ) |
Parses response to request 22.
address | Address of the slave |
function | Response function code |
requestPDU | pointer to the PDU section of the request frame |
requestLength | request PDU section length |
responsePDU | pointer to the PDU section of the response frame |
responseLength | response PDU section length |