#ifndef _DN_485_H_ #define _DN_485_H_ #include "../Hardware/boardinit.h" #include "public.h" #include "xspDataOpt.h" /*-------------------------------------系统指令 --------------------*/ #define SYSTEM_1001_LEN 13 #define SYSTEM_2030_LEN 24 #define SYSTEM_1030_LEN 16 typedef struct _system_0x1021_{ // 系统类指令 重启 uint8_t object; // 重启对象 uint8_t info[2]; // 用于存储crc 校验码 }__attribute__((packed))system0x1021; typedef struct _system_0x1015_{ // 系统类指令 时间同步 uint32_t timer; // 时间戳 uint32_t reserve; // 预留 }__attribute__((packed))system0x1015; typedef struct _sys_cmd_1026_{ uint8_t priceInuseCout; // 对于单价屏是否探针板接线 uint8_t confFileNum[8]; //配置文件编号 uint16_t appointDevModel; // 配置文件适配设备类型 uint8_t portStatus; // 端口是否启用 uint8_t portNum[4]; // 每个端口连接针脚的个数 uint8_t comGroup; // com端的级数 uint8_t param[4][4]; // 一共4组,每组4个参数 }__attribute__((packed))sysCmd1026; typedef struct _system_0x1026_{ // 系统类指令 com端文件配置 uint32_t reserve; // 预留 不需要存储EPPROM -4 uint16_t expireTime; // 过期时间 不需要存储EPPROM -2 uint8_t priceInuseCout; // 对于单价屏是否探针板接线 uint8_t confFileNum[8]; //配置文件编号 uint16_t appointDevModel; // 配置文件适配设备类型 uint8_t portStatus; // 端口是否启用 uint8_t portNum[4]; // 每个端口连接针脚的个数 uint8_t comGroup; // com端的级数 uint8_t param[4][4]; // 一共4组,每组4个参数 }__attribute__((packed))system0x1026; typedef struct _sys_cmd_1027_{ uint8_t confFileNum[8]; //配置文件编号 uint16_t appointDevModel; // 配置文件适配设备类型 uint8_t groupNum; // 组数 uint8_t table[300][2]; // 表的说明 }__attribute__((packed))sysCmd1027; extern sysCmd1027 g_table1027; extern sysCmd1027 g_temtable1027; // ???±±í typedef struct _sys_0x1027_{ uint32_t reserve; // 预留 uint16_t expireTime; // 过期时间 uint8_t framNo; // 帧号 sysCmd1027 da1027; }__attribute__((packed))system0x1027; typedef struct _sys_0x1028_{ uint32_t time; // 开启时常 }__attribute__((packed))system0x1028; typedef struct _sys_0x1029_{ uint8_t status; // 保存状态 1:保存 2:放弃 }__attribute__((packed))system0x1029; typedef struct _sys_0x1030_{ uint32_t reserve; uint8_t info[2];//用于校验位 }__attribute__((packed))system0x1030; typedef struct _sys_0x2030_{ uint8_t configfileNo[8]; //配置文件编号 uint32_t reserve; //预留 }__attribute__((packed))system0x2030; typedef union _system_cmd_table_{ system0x1021 s0x1021; system0x1015 s0x1015; system0x1026 s0x1026; // com端配置文件 system0x1027 s0x1027; // 探针脚配置文件 system0x1028 s0x1028; // 开启8段码上报 system0x1029 s0x1029; // 关闭8段码上报 system0x1030 s0x1030; // 读取8段数据 system0x2030 s0x2030; // 上报8段码数据 }__attribute__((packed))systemCmdTable; typedef struct _system_cmd_{ uint16_t devTypeM; uint32_t devSnM; uint16_t devTypeS; uint32_t devSnS; systemCmdTable sDa; }__attribute__((packed))systemCmd; /*-------------------------------------状态指令 --------------------*/ enum { SELF_STATUS = 0x02, SLAVE_OFFLINE = 0x03, }; typedef struct _status_0x2002_{ uint16_t devTypeM; //主设备类型 uint32_t devSnM; //主设备SN uint16_t devTypeS; //从设备类型 uint32_t devSnS; //从设备SN uint8_t cfgFileNo[8]; //配置文件编号 uint8_t identity; //主从身份 1:从 2:主 uint8_t bHave4G; //是否有4G模块 0:无 1:有 uint8_t status; //在线状态 0:离线 1:在线 uint8_t lastResetType; // 最后一次复位类型 uint32_t resetNum; // 复位次数 uint32_t runTime; // 运行时常 uint32_t voltage; // 电压 uint32_t temperature; // 温度 uint16_t rssi4G; // 4G强度 uint16_t snr4G; // 4G信噪比 uint32_t tempStamp; // 时间戳 uint32_t reserve; }__attribute__((packed))status0x2002; typedef struct _status_0x2001_{ uint16_t devTypeM; // 主设备类型 uint32_t devSnM; // 主设备SN uint16_t devTypeS; // 从设备类型 uint32_t devSnS; // 从设备SN uint8_t upCode; // 升级状态码 uint32_t bootVer; // bootloader版本 uint32_t ptVer; // pt版本 uint32_t appVer; // app版本 uint8_t uuid[12]; // UUID uint8_t imei[15]; // imei uint8_t iccid[20]; // iccid uint32_t reserve; // 预留 }__attribute__((packed))status0x2001; #define STATUS_COMM_LEN 12 typedef struct _status_comm_msg_{ uint16_t devTypeM; uint32_t devSnM; uint16_t devTypeS; uint32_t devSnS; uint8_t info[2]; }__attribute__((packed))statCom; /*-------------------------------------数据指令 --------------------*/ #define DATA_1061_LEN 20 typedef struct _data_0x1061_{ uint16_t devTypeM; uint32_t devSnM; uint16_t devTypeS; uint32_t devSnS; uint32_t recordId; uint32_t reserve; uint8_t info[2]; }__attribute__((packed))data0x1061; #define DATA_2061_LEN 18 typedef struct _data_0x2061_{ uint16_t devTypeM; uint32_t devSnM; uint16_t devTypeS; uint32_t devSnS; uint32_t reserve; uint8_t bnewflag; // 新交易标识 uint8_t palen; // 参数长度 uint8_t info[160]; }__attribute__((packed))data0x2061; #define LOG_2062_LEN 17 typedef struct _log_0x2062_{ uint16_t devTypeM; uint32_t devSnM; uint16_t devTypeS; uint32_t devSnS; uint32_t reserve; uint8_t palen; // 参数长度 uint8_t info[160]; }__attribute__((packed))log0x2062; #define LOG_1062_LEN 21 typedef struct _log_0x1062_{ uint16_t devTypeM; uint32_t devSnM; uint16_t devTypeS; uint32_t devSnS; uint8_t logType; // 日志类型 uint32_t time; // 开启日志的时间 uint32_t reserve; // 预留 }__attribute__((packed))log0x1062; #define LOG_2063_LEN 18 typedef struct _log_0x2063_{ uint16_t devTypeM; uint32_t devSnM; uint16_t devTypeS; uint32_t devSnS; uint8_t logtype; // 1:错误七段码上 2:log 日志 3:信号错误率 uint32_t reserve; uint8_t palen; // 参数长度 uint8_t info[256]; }__attribute__((packed))log0x2063; #define LOG_1063_LEN 22 typedef struct _log_0x1063_{ uint16_t devTypeM; uint32_t devSnM; uint16_t devTypeS; uint32_t devSnS; uint8_t logType; // 日志类型 1: 去重七段码上报 2:lg日志 3: 信号采集率调试 uint32_t time; // 开启日志的时间(秒) 0: 关闭 非0:开始时长 uint8_t interval; // 间隔上报 秒 uint32_t reserve; // 预留 }__attribute__((packed))log0x1063; /*----------------------------------升级指令-------------------------*/ typedef struct _update_0x1001_{ uint16_t devType; uint32_t devSn; uint16_t taskId; // 任务号 uint32_t reserve; // 预留 }__attribute__((packed))update0x1001; typedef struct _update_0x2001_{ uint16_t devType; uint32_t devSn; uint32_t appVer; uint16_t taskId; uint32_t reserve; }__attribute__((packed))update0x2001; typedef union _update_info_{ update0x1001 up0x1001; update0x2001 up0x2001; }__attribute__((packed))updateCmd; /*------------------------------------------------------------------*/ typedef union _comm_info_{ //system0x1021 sys1021; systemCmd sysMsg; statCom statusMsg; updateCmd upMsg; data0x1061 da1061; data0x2061 da2061; log0x1062 lg1062; log0x2062 lg2062; log0x1063 lg1063; log0x2063 lg2063; uint8_t info[256]; }__attribute__((packed))commInfo_t; #define COMM_HEAD_LEN 12 typedef struct _HEAD_DATA_{ uint16_t start; uint8_t proVer; uint32_t msgId; uint8_t msgType1; uint16_t msgType2; uint16_t palen; commInfo_t comInfo; }__attribute__((packed))MasterSlave; extern void slave_send_data_to_uart(uint8_t type1, uint16_t type2,uint8_t *data,uint8_t len); extern void slave_send_log_0x2063(uint16_t devType, uint32_t devSn,uint8_t logtype,uint8_t *data, uint8_t len); extern void slave_send_data_0x2030(uint16_t devType, uint32_t devSn,uint8_t *data,uint8_t *cfigNo, uint8_t len); extern void analysis_cmd_system(uint16_t cmd, uint8_t *data,uint8_t len); extern void analysis_cmd_status(uint16_t cmd, uint8_t *data,uint8_t len); extern void analysis_cmd_data(uint16_t cmd,uint8_t *data,uint8_t len); extern void analysis_cmd_update(uint16_t cmd,uint8_t *data,uint8_t len); extern void analysis_cmd_log(uint16_t cmd,uint8_t *data,uint8_t len); #endif