| ioPAC RTU Controllers C/C++ Sample Code Programming Guide

- Main Page
- Modules
- Data Structures
- Files

Modules | Macros | Enumerations
ModbusSlave
Library

## Modules
| ModbusSlaveExceptionCode
| ModbusSlaveReturnCode
| ModbusSlaveFunctionCode
| ModbusSlaveMapType
| ModbusTCPSlave
| ModbusRTUSlave

## Macros
#define | MAKE_WORD(a, b) (((UINT16)a<<8) +(UINT16)b)
#define | pfnModbusRead int (*pfnModRead)(UINT8 *pData, UINT16 nth, void *pUserData)
#define | pfnModbusWrite int (*pfnModWrite)(UINT8 *pData, UINT16 nth, void *pUserData)
#define | MODBUS_LISTEN_PORTS 1
#define | MODBUS_MAX_CONNECTION 10
#define | MODBUS_MAX_MAP_SIZE 3000
#define | MODBUS_MIN_IDLE_TIMEOUT_SECOND 10

## Enumerations
enum | MODBUS_SLAVE_ERR_CODE { MODBUS_SLAVE_ERR_OK = 0, MODBUS_SLAVE_ERR_ADDRESS, MODBUS_SLAVE_ERR_ADDRESS_COLLISION, MODBUS_SLAVE_ERR_BIND, MODBUS_SLAVE_ERR_CREATE_SOCKET, MODBUS_SLAVE_ERR_CREATE_THREAD, MODBUS_SLAVE_ERR_EXCEPTION, MODBUS_SLAVE_ERR_EXCEED_MAP_SIZE, MODBUS_SLAVE_ERR_FUNCTION, MODBUS_SLAVE_ERR_ILLEGAL_HANDLE, MODBUS_SLAVE_ERR_IDLE_TIMEOUT, MODBUS_SLAVE_ERR_ILLEGAL_ACTION, MODBUS_SLAVE_ERR_LISTEN, MODBUS_SLAVE_ERR_LISTEN_PORT_OVERFLOW, MODBUS_SLAVE_ERR_MAP_TYPE, MODBUS_SLAVE_ERR_MAP_EMPTY, MODBUS_SLAVE_ERR_MEMORY_LEAK, MODBUS_SLAVE_ERR_NO_START, MODBUS_SLAVE_ERR_NO_REGISTER, MODBUS_SLAVE_ERR_PORT_LISTENING, MODBUS_SLAVE_ERR_REGISTERED_PORT, MODBUS_SLAVE_ERR_SIZE, MODBUS_SLAVE_ERR_SYSTEM_TIMEOUT, MODBUS_SLAVE_ERR_SET_SOCKET_MODE, MODBUS_SLAVE_ERR_SET_SOCKET_OPTION, MODBUS_SLAVE_ERR_NO_CONNECTIONS, MODBUS_SLAVE_ERR_SYSTEM_INFO, MODBUS_SLAVE_ERR_AMOUNT }

## Detailed Description

Sample Code:

- modbus_tcp_slave.c
- modbus_rtu_slave.c

## Macro Definition Documentation

#define MAKE_WORD | ( |  | a,
|  |  | b
| ) |  | (((UINT16)a<<8) +(UINT16)b)

#define pfnModbusRead int (*pfnModRead)(UINT8 *pData, UINT16 nth, void *pUserData)

#define pfnModbusWrite int (*pfnModWrite)(UINT8 *pData, UINT16 nth, void *pUserData)

#define MODBUS_LISTEN_PORTS 1

#define MODBUS_MAX_CONNECTION 10

#define MODBUS_MAX_MAP_SIZE 3000

#define MODBUS_MIN_IDLE_TIMEOUT_SECOND 10

## Enumeration Type Documentation

enum MODBUS_SLAVE_ERR_CODE

Enumerator
MODBUS_SLAVE_ERR_OK | 0
MODBUS_SLAVE_ERR_ADDRESS | 1
MODBUS_SLAVE_ERR_ADDRESS_COLLISION | 2
MODBUS_SLAVE_ERR_BIND | 3
MODBUS_SLAVE_ERR_CREATE_SOCKET | 4
MODBUS_SLAVE_ERR_CREATE_THREAD | 5
MODBUS_SLAVE_ERR_EXCEPTION | 6
MODBUS_SLAVE_ERR_EXCEED_MAP_SIZE | 7
MODBUS_SLAVE_ERR_FUNCTION | 8
MODBUS_SLAVE_ERR_ILLEGAL_HANDLE | 9
MODBUS_SLAVE_ERR_IDLE_TIMEOUT | 10
MODBUS_SLAVE_ERR_ILLEGAL_ACTION | 11
MODBUS_SLAVE_ERR_LISTEN | 12
MODBUS_SLAVE_ERR_LISTEN_PORT_OVERFLOW | 13
MODBUS_SLAVE_ERR_MAP_TYPE | 14
MODBUS_SLAVE_ERR_MAP_EMPTY | 15
MODBUS_SLAVE_ERR_MEMORY_LEAK | 16
MODBUS_SLAVE_ERR_NO_START | 17
MODBUS_SLAVE_ERR_NO_REGISTER | 18
MODBUS_SLAVE_ERR_PORT_LISTENING | 19
MODBUS_SLAVE_ERR_REGISTERED_PORT | 20
MODBUS_SLAVE_ERR_SIZE | 21
MODBUS_SLAVE_ERR_SYSTEM_TIMEOUT | 22
MODBUS_SLAVE_ERR_SET_SOCKET_MODE | 23
MODBUS_SLAVE_ERR_SET_SOCKET_OPTION | 24
MODBUS_SLAVE_ERR_NO_CONNECTIONS | 25
MODBUS_SLAVE_ERR_SYSTEM_INFO | 26
MODBUS_SLAVE_ERR_AMOUNT | 27