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.
72 lines
1.8 KiB
C
72 lines
1.8 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+18)
|
|
#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;
|
|
|
|
typedef struct
|
|
{
|
|
uint32_t has_new_data;
|
|
uint32_t new_data_len;
|
|
uint32_t data_timestamp;
|
|
uint32_t rsv;
|
|
} SLAVE_REG_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);
|
|
void SJZD_file_analysis(uint8_t slave_addr,char *curr_file,float sensor_range);
|
|
int cmp(const void *a, const void *b);
|
|
void fault_up(char dev_fault);
|
|
void heartbeat(char dev_num);
|
|
int relay_init(void);
|
|
int relay_on(void);
|
|
int relay_off(void);
|
|
void sensor_fault(char slave_addr,char sensor_err);
|
|
void SJZD_file_analysis_nodata(uint8_t slave_addr);
|
|
#endif |