modbus_client_pdu.h File Reference

Modbus PDU formatting and parsing. More...

#include "core/net.h"
#include "modbus/modbus_client.h"

Go to the source code of this file.

Functions

error_t modbusClientFormatReadCoilsReq (ModbusClientContext *context, uint16_t address, uint_t quantity)
 Format Read Coils request. More...
 
error_t modbusClientFormatReadDiscreteInputsReq (ModbusClientContext *context, uint16_t address, uint_t quantity)
 Format Read Discrete Inputs request. More...
 
error_t modbusClientFormatReadHoldingRegsReq (ModbusClientContext *context, uint16_t address, uint_t quantity)
 Format Read Holding Registers request. More...
 
error_t modbusClientFormatReadInputRegsReq (ModbusClientContext *context, uint16_t address, uint_t quantity)
 Format Read Input Registers request. More...
 
error_t modbusClientFormatWriteSingleCoilReq (ModbusClientContext *context, uint16_t address, bool_t value)
 Format Write Single Coil request. More...
 
error_t modbusClientFormatWriteSingleRegReq (ModbusClientContext *context, uint16_t address, uint16_t value)
 Format Write Single Register request. More...
 
error_t modbusClientFormatWriteMultipleCoilsReq (ModbusClientContext *context, uint16_t address, uint_t quantity, const uint8_t *value)
 Format Write Multiple Coils request. More...
 
error_t modbusClientFormatWriteMultipleRegsReq (ModbusClientContext *context, uint16_t address, uint_t quantity, const uint16_t *value)
 Format Write Multiple Registers request. More...
 
error_t modbusClientFormatMaskWriteRegReq (ModbusClientContext *context, uint16_t address, uint16_t andMask, uint16_t orMask)
 Format Mask Write Register request. More...
 
error_t modbusClientFormatReadWriteMultipleRegsReq (ModbusClientContext *context, uint16_t readAddress, uint16_t readQuantity, uint16_t writeAddress, uint16_t writeQuantity, const uint16_t *writeValue)
 Format Read/Write Multiple Registers request. More...
 
error_t modbusClientParseReadCoilsResp (ModbusClientContext *context, uint_t quantity, uint8_t *value)
 Parse Read Coils response. More...
 
error_t modbusClientParseReadDiscreteInputsResp (ModbusClientContext *context, uint_t quantity, uint8_t *value)
 Parse Discrete Inputs response. More...
 
error_t modbusClientParseReadHoldingRegsResp (ModbusClientContext *context, uint_t quantity, uint16_t *value)
 Parse Read Holding Registers response. More...
 
error_t modbusClientParseReadInputRegsResp (ModbusClientContext *context, uint_t quantity, uint16_t *value)
 Parse Read Input Registers response. More...
 
error_t modbusClientParseWriteSingleCoilResp (ModbusClientContext *context, uint16_t address, bool_t value)
 Parse Write Single Coil response. More...
 
error_t modbusClientParseWriteSingleRegResp (ModbusClientContext *context, uint16_t address, uint16_t value)
 Parse Write Single Register response. More...
 
error_t modbusClientParseWriteMultipleCoilsResp (ModbusClientContext *context, uint16_t address, uint_t quantity)
 Parse Write Multiple Coils response. More...
 
error_t modbusClientParseWriteMultipleRegsResp (ModbusClientContext *context, uint16_t address, uint_t quantity)
 Parse Write Multiple Registers response. More...
 
error_t modbusClientParseMaskWriteRegResp (ModbusClientContext *context, uint16_t address, uint16_t andMask, uint16_t orMask)
 Parse Mask Write Register response. More...
 
error_t modbusClientParseReadWriteMultipleRegsResp (ModbusClientContext *context, uint_t readQuantity, uint16_t *readValue)
 Parse Read/Write Multiple Registers response. More...
 
error_t modbusClientParseExceptionResp (ModbusClientContext *context)
 Parse Exception response. More...
 

Detailed Description

Modbus PDU formatting and parsing.

License

SPDX-License-Identifier: GPL-2.0-or-later

Copyright (C) 2010-2024 Oryx Embedded SARL. All rights reserved.

This file is part of CycloneTCP Open.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Author
Oryx Embedded SARL (www.oryx-embedded.com)
Version
2.4.4

Definition in file modbus_client_pdu.h.

Function Documentation

◆ modbusClientFormatMaskWriteRegReq()

error_t modbusClientFormatMaskWriteRegReq ( ModbusClientContext context,
uint16_t  address,
uint16_t  andMask,
uint16_t  orMask 
)

Format Mask Write Register request.

Parameters
[in]contextPointer to the Modbus/TCP client context
[in]addressAddress of the holding register
[in]andMaskAND bitmask
[in]orMaskOR bitmask
Returns
Error code

Definition at line 366 of file modbus_client_pdu.c.

◆ modbusClientFormatReadCoilsReq()

error_t modbusClientFormatReadCoilsReq ( ModbusClientContext context,
uint16_t  address,
uint_t  quantity 
)

Format Read Coils request.

Parameters
[in]contextPointer to the Modbus/TCP client context
[in]addressAddress of the first coil
[in]quantityNumber of coils
Returns
Error code

Definition at line 53 of file modbus_client_pdu.c.

◆ modbusClientFormatReadDiscreteInputsReq()

error_t modbusClientFormatReadDiscreteInputsReq ( ModbusClientContext context,
uint16_t  address,
uint_t  quantity 
)

Format Read Discrete Inputs request.

Parameters
[in]contextPointer to the Modbus/TCP client context
[in]addressAddress of the first coil
[in]quantityNumber of inputs
Returns
Error code

Definition at line 88 of file modbus_client_pdu.c.

◆ modbusClientFormatReadHoldingRegsReq()

error_t modbusClientFormatReadHoldingRegsReq ( ModbusClientContext context,
uint16_t  address,
uint_t  quantity 
)

Format Read Holding Registers request.

Parameters
[in]contextPointer to the Modbus/TCP client context
[in]addressStarting register address
[in]quantityNumber of registers
Returns
Error code

Definition at line 123 of file modbus_client_pdu.c.

◆ modbusClientFormatReadInputRegsReq()

error_t modbusClientFormatReadInputRegsReq ( ModbusClientContext context,
uint16_t  address,
uint_t  quantity 
)

Format Read Input Registers request.

Parameters
[in]contextPointer to the Modbus/TCP client context
[in]addressStarting register address
[in]quantityNumber of registers
Returns
Error code

Definition at line 158 of file modbus_client_pdu.c.

◆ modbusClientFormatReadWriteMultipleRegsReq()

error_t modbusClientFormatReadWriteMultipleRegsReq ( ModbusClientContext context,
uint16_t  readAddress,
uint16_t  readQuantity,
uint16_t  writeAddress,
uint16_t  writeQuantity,
const uint16_t *  writeValue 
)

Format Read/Write Multiple Registers request.

Parameters
[in]contextPointer to the Modbus/TCP client context
[in]readAddressAddress of the first holding registers to be read
[in]readQuantityNumber of holding registers to be read
[in]writeAddressAddress of the first holding registers to be written
[in]writeQuantityNumber of holding registers to be written
[in]writeValueValue of the holding registers (write operation)
Returns
Error code

Definition at line 405 of file modbus_client_pdu.c.

◆ modbusClientFormatWriteMultipleCoilsReq()

error_t modbusClientFormatWriteMultipleCoilsReq ( ModbusClientContext context,
uint16_t  address,
uint_t  quantity,
const uint8_t *  value 
)

Format Write Multiple Coils request.

Parameters
[in]contextPointer to the Modbus/TCP client context
[in]addressAddress of the first coil to be forced
[in]quantityNumber of coils
[in]valueValue of the discrete outputs
Returns
Error code

Definition at line 274 of file modbus_client_pdu.c.

◆ modbusClientFormatWriteMultipleRegsReq()

error_t modbusClientFormatWriteMultipleRegsReq ( ModbusClientContext context,
uint16_t  address,
uint_t  quantity,
const uint16_t *  value 
)

Format Write Multiple Registers request.

Parameters
[in]contextPointer to the Modbus/TCP client context
[in]addressStarting register address
[in]quantityNumber of registers
[in]valueValue of the holding registers
Returns
Error code

Definition at line 322 of file modbus_client_pdu.c.

◆ modbusClientFormatWriteSingleCoilReq()

error_t modbusClientFormatWriteSingleCoilReq ( ModbusClientContext context,
uint16_t  address,
bool_t  value 
)

Format Write Single Coil request.

Parameters
[in]contextPointer to the Modbus/TCP client context
[in]addressAddress of the coil to be forced
[in]valueValue of the discrete output
Returns
Error code

Definition at line 193 of file modbus_client_pdu.c.

◆ modbusClientFormatWriteSingleRegReq()

error_t modbusClientFormatWriteSingleRegReq ( ModbusClientContext context,
uint16_t  address,
uint16_t  value 
)

Format Write Single Register request.

Parameters
[in]contextPointer to the Modbus/TCP client context
[in]addressAddress of the register to be written
[in]valueRegister value
Returns
Error code

Definition at line 238 of file modbus_client_pdu.c.

◆ modbusClientParseExceptionResp()

error_t modbusClientParseExceptionResp ( ModbusClientContext context)

Parse Exception response.

Parameters
[in]contextPointer to the Modbus/TCP client context
Returns
Error code

Definition at line 869 of file modbus_client_pdu.c.

◆ modbusClientParseMaskWriteRegResp()

error_t modbusClientParseMaskWriteRegResp ( ModbusClientContext context,
uint16_t  address,
uint16_t  andMask,
uint16_t  orMask 
)

Parse Mask Write Register response.

Parameters
[in]contextPointer to the Modbus/TCP client context
[in]addressAddress of the holding register
[in]andMaskAND bitmask
[in]orMaskOR bitmask
Returns
Error code

Definition at line 785 of file modbus_client_pdu.c.

◆ modbusClientParseReadCoilsResp()

error_t modbusClientParseReadCoilsResp ( ModbusClientContext context,
uint_t  quantity,
uint8_t *  value 
)

Parse Read Coils response.

Parameters
[in]contextPointer to the Modbus/TCP client context
[in]quantityNumber of coils
[out]valueValue of the discrete outputs
Returns
Error code

Definition at line 451 of file modbus_client_pdu.c.

◆ modbusClientParseReadDiscreteInputsResp()

error_t modbusClientParseReadDiscreteInputsResp ( ModbusClientContext context,
uint_t  quantity,
uint8_t *  value 
)

Parse Discrete Inputs response.

Parameters
[in]contextPointer to the Modbus/TCP client context
[in]quantityNumber of inputs
[out]valueValue of the discrete inputs
Returns
Error code

Definition at line 492 of file modbus_client_pdu.c.

◆ modbusClientParseReadHoldingRegsResp()

error_t modbusClientParseReadHoldingRegsResp ( ModbusClientContext context,
uint_t  quantity,
uint16_t *  value 
)

Parse Read Holding Registers response.

Parameters
[in]contextPointer to the Modbus/TCP client context
[in]quantityNumber of registers
[out]valueValue of the holding registers
Returns
Error code

Definition at line 533 of file modbus_client_pdu.c.

◆ modbusClientParseReadInputRegsResp()

error_t modbusClientParseReadInputRegsResp ( ModbusClientContext context,
uint_t  quantity,
uint16_t *  value 
)

Parse Read Input Registers response.

Parameters
[in]contextPointer to the Modbus/TCP client context
[in]quantityNumber of registers
[out]valueValue of the input registers
Returns
Error code

Definition at line 581 of file modbus_client_pdu.c.

◆ modbusClientParseReadWriteMultipleRegsResp()

error_t modbusClientParseReadWriteMultipleRegsResp ( ModbusClientContext context,
uint_t  readQuantity,
uint16_t *  readValue 
)

Parse Read/Write Multiple Registers response.

Parameters
[in]contextPointer to the Modbus/TCP client context
[in]readQuantityNumber of holding registers to be read
[out]readValueValue of the holding registers
Returns
Error code

Definition at line 823 of file modbus_client_pdu.c.

◆ modbusClientParseWriteMultipleCoilsResp()

error_t modbusClientParseWriteMultipleCoilsResp ( ModbusClientContext context,
uint16_t  address,
uint_t  quantity 
)

Parse Write Multiple Coils response.

Parameters
[in]contextPointer to the Modbus/TCP client context
[in]addressAddress of the first coil to be forced
[in]quantityNumber of coils
Returns
Error code

Definition at line 708 of file modbus_client_pdu.c.

◆ modbusClientParseWriteMultipleRegsResp()

error_t modbusClientParseWriteMultipleRegsResp ( ModbusClientContext context,
uint16_t  address,
uint_t  quantity 
)

Parse Write Multiple Registers response.

Parameters
[in]contextPointer to the Modbus/TCP client context
[in]addressStarting register address
[in]quantityNumber of registers
Returns
Error code

Definition at line 746 of file modbus_client_pdu.c.

◆ modbusClientParseWriteSingleCoilResp()

error_t modbusClientParseWriteSingleCoilResp ( ModbusClientContext context,
uint16_t  address,
bool_t  value 
)

Parse Write Single Coil response.

Parameters
[in]contextPointer to the Modbus/TCP client context
[in]addressAddress of the coil to be forced
[in]valueValue of the discrete output
Returns
Error code

Definition at line 629 of file modbus_client_pdu.c.

◆ modbusClientParseWriteSingleRegResp()

error_t modbusClientParseWriteSingleRegResp ( ModbusClientContext context,
uint16_t  address,
uint16_t  value 
)

Parse Write Single Register response.

Parameters
[in]contextPointer to the Modbus/TCP client context
[in]addressAddress of the register to be written
[in]valueRegister value
Returns
Error code

Definition at line 671 of file modbus_client_pdu.c.