ioPAC RTU Controllers
C/C++ Sample Code Programming Guide
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions
ModbusTCPMaster

Functions

MODBUS_MASTER_ERR_CODE MX_RTU_Modbus_Tcp_Master_Open (UINT8 ipAddress[], UINT16 tcpPort, UINT32 cTimeoutMs, UINT32 *sHandle)
 
MODBUS_MASTER_ERR_CODE MX_RTU_Modbus_Tcp_Master_Close (UINT32 sHandle)
 
MODBUS_MASTER_ERR_CODE MX_RTU_Modbus_Tcp_Master_Ioctl (UINT32 sHandle, UINT8 unitId, UINT32 rwTimeoutMs)
 
MODBUS_MASTER_ERR_CODE MX_RTU_Modbus_Tcp_Master_Read_Coils (UINT32 sHandle, UINT16 startAddr, UINT16 coilCount, UINT8 byteCoils[])
 
MODBUS_MASTER_ERR_CODE MX_RTU_Modbus_Tcp_Master_Write_Coils (UINT32 sHandle, UINT16 startAddr, UINT16 coilCount, UINT8 byteCoils[])
 
MODBUS_MASTER_ERR_CODE MX_RTU_Modbus_Tcp_Master_Write_Coil (UINT32 sHandle, UINT16 addr, UINT8 coil)
 
MODBUS_MASTER_ERR_CODE MX_RTU_Modbus_Tcp_Master_Read_Discrete_Inputs (UINT32 sHandle, UINT16 startAddr, UINT16 coilCount, UINT8 byteCoils[])
 
MODBUS_MASTER_ERR_CODE MX_RTU_Modbus_Tcp_Master_Read_Input_Regs (UINT32 sHandle, UINT16 startAddr, UINT16 regCount, UINT16 regs[])
 
MODBUS_MASTER_ERR_CODE MX_RTU_Modbus_Tcp_Master_Read_Holding_Regs (UINT32 sHandle, UINT16 startAddr, UINT16 regCount, UINT16 regs[])
 
MODBUS_MASTER_ERR_CODE MX_RTU_Modbus_Tcp_Master_Write_Holding_Regs (UINT32 sHandle, UINT16 startAddr, UINT16 regCount, UINT16 regs[])
 
MODBUS_MASTER_ERR_CODE MX_RTU_Modbus_Tcp_Master_Write_Holding_Reg (UINT32 sHandle, UINT16 addr, UINT16 regValue)
 

Detailed Description

Sample Code:
modbus_tcp_master.c

Function Documentation

MODBUS_MASTER_ERR_CODE MX_RTU_Modbus_Tcp_Master_Open ( UINT8  ipAddress[],
UINT16  tcpPort,
UINT32  cTimeoutMs,
UINT32 sHandle 
)
Parameters
[in]ipAddressIP of Modbus TCP Slave.
[in]tcpPortPort of Modbus TCP Slave.
[in]cTimeoutMsModbus TCP connecting timeout in milliseconds.
[out]sHandleA handle, like a file descriptor, stands for the connection.
Returns
MODBUS_MASTER_ERR_CODE
MODBUS_MASTER_ERR_CODE MX_RTU_Modbus_Tcp_Master_Close ( UINT32  sHandle)
Parameters
[in]sHandleA handle, like a file descriptor, stands for the connection.
Returns
MODBUS_MASTER_ERR_CODE
MODBUS_MASTER_ERR_CODE MX_RTU_Modbus_Tcp_Master_Ioctl ( UINT32  sHandle,
UINT8  unitId,
UINT32  rwTimeoutMs 
)
Parameters
[in]sHandleA handle, like a file descriptor, stands for the connection.
[in]unitIdUnit ID from 0x0 to 0xffff, Unit ID is not 0 when the Modbus TCP Slave is a gateway.
[in]rwTimeoutMsModbus TCP RW timeout in milliseconds.
Returns
MODBUS_MASTER_ERR_CODE
MODBUS_MASTER_ERR_CODE MX_RTU_Modbus_Tcp_Master_Read_Coils ( UINT32  sHandle,
UINT16  startAddr,
UINT16  coilCount,
UINT8  byteCoils[] 
)
Parameters
[in]sHandleA handle, like a file descriptor, stands for the connection.
[in]startAddrModbus Address from 0x0 to 0xffff.
[in]coilCountThe amount of coils to be read from Start Address.
[out]byteCoilsRead Data from Modbus TCP Slave.
Returns
MODBUS_MASTER_ERR_CODE
MODBUS_MASTER_ERR_CODE MX_RTU_Modbus_Tcp_Master_Write_Coils ( UINT32  sHandle,
UINT16  startAddr,
UINT16  coilCount,
UINT8  byteCoils[] 
)
Parameters
[in]sHandleA handle, like a file descriptor, stands for the connection.
[in]startAddrModbus Address from 0x0 to 0xffff.
[in]coilCountThe amount of coils to be written from Start Address.
[in]byteCoilsWritten Data to Modbus TCP Slave.
Returns
MODBUS_MASTER_ERR_CODE
MODBUS_MASTER_ERR_CODE MX_RTU_Modbus_Tcp_Master_Write_Coil ( UINT32  sHandle,
UINT16  addr,
UINT8  coil 
)
Parameters
[in]sHandleA handle, like a file descriptor, stands for the connection.
[in]addrModbus Address from 0x0 to 0xffff.
[in]coilWritten Data to Modbus TCP Slave.
Returns
MODBUS_MASTER_ERR_CODE
MODBUS_MASTER_ERR_CODE MX_RTU_Modbus_Tcp_Master_Read_Discrete_Inputs ( UINT32  sHandle,
UINT16  startAddr,
UINT16  coilCount,
UINT8  byteCoils[] 
)
Parameters
[in]sHandleA handle, like a file descriptor, stands for the connection.
[in]startAddrModbus Address from 0x0 to 0xffff.
[in]coilCountThe amount of discrete inputs to be read from Start Address.
[out]byteCoilsRead Data from Modbus TCP Slave.
Returns
MODBUS_MASTER_ERR_CODE
MODBUS_MASTER_ERR_CODE MX_RTU_Modbus_Tcp_Master_Read_Input_Regs ( UINT32  sHandle,
UINT16  startAddr,
UINT16  regCount,
UINT16  regs[] 
)
Parameters
[in]sHandleA handle, like a file descriptor, stands for the connection.
[in]startAddrModbus Address from 0x0 to 0xffff.
[in]regCountThe amount of input registers to be read from Start Address.
[out]regsRead Data from Modbus TCP Slave.
Returns
MODBUS_MASTER_ERR_CODE
MODBUS_MASTER_ERR_CODE MX_RTU_Modbus_Tcp_Master_Read_Holding_Regs ( UINT32  sHandle,
UINT16  startAddr,
UINT16  regCount,
UINT16  regs[] 
)
Parameters
[in]sHandleA handle, like a file descriptor, stands for the connection.
[in]startAddrModbus Address from 0x0 to 0xffff.
[in]regCountThe amount of holding registers to be read from Start Address.
[out]regsRead Data from Modbus TCP Slave.
Returns
MODBUS_MASTER_ERR_CODE
MODBUS_MASTER_ERR_CODE MX_RTU_Modbus_Tcp_Master_Write_Holding_Regs ( UINT32  sHandle,
UINT16  startAddr,
UINT16  regCount,
UINT16  regs[] 
)
Parameters
[in]sHandleA handle, like a file descriptor, stands for the connection.
[in]startAddrModbus Address from 0x0 to 0xffff.
[in]regCountThe amount of holding registers will be written from Start Address.
[in]regsWritten Data to Modbus TCP Slave.
Returns
MODBUS_MASTER_ERR_CODE
MODBUS_MASTER_ERR_CODE MX_RTU_Modbus_Tcp_Master_Write_Holding_Reg ( UINT32  sHandle,
UINT16  addr,
UINT16  regValue 
)
Parameters
[in]sHandleA handle, like a file descriptor, stands for the connection.
[in]addrModbus Address from 0x0 to 0xffff.
[in]regValueWritten Data to Modbus TCP Slave.
Returns
MODBUS_MASTER_ERR_CODE