mbmaster.h 文件参考
#include <stdio.h>
#include <string.h>
#include "k_api.h"
#include "mbmaster_default_config.h"
#include "adu.h"
#include "auxiliary.h"

浏览源代码.

结构体

struct  mb_handler
 

类型定义

typedef enum mb_status mb_status_t
 
typedef struct mb_handler mb_handler_t
 
typedef mb_status_t(* frame_send_func_t) (mb_handler_t *handler, uint32_t timeout)
 
typedef mb_status_t(* frame_recv_func_t) (mb_handler_t *handler)
 
typedef mb_status_t(* adu_assemble_func_t) (mb_handler_t *handler)
 
typedef mb_status_t(* adu_disassemble_func_t) (mb_handler_t *handler)
 

枚举

enum  mb_parity_t { MB_PAR_NONE , MB_PAR_ODD , MB_PAR_EVEN }
 
enum  mb_status {
  MB_SUCCESS = 0u , MB_MUTEX_ERROR , MB_INVALID_SLAVE_ADDR , MB_INVALID_PARAM ,
  MB_RESPOND_EXCEPTION , MB_RESPOND_LENGTH_ERR , MB_RESPOND_FRAME_ERR , MB_RESPOND_TIMEOUT ,
  MB_CANNOT_GET_HANDLER , MB_SLAVE_NO_RESPOND , MB_FRAME_SEND_ERR , MB_SERIAL_INIT_FAILED ,
  MB_SERIAL_UNINIT_FAILED , MB_FUNCTION_CODE_NOT_SUPPORT
}
 
enum  mb_mode_t { MB_RTU , MB_ASCII , MB_TCP }
 

函数

mb_status_t mbmaster_rtu_init (mb_handler_t **handler, uint8_t port, uint32_t baud_rate, mb_parity_t parity, uint32_t timeout)
 
mb_status_t mbmaster_rtu_uninit (mb_handler_t *req_handler)
 
mb_status_t mbmaster_read_coils (mb_handler_t *req_handler, uint8_t slave_addr, uint16_t start_addr, uint16_t quantity, uint8_t *respond_buf, uint8_t *respond_count, uint32_t timeout)
 
mb_status_t mbmaster_read_discrete_inputs (mb_handler_t *req_handler, uint8_t slave_addr, uint16_t start_addr, uint16_t quantity, uint8_t *respond_buf, uint8_t *respond_count, uint32_t timeout)
 
mb_status_t mbmaster_read_holding_registers (mb_handler_t *req_handler, uint8_t slave_addr, uint16_t start_addr, uint16_t quantity, uint8_t *respond_buf, uint8_t *respond_count, uint32_t timeout)
 
mb_status_t mbmaster_read_input_registers (mb_handler_t *req_handler, uint8_t slave_addr, uint16_t start_addr, uint16_t quantity, uint8_t *respond_buf, uint8_t *respond_count, uint32_t timeout)
 
mb_status_t mbmaster_write_single_coil (mb_handler_t *req_handler, uint8_t slave_addr, uint16_t coil_addr, uint16_t coil_value, uint16_t *resp_addr, uint16_t *resp_value, uint8_t *exception_code, uint32_t timeout)
 
mb_status_t mbmaster_write_single_register (mb_handler_t *req_handler, uint8_t slave_addr, uint16_t register_addr, uint16_t register_value, uint16_t *resp_addr, uint16_t *resp_value, uint8_t *exception_code, uint32_t timeout)
 
mb_status_t mbmaster_write_multiple_coils (mb_handler_t *req_handler, uint8_t slave_addr, uint16_t start_addr, uint16_t quantity, uint8_t *outputs_buf, uint16_t *resp_addr, uint16_t *resp_quantity, uint8_t *exception_code, uint32_t timeout)
 
mb_status_t mbmaster_write_multiple_registers (mb_handler_t *req_handler, uint8_t slave_addr, uint16_t start_addr, uint16_t quantity, uint8_t *outputs_buf, uint16_t *resp_addr, uint16_t *resp_quantity, uint8_t *exception_code, uint32_t timeout)