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.
55 lines
1.4 KiB
C
55 lines
1.4 KiB
C
#ifndef _MODBUS_H
|
|
#define _MODBUS_H
|
|
|
|
#include "crc.h"
|
|
#include "common.h"
|
|
#include "string.h"
|
|
#include "sjzd_serial.h"
|
|
|
|
#define FRM_ERR_NONE 0
|
|
#define FRM_ERR_START -1
|
|
#define FRM_ERR_RX_TIMEOUT -2
|
|
#define FRM_ERR_SLAVE_ADDR -3
|
|
#define FRM_ERR_FC -4
|
|
#define FRM_ERR_BYTE_COUNT -5
|
|
#define FRM_ERR_CRC -6
|
|
|
|
|
|
#define MAX_PAYLOAD_SIZE 1024
|
|
#define FRM_MAX_LEN (MAX_PAYLOAD_SIZE+8)
|
|
#define FRM_HEADER_LEN 4
|
|
|
|
#define SJZD_RD_REGS 1
|
|
#define SJZD_WR_REGS 2
|
|
#define SJZD_RD_FILE_START 3
|
|
#define SJZD_RD_FILE_CONTENT 4
|
|
#define SJZD_RD_FILE_END 5
|
|
|
|
typedef struct
|
|
{
|
|
float AccPri[19];
|
|
float AccSec[7];
|
|
float EnvNoiPri;
|
|
float EnvNoiSec;
|
|
float NeuCur;
|
|
int MoDevConf;
|
|
int MoDevDetF;
|
|
int MoDevSigF;
|
|
int ModevPowF;
|
|
int EnvNoiPriAlm;
|
|
int EnvNoiSecAlm;
|
|
int NeuCurAlm;
|
|
int AccPriAlm[19];
|
|
int AccSecAlm[7];
|
|
}SVBR_PRI_TYPE;
|
|
|
|
|
|
int32_t sjzd_master_init(char *port,char *baud,char *parity);
|
|
int32_t sjzd_make_frm(uint8_t *enc_buf,uint8_t slave_addr,uint8_t cmd,uint8_t *data,uint16_t data_len);
|
|
int32_t sjzd_chk_frm(uint8_t *buf,uint16_t len,uint8_t slave_addr,uint8_t cmd);
|
|
|
|
int32_t sjzd_reg_rd(uint8_t slave_node,uint32_t reg_addr,uint8_t *reg_tbl,uint32_t nbr_reg);
|
|
int32_t sjzd_reg_wr(uint8_t slave_node,uint32_t reg_addr,uint8_t *reg_tbl,uint32_t nbr_reg,uint8_t *rlt);
|
|
int32_t sjzd_file_rd(uint8_t slave_node,char *in_file,char *out_file);
|
|
|
|
#endif |