You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.0 KiB
C
50 lines
1.0 KiB
C
#ifndef __PD_MODBUS_H__
|
|
#define __PD_MODBUS_H__
|
|
|
|
#ifdef CFG_DEV_TYPE_LAND_PD
|
|
|
|
#define WRITE 1
|
|
#define READ 0
|
|
|
|
#define MODBUS_IR_CURRENT_ADDR 0x0 // 铁芯
|
|
#define MODBUS_IR_CURRENT_LEN 2
|
|
#define MODBUS_DC_CURRENT_ADDR 0x34 // 直流偏磁
|
|
#define MODBUS_DC_CURRENT_LEN 2
|
|
|
|
#define MODBUS_UNIT_IR 0x01
|
|
|
|
#define MODBUS_CURRENT_LEN 4
|
|
#define MODBUS_ADDR_ALARM 0x32
|
|
#define MODBUS_ALARM_LEN 2
|
|
|
|
|
|
// 定义Modbus TCP MBAP头
|
|
//#pragma pack(push, 1)
|
|
typedef struct
|
|
{
|
|
uint16_t transaction_id; // 事务处理标识
|
|
uint16_t protocol_id; // 协议标识
|
|
uint16_t length; // 数据长度
|
|
uint8_t unit_id; // 设备地址
|
|
uint8_t function_code; // 功能码
|
|
} modbus_tcp_t;
|
|
//#pragma pack(pop)
|
|
|
|
typedef struct
|
|
{
|
|
uint8_t function;
|
|
uint16_t address;
|
|
uint16_t length;
|
|
} pdu_t;
|
|
|
|
typedef struct
|
|
{
|
|
int fd;
|
|
uint8_t txbuf[512];
|
|
uint8_t rxbuf[512];
|
|
}modbus_t;
|
|
|
|
extern int32_t modbus_handle_init_after(void);
|
|
#endif
|
|
#endif
|