23 #if (defined(__unix__) || defined(unix)) && !defined(USG) 24 #include <sys/param.h> 38 # define MODBUS_BEGIN_DECLS extern "C" { 39 # define MODBUS_END_DECLS } 41 # define MODBUS_BEGIN_DECLS 42 # define MODBUS_END_DECLS 63 #define MODBUS_BROADCAST_ADDRESS 0 70 #define MODBUS_MAX_READ_BITS 2000 71 #define MODBUS_MAX_WRITE_BITS 1968 80 #define MODBUS_MAX_READ_REGISTERS 125 81 #define MODBUS_MAX_WRITE_REGISTERS 123 82 #define MODBUS_MAX_RW_WRITE_REGISTERS 121 85 #define MODBUS_ENOBASE 112345678 103 #define EMBXILFUN (MODBUS_ENOBASE + MODBUS_EXCEPTION_ILLEGAL_FUNCTION) 104 #define EMBXILADD (MODBUS_ENOBASE + MODBUS_EXCEPTION_ILLEGAL_DATA_ADDRESS) 105 #define EMBXILVAL (MODBUS_ENOBASE + MODBUS_EXCEPTION_ILLEGAL_DATA_VALUE) 106 #define EMBXSFAIL (MODBUS_ENOBASE + MODBUS_EXCEPTION_SLAVE_OR_SERVER_FAILURE) 107 #define EMBXACK (MODBUS_ENOBASE + MODBUS_EXCEPTION_ACKNOWLEDGE) 108 #define EMBXSBUSY (MODBUS_ENOBASE + MODBUS_EXCEPTION_SLAVE_OR_SERVER_BUSY) 109 #define EMBXNACK (MODBUS_ENOBASE + MODBUS_EXCEPTION_NEGATIVE_ACKNOWLEDGE) 110 #define EMBXMEMPAR (MODBUS_ENOBASE + MODBUS_EXCEPTION_MEMORY_PARITY) 111 #define EMBXGPATH (MODBUS_ENOBASE + MODBUS_EXCEPTION_GATEWAY_PATH) 112 #define EMBXGTAR (MODBUS_ENOBASE + MODBUS_EXCEPTION_GATEWAY_TARGET) 115 #define EMBBADCRC (EMBXGTAR + 1) 116 #define EMBBADDATA (EMBXGTAR + 2) 117 #define EMBBADEXC (EMBXGTAR + 3) 118 #define EMBUNKEXC (EMBXGTAR + 4) 119 #define EMBMDATA (EMBXGTAR + 5) 177 const uint16_t *src,
int read_addr,
int read_nb,
182 int nb_holding_registers,
int nb_input_registers);
195 unsigned int exception_code);
201 #define MODBUS_GET_HIGH_BYTE(data) (((data) >> 8) & 0xFF) 202 #define MODBUS_GET_LOW_BYTE(data) ((data) & 0xFF) 203 #define MODBUS_GET_INT32_FROM_INT16(tab_int16, index) ((tab_int16[(index)] << 16) + tab_int16[(index) + 1]) 204 #define MODBUS_GET_INT16_FROM_INT8(tab_int8, index) ((tab_int8[(index)] << 8) + tab_int8[(index) + 1]) 205 #define MODBUS_SET_INT16_TO_INT8(tab_int8, index, value) \ 207 tab_int8[(index)] = (value) >> 8; \ 208 tab_int8[(index) + 1] = (value) & 0xFF; \ 213 const uint8_t *tab_byte);
void modbus_set_bits_from_byte(uint8_t *dest, int index, const uint8_t value)
const unsigned int libmodbus_version_major
int modbus_receive_from(modbus_t *ctx, int sockfd, uint8_t *req)
modbus_mapping_t * modbus_mapping_new(int nb_coil_status, int nb_input_status, int nb_holding_registers, int nb_input_registers)
float modbus_get_float(const uint16_t *src)
int modbus_read_bits(modbus_t *ctx, int addr, int nb, uint8_t *dest)
void modbus_set_byte_timeout(modbus_t *ctx, const struct timeval *timeout)
int modbus_reply_exception(modbus_t *ctx, const uint8_t *req, unsigned int exception_code)
int modbus_receive(modbus_t *ctx, uint8_t *req)
void modbus_free(modbus_t *ctx)
int modbus_flush(modbus_t *ctx)
int modbus_set_error_recovery(modbus_t *ctx, modbus_error_recovery_mode error_recovery)
const unsigned int libmodbus_version_micro
int modbus_read_input_bits(modbus_t *ctx, int addr, int nb, uint8_t *dest)
#define MODBUS_BEGIN_DECLS
void modbus_set_debug(modbus_t *ctx, int boolean)
void modbus_close(modbus_t *ctx)
int modbus_set_slave(modbus_t *ctx, int slave)
int modbus_reply(modbus_t *ctx, const uint8_t *req, int req_length, modbus_mapping_t *mb_mapping)
int modbus_read_input_registers(modbus_t *ctx, int addr, int nb, uint16_t *dest)
void modbus_get_byte_timeout(modbus_t *ctx, struct timeval *timeout)
void modbus_get_response_timeout(modbus_t *ctx, struct timeval *timeout)
int modbus_write_register(modbus_t *ctx, int reg_addr, int value)
const char * modbus_strerror(int errnum)
void modbus_set_bits_from_bytes(uint8_t *dest, int index, unsigned int nb_bits, const uint8_t *tab_byte)
int modbus_write_registers(modbus_t *ctx, int addr, int nb, const uint16_t *data)
uint16_t * tab_input_registers
void modbus_set_float(float f, uint16_t *dest)
modbus_error_recovery_mode
int modbus_get_header_length(modbus_t *ctx)
void modbus_mapping_free(modbus_mapping_t *mb_mapping)
int modbus_write_bits(modbus_t *ctx, int addr, int nb, const uint8_t *data)
int modbus_receive_confirmation(modbus_t *ctx, uint8_t *rsp)
const unsigned int libmodbus_version_minor
int modbus_read_registers(modbus_t *ctx, int addr, int nb, uint16_t *dest)
uint8_t modbus_get_byte_from_bits(const uint8_t *src, int index, unsigned int nb_bits)
int modbus_connect(modbus_t *ctx)
modbus_mapping_t * mb_mapping
void modbus_set_socket(modbus_t *ctx, int socket)
int modbus_report_slave_id(modbus_t *ctx, uint8_t *dest)
void modbus_set_response_timeout(modbus_t *ctx, const struct timeval *timeout)
int modbus_send_raw_request(modbus_t *ctx, uint8_t *raw_req, int raw_req_length)
int modbus_write_and_read_registers(modbus_t *ctx, int write_addr, int write_nb, const uint16_t *src, int read_addr, int read_nb, uint16_t *dest)
int modbus_get_socket(modbus_t *ctx)
int modbus_write_bit(modbus_t *ctx, int coil_addr, int status)