IPC@CHIP Modbus library – API Documentation

Header image

Main page


Modbus TCP client - Functions


Detailed Description

This page lists all functions of the Modbus TCP client API.
The Modbus library allows to create/handle several Modbus TCP connections specificable by a unique handle number.
The implemented set of functions provides the establishment of TCP connections and the execution of Modbus master requests for the following function codes:
1h,2h,3h,5h,6h,10h,17h

The provided source code sample TCP_CLIENT shall be used as a template for the creation of own Modbus TCP client applications.
Enable debug mode: When setting the internal library variables mb_tcp_rcv_dbg and mb_tcp_snd_dbg to value 1 all incoming and outgoing messages are written to stdout.

Functions

int mbTCP_cl_init (MbHandle *handle, u8 async)
 Initialises a Modbus TCP client connection.
int mbTCP_cl_deinit (MbHandle handle)
 Deinitialises a Modbus TCP client connection.
int mbTCP_cl_connect (MbHandle handle, const char *ipAddrStr, u16 port, TCPKeepAliveOpt *opt, u16 timeoutMs, int *errorCode)
 Establish a connection to a Modbus TCP server.
int mbTCP_cl_disconnect (MbHandle handle, int *errorCode)
 Close Modbus TCP connection.
int mbTCP_cl_get_socket (MbHandle handle)
 Gets the Modbus TCP client connection's socket descriptor.
int mbTCP_cl_wr_regs (MbHandle handle, u8 unitId, u16 startAddress, u16 items, const u16 *registerData, u8 *exception, u32 timeoutMs, int *errorCode)
 Write multiple registers (10h).
int mbTCP_cl_wr_regs_packed (MbHandle handle, u8 unitId, u16 startAddress, u16 quantity, u8 *registerData, u8 *exception, u32 timeoutMs, int *errorCode)
 Write multiple registers in a packed manner (10h).
int mbTCP_cl_wr_single_reg (MbHandle handle, u8 unitId, u8 functionCode, u16 startAddress, u16 registerData, u8 *exception, u32 timeoutMs, int *errorCode)
 Write single holding register (6h or 64h).
int mbTCP_cl_wr_single_coil (MbHandle handle, u8 unitId, u16 startAddress, u16 coil, u8 *exception, u32 timeoutMs, int *errorCode)
 Write single coil (5h).
int mbTCP_cl_rd_discr_inputs (MbHandle handle, u8 unitId, u8 functionCode, u16 startAddress, u16 quantity, u8 *input_coilbuf, u8 *exception, u32 timeoutMs, int *errorCode)
 Read coils status/discrete input (01h or 02h).
int mbTCP_cl_wr_coils (MbHandle handle, u8 unitId, u16 startAddress, u16 quantity, const u8 *coilBuf, u8 *exception, u32 timeoutMs, int *errorCode)
 Write multiple coils (0fh) Send a "write multiple coils" (0Fh) request and receive the reply from the server.
int mbTCP_cl_rd_regs (MbHandle handle, u8 unitId, u8 functionCode, u16 startAddress, u16 quantity, u16 *registerData, u8 *exception, u32 timeoutMs, int *errorCode)
 Read multiple registers (03h or 04h).
int mbTCP_cl_rd_regs_packed (MbHandle handle, u8 unitId, u8 functionCode, u16 startAddress, u16 quantity, u8 *registerData, u8 *exception, u32 timeoutMs, int *errorCode)
 Read multiple registers in a packed manner (03h or 04h).
int mbTCP_cl_rdwr_regs (MbHandle handle, u8 unitId, u16 startAddressRd, u16 quantityRd, u16 *registerDataRd, u16 startAddressWr, u16 quantityWr, const u16 *registerDataWr, u8 *exception, u32 timeoutMs, int *errorCode)
 Read/write multiple registers (17h).
int mbTCP_cl_rdwr_regs_packed (MbHandle handle, u8 unitId, u16 startAddressRd, u16 quantityRd, u8 *registerDataRd, u16 startAddressWr, u16 quantityWr, const u8 *registerDataWr, u8 *exception, u32 timeoutMs, int *errorCode)
 Read/write multiple registers in a packed manner (17h).





Top of page | Main page

Copyright © 2017 Beck IPC GmbH
Generated on Thu Mar 9 18:00:33 2017 by Doxygen 1.6.1