Go to the documentation of this file.
31 #ifndef _MODBUS_COMMON_H
32 #define _MODBUS_COMMON_H
38 #define MODBUS_TCP_PORT 502
40 #define MODBUS_TCP_SECURE_PORT 802
43 #define MODBUS_PROTOCOL_ID 0
45 #define MODBUS_DEFAULT_UNIT_ID 255
48 #define MODBUS_MAX_PDU_SIZE 253
50 #define MODBUS_MAX_ADU_SIZE 260
53 #define MODBUS_FUNCTION_CODE_MASK 0x7F
55 #define MODBUS_EXCEPTION_MASK 0x80
58 #define MODBUS_SET_COIL(a, n) ((a)[(n) / 8] |= (1 << ((n) % 8)))
60 #define MODBUS_RESET_COIL(a, n) ((a)[(n) / 8] &= ~(1 << ((n) % 8)))
62 #define MODBUS_TEST_COIL(a, n) ((a[(n) / 8] >> ((n) % 8)) & 1)
128 #if defined(__CCRX__)
130 #elif defined(__CWCC__) || defined(_WIN32)
131 #pragma pack(push, 1)
155 uint8_t functionCode;
167 uint8_t functionCode;
179 uint8_t functionCode;
191 uint8_t functionCode;
203 uint8_t functionCode;
215 uint8_t functionCode;
227 uint8_t functionCode;
239 uint8_t functionCode;
251 uint8_t functionCode;
263 uint8_t functionCode;
275 uint8_t functionCode;
287 uint8_t functionCode;
299 uint8_t functionCode;
313 uint8_t functionCode;
325 uint8_t functionCode;
339 uint8_t functionCode;
351 uint8_t functionCode;
364 uint8_t functionCode;
377 uint8_t functionCode;
393 uint8_t functionCode;
405 uint8_t functionCode;
411 #if defined(__CCRX__)
413 #elif defined(__CWCC__) || defined(_WIN32)
@ MODBUS_FUNCTION_WRITE_FILE_RECORD
@ MODBUS_FUNCTION_READ_FIFO_QUEUE
@ MODBUS_FUNCTION_GET_COMM_EVENT_COUNTER
ModbusReadHoldingRegsResp
ModbusReadDiscreteInputsResp
uint16_t writeStartingAddr
@ MODBUS_EXCEPTION_GATEWAY_PATH_UNAVAILABLE
@ MODBUS_FUNCTION_DIAGNOSTICS
ModbusWriteSingleCoilResp
ModbusWriteMultipleRegsReq
uint16_t readStartingAddr
ModbusWriteMultipleRegsResp
@ MODBUS_FUNCTION_READ_FILE_RECORD
@ MODBUS_FUNCTION_READ_DISCRETE_INPUTS
@ MODBUS_FUNCTION_READ_WRITE_MULTIPLE_REGS
@ MODBUS_FUNCTION_REPORT_SLAVE_ID
ModbusWriteMultipleCoilsReq
@ MODBUS_FUNCTION_READ_EXCEPTION_STATUS
@ MODBUS_EXCEPTION_SLAVE_DEVICE_FAILURE
@ MODBUS_FUNCTION_WRITE_MULTIPLE_REGS
@ MODBUS_FUNCTION_MASK_WRITE_REG
typedef __packed_struct
MBAP header (Modbus Application Protocol)
@ MODBUS_EXCEPTION_ILLEGAL_DATA_ADDRESS
@ MODBUS_EXCEPTION_SLAVE_DEVICE_BUSY
@ MODBUS_FUNCTION_WRITE_SINGLE_REG
@ MODBUS_FUNCTION_READ_INPUT_REGS
ModbusWriteMultipleCoilsResp
@ MODBUS_EXCEPTION_ACKNOWLEDGE
uint16_t quantityOfOutputs
@ MODBUS_FUNCTION_GET_COMM_EVENT_LOG
ModbusCoilState
Coil states.
ModbusFunctionCode
Modbus functions codes.
uint16_t quantityOfInputs
@ MODBUS_EXCEPTION_MEMORY_PARITY_ERROR
@ MODBUS_FUNCTION_ENCAPSULATED_IF_TRANSPORT
@ MODBUS_EXCEPTION_ILLEGAL_FUNCTION
@ MODBUS_FUNCTION_READ_HOLDING_REGS
ModbusReadDiscreteInputsReq
ModbusReadWriteMultipleRegsReq
@ MODBUS_EXCEPTION_ILLEGAL_DATA_VALUE
@ MODBUS_EXCEPTION_GATEWAY_NO_RESPONSE_FROM_TARGET
@ MODBUS_FUNCTION_WRITE_SINGLE_COIL
ModbusExceptionCode
Modbus exception codes.
@ MODBUS_FUNCTION_WRITE_MULTIPLE_COILS
ModbusReadWriteMultipleRegsResp
@ MODBUS_FUNCTION_READ_COILS