608 lines
31 KiB
C
608 lines
31 KiB
C
/*
|
||
* hy_protocol.h
|
||
*
|
||
* Created on: 2024年10月11日
|
||
* Author: psx
|
||
*/
|
||
|
||
#ifndef APP_INC_HY_PROTOCOL_H_
|
||
#define APP_INC_HY_PROTOCOL_H_
|
||
|
||
#include "debug.h"
|
||
#include "uart_dev.h"
|
||
#include "math.h"
|
||
|
||
/* 功能码 */
|
||
typedef enum
|
||
{
|
||
HY_batteryStatus = 0x60, /* 电池状态数据报 */
|
||
HY_electricityStatistics = 0x61, /* 电量统计数据报 */
|
||
HY_sensorNumberConfiguration = 0x62, /* 传感器号码配置 */
|
||
HY_sensorNumberInquiry = 0x63, /* 传感器号码查询 */
|
||
HY_chargingThresholdVoltageConfiguration = 0x64, /* 充电阈值电压配置 */
|
||
HY_chargingRangeVoltageQuery = 0x65, /* 充电域值电压查询 */
|
||
HY_resetInstruction = 0x66, /* 复位指令 */
|
||
|
||
HY_chargingControlConfiguration = 0x6C, /* 充电控制配置 */
|
||
HY_chargingControlQuery = 0x6D, /* 充电控制查询 */
|
||
|
||
HY_configureProtocolType = 0x70, /* 配置协议类型 */
|
||
HY_responseConfigureProtocolType = 0x71, /* 响应配置协议类型 */
|
||
|
||
HY_queryControlBoxConfiguration = 0x74, /* 查询电池控制盒当前配置 */
|
||
HY_querySoftwareVersion = 0x75, /* 查询电池控制盒软件版本 */
|
||
HY_enterConfigurationMode = 0x76, /* 进入配置模式 */
|
||
|
||
HY_configureHardwareID = 0x7B, /* 配置控制盒硬件ID号 */
|
||
HY_hardwareID_communicationIDQuery = 0x7C, /* 控制盒硬件ID号及通信ID号(原传感器号)查询 */
|
||
HY_modifyCommunicationID = 0x7D, /* 修改通信ID号(原传感器号) */
|
||
HY_checkMotherboardTemperature = 0x7E, /* 查询主板温度值 */
|
||
|
||
}HY_MsgFunctionCode;
|
||
|
||
|
||
/* 解析数据包的长度 */
|
||
typedef enum
|
||
{
|
||
HY_analyzeStartFlag = 1, /* 长度为1时解析起始标志 */
|
||
HY_analyzeHardwareID = 7, /* 长度为7时解析硬件ID */
|
||
HY_analyzeCommunicationID = 11, /* 长度为10时解析通信ID */
|
||
HY_analyzeControlWord = 12, /* 长度为12时解析控制字 */
|
||
HY_analyzeDataLen = 14, /* 长度为14时解析数据长度 */
|
||
|
||
}HY_AnalyzeDataLen;
|
||
|
||
/* 执行状态 */
|
||
typedef enum
|
||
{
|
||
/* 返回状态 */
|
||
HY_success = 0xFF, /* 成功 */
|
||
HY_fail = 0x00, /* 失败 */
|
||
|
||
/* 返回状态 */
|
||
HY_success1 = 0x01, /* 成功 */
|
||
|
||
/* 充电开关状态 */
|
||
HY_switchON = 0x01, /* 打开 */
|
||
HY_switchOFF = 0x00, /* 关闭 */
|
||
|
||
/* 控制开关状态 */
|
||
HY_cSwitchON = 0x00, /* 打开 */
|
||
HY_cSwitchOFF = 0x01, /* 关闭 */
|
||
|
||
}HY_state;
|
||
|
||
/* 指定对齐方式为1字节 */
|
||
#pragma pack(push,1)
|
||
|
||
/* 通用参数 */
|
||
typedef struct _HY_Recv_pack{
|
||
uint8_t start_Flag; /* 起始标志 */
|
||
uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */
|
||
uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */
|
||
uint8_t controlWord; /* 控制字 */
|
||
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
|
||
}HY_Recv_pack;
|
||
|
||
/* 功能码处理函数 */
|
||
typedef void (*HYMsgProcFunc)(device_handle device, void*, uint32_t MsgLen);
|
||
typedef struct _HY_FunctionMsgProcTable{
|
||
u_int32_t msgId;
|
||
HYMsgProcFunc pMsgProc;
|
||
}HY_FuncionMsgProcTable;
|
||
|
||
|
||
/* 电池状态数据报查询 */
|
||
typedef struct _HY_batteryStatusQuery{
|
||
uint8_t start_Flag; /* 起始标志 */
|
||
uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */
|
||
uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */
|
||
uint8_t controlWord; /* 控制字 */
|
||
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
|
||
uint32_t frameNumber; /* 帧序号 */
|
||
uint8_t check_Bit; /* 校验码 */
|
||
uint8_t end_Flag; /* 结束标志 */
|
||
}HY_batteryStatusQuery;
|
||
#define HY_batteryStatusQuery_PACK_SIZE (sizeof(HY_batteryStatusQuery))
|
||
|
||
/* 电池状态数据报响应 */
|
||
typedef struct _HY_batteryStatusResponse{
|
||
uint8_t start_Flag; /* 起始标志 */
|
||
uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */
|
||
uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */
|
||
uint8_t controlWord; /* 控制字 */
|
||
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
|
||
float_t batteryVoltage; /* 电池电压 */
|
||
float_t dischargCurrent; /* 输出电流(流向负载) */
|
||
float_t chargCurrent1; /* 充电电流(流向电池+负载) */
|
||
float_t SOC; /* 剩余电量 */
|
||
float_t openCircuitVoltage1; /* 充电开路电压 */
|
||
uint8_t chargSwitchStatus1; /* 充电开关状态 */
|
||
float_t chargCurrent2; /* 充电电流(流向电池+负载) */
|
||
float_t openCircuitVoltage2; /* 充电开路电压 */
|
||
uint8_t chargSwitchStatus2; /* 充电开关状态 */
|
||
float_t Mos_Temperature; /* 工作温度 */
|
||
uint32_t frameNumber; /* 帧序号 */
|
||
uint8_t check_Bit; /* 校验码 */
|
||
uint8_t end_Flag; /* 结束标志 */
|
||
}HY_batteryStatusResponse;
|
||
#define HY_batteryStatusResponse_PACK_SIZE (sizeof(HY_batteryStatusResponse))
|
||
#define HY_batteryStatusResponse_dataLen 38
|
||
|
||
/* 电量统计数据报查询 */
|
||
typedef struct _HY_electricityStatisticsQuery{
|
||
uint8_t start_Flag; /* 起始标志 */
|
||
uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */
|
||
uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */
|
||
uint8_t controlWord; /* 控制字 */
|
||
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
|
||
uint32_t frameNumber; /* 帧序号 */
|
||
uint8_t check_Bit; /* 校验码 */
|
||
uint8_t end_Flag; /* 结束标志 */
|
||
}HY_electricityStatisticsQuery;
|
||
#define HY_electricityStatisticsQuery_PACK_SIZE (sizeof(HY_electricityStatisticsQuery))
|
||
|
||
/* 电量统计数据报响应 */
|
||
typedef struct _HY_electricityStatisticsResponse{
|
||
uint8_t start_Flag; /* 起始标志 */
|
||
uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */
|
||
uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */
|
||
uint8_t controlWord; /* 控制字 */
|
||
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
|
||
float_t statisticalDuration; /* 统计时长 */
|
||
float_t totalElectricityConsumption; /* 总电量消耗 */
|
||
float_t totalChargCapacity; /* 总充电电量 */
|
||
uint32_t frameNumber; /* 帧序号 */
|
||
uint8_t check_Bit; /* 校验码 */
|
||
uint8_t end_Flag; /* 结束标志 */
|
||
}HY_electricityStatisticsResponse;
|
||
#define HY_electricityStatisticsResponse_PACK_SIZE (sizeof(HY_electricityStatisticsResponse))
|
||
#define HY_electricityStatisticsResponse_dataLen 16
|
||
|
||
/* 传感器号码配置 */
|
||
typedef struct _HY_sensorNumberConfig{
|
||
uint8_t start_Flag; /* 起始标志 */
|
||
uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */
|
||
uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */
|
||
uint8_t controlWord; /* 控制字 */
|
||
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
|
||
uint32_t frameNumber; /* 帧序号 */
|
||
uint8_t newHardwareID[6]; /* 新硬件ID;高字节在前,低字节在后(保持不变) */
|
||
uint8_t newCommunicationID[4]; /* 新通信ID;高字节在前,低字节在后 */
|
||
uint8_t check_Bit; /* 校验码 */
|
||
uint8_t end_Flag; /* 结束标志 */
|
||
}HY_sensorNumberConfig;
|
||
#define HY_sensorNumberConfiguration_PACK_SIZE (sizeof(HY_sensorNumberConfig))
|
||
|
||
/* 传感器号码配置响应 */
|
||
typedef struct _HY_sensorNumberConfigurationResponse{
|
||
uint8_t start_Flag; /* 起始标志 */
|
||
uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */
|
||
uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */
|
||
uint8_t controlWord; /* 控制字 */
|
||
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
|
||
uint8_t state; /* 状态 */
|
||
uint32_t frameNumber; /* 帧序号 */
|
||
uint8_t check_Bit; /* 校验码 */
|
||
uint8_t end_Flag; /* 结束标志 */
|
||
}HY_sensorNumberConfigurationResponse;
|
||
#define HY_sensorNumberConfigurationResponse_PACK_SIZE (sizeof(HY_sensorNumberConfigurationResponse))
|
||
#define HY_sensorNumberConfigurationResponse_dataLen 5
|
||
|
||
/* 传感器号码查询 */
|
||
typedef struct _HY_sensorNumberInquiryQuery{
|
||
uint8_t start_Flag; /* 起始标志 */
|
||
uint8_t broadcastTerminal[6]; /* 广播终端ID:0xFF 0xFF 0xFF 0xFF 0xFF 0xFF */
|
||
uint8_t broadcastCommunication[4]; /* 广播通信ID:0xFF 0xFF 0xFF 0xFF */
|
||
uint8_t controlWord; /* 控制字 */
|
||
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
|
||
uint32_t frameNumber; /* 帧序号 */
|
||
uint8_t check_Bit; /* 校验码 */
|
||
uint8_t end_Flag; /* 结束标志 */
|
||
}HY_sensorNumberInquiryQuery;
|
||
#define HY_sensorNumberInquiryQuery_PACK_SIZE (sizeof(HY_sensorNumberInquiryQuery))
|
||
|
||
/* 传感器号码查询响应 */
|
||
typedef struct _HY_sensorNumberInquiryResponse{
|
||
uint8_t start_Flag; /* 起始标志 */
|
||
uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */
|
||
uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */
|
||
uint8_t controlWord; /* 控制字 */
|
||
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
|
||
uint8_t hardwareIDR[6]; /* 硬件ID;高字节在前,低字节在后 */
|
||
uint8_t communicationIDR[4]; /* 通信ID;高字节在前,低字节在后 */
|
||
uint32_t frameNumber; /* 帧序号 */
|
||
uint8_t check_Bit; /* 校验码 */
|
||
uint8_t end_Flag; /* 结束标志 */
|
||
}HY_sensorNumberInquiryResponse;
|
||
#define HY_sensorNumberInquiryResponse_PACK_SIZE (sizeof(HY_sensorNumberInquiryResponse))
|
||
#define HY_sensorNumberInquiryResponse_dataLen 14
|
||
|
||
/* 充电阈值电压配置 */
|
||
typedef struct _HY_chargingThresholdVoltageConfig{
|
||
uint8_t start_Flag; /* 起始标志 */
|
||
uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */
|
||
uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */
|
||
uint8_t controlWord; /* 控制字 */
|
||
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
|
||
uint32_t frameNumber; /* 帧序号 */
|
||
float_t chargOpenVoltage; /* 充电开电池电压 */
|
||
float_t chargCloseVoltage; /* 充电关电池电压 */
|
||
uint8_t check_Bit; /* 校验码 */
|
||
uint8_t end_Flag; /* 结束标志 */
|
||
}HY_chargingThresholdVoltageConfig;
|
||
#define HY_chargingThresholdVoltageConfig_PACK_SIZE (sizeof(HY_chargingThresholdVoltageConfig))
|
||
|
||
/* 充电阈值电压配置响应 */
|
||
typedef struct _HY_chargingThresholdVoltageConfigResponse{
|
||
uint8_t start_Flag; /* 起始标志 */
|
||
uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */
|
||
uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */
|
||
uint8_t controlWord; /* 控制字 */
|
||
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
|
||
uint8_t state; /* 状态 */
|
||
uint32_t frameNumber; /* 帧序号 */
|
||
uint8_t check_Bit; /* 校验码 */
|
||
uint8_t end_Flag; /* 结束标志 */
|
||
}HY_chargingThresholdVoltageConfigResponse;
|
||
#define HY_chargingThresholdVoltageConfigResponse_PACK_SIZE (sizeof(HY_chargingThresholdVoltageConfigResponse))
|
||
|
||
|
||
/* 充电域值电压查询 */
|
||
typedef struct _HY_chargRangeVoltageQuery{
|
||
uint8_t start_Flag; /* 起始标志 */
|
||
uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */
|
||
uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */
|
||
uint8_t controlWord; /* 控制字 */
|
||
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
|
||
uint32_t frameNumber; /* 帧序号 */
|
||
uint8_t check_Bit; /* 校验码 */
|
||
uint8_t end_Flag; /* 结束标志 */
|
||
}HY_chargRangeVoltageQuery;
|
||
#define HY_chargRangeVoltageQuery_PACK_SIZE (sizeof(HY_chargRangeVoltageQuery))
|
||
|
||
/* 充电域值电压查询响应 */
|
||
typedef struct _HY_chargRangeVoltageQueryResponse{
|
||
uint8_t start_Flag; /* 起始标志 */
|
||
uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */
|
||
uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */
|
||
uint8_t controlWord; /* 控制字 */
|
||
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
|
||
float_t chargOpenVoltage; /* 充电开电池电压 */
|
||
float_t chargCloseVoltage; /* 充电关电池电压 */
|
||
uint32_t frameNumber; /* 帧序号 */
|
||
uint8_t check_Bit; /* 校验码 */
|
||
uint8_t end_Flag; /* 结束标志 */
|
||
}HY_chargRangeVoltageQueryResponse;
|
||
#define HY_chargRangeVoltageQueryResponse_PACK_SIZE (sizeof(HY_chargRangeVoltageQueryResponse))
|
||
|
||
/* 复位指令 */
|
||
typedef struct _HY_resetInstructionQuery{
|
||
uint8_t start_Flag; /* 起始标志 */
|
||
uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */
|
||
uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */
|
||
uint8_t controlWord; /* 控制字 */
|
||
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
|
||
uint32_t frameNumber; /* 帧序号 */
|
||
uint8_t check_Bit; /* 校验码 */
|
||
uint8_t end_Flag; /* 结束标志 */
|
||
}HY_resetInstructionQuery;
|
||
#define HY_resetInstructionQuery_PACK_SIZE (sizeof(HY_resetInstructionQuery))
|
||
|
||
/* 复位指令响应 */
|
||
typedef struct _HY_resetInstructionResponse{
|
||
uint8_t start_Flag; /* 起始标志 */
|
||
uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */
|
||
uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */
|
||
uint8_t controlWord; /* 控制字 */
|
||
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
|
||
uint8_t state; /* 状态 */
|
||
uint32_t frameNumber; /* 帧序号 */
|
||
uint8_t check_Bit; /* 校验码 */
|
||
uint8_t end_Flag; /* 结束标志 */
|
||
}HY_resetInstructionResponse;
|
||
#define HY_resetInstructionResponse_PACK_SIZE (sizeof(HY_resetInstructionResponse))
|
||
#define HY_resetInstructionResponse_dataLen 5
|
||
|
||
/* 充电控制配置 */
|
||
typedef struct _HY_chargingControlConfig{
|
||
uint8_t start_Flag; /* 起始标志 */
|
||
uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */
|
||
uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */
|
||
uint8_t controlWord; /* 控制字 */
|
||
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
|
||
uint32_t frameNumber; /* 帧序号 */
|
||
uint8_t chargInterface; /* 充电接口 */
|
||
uint8_t chargInterfaceControl; /* 充电接口控制 */
|
||
uint8_t check_Bit; /* 校验码 */
|
||
uint8_t end_Flag; /* 结束标志 */
|
||
}HY_chargingControlConfig;
|
||
#define HY_chargingControlConfig_PACK_SIZE (sizeof(HY_chargingControlConfig))
|
||
|
||
/* 充电控制配置响应 */
|
||
typedef struct _HY_chargingControlConfigResponse{
|
||
uint8_t start_Flag; /* 起始标志 */
|
||
uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */
|
||
uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */
|
||
uint8_t controlWord; /* 控制字 */
|
||
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
|
||
uint8_t state; /* 状态 */
|
||
uint32_t frameNumber; /* 帧序号 */
|
||
uint8_t check_Bit; /* 校验码 */
|
||
uint8_t end_Flag; /* 结束标志 */
|
||
}HY_chargingControlConfigResponse;
|
||
#define HY_chargingControlConfigResponse_PACK_SIZE (sizeof(HY_chargingControlConfigResponse))
|
||
#define HY_chargingControlConfigResponse_dataLen 5
|
||
|
||
/* 充电控制查询 */
|
||
typedef struct _HY_QueryChargingControl{
|
||
uint8_t start_Flag; /* 起始标志 */
|
||
uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */
|
||
uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */
|
||
uint8_t controlWord; /* 控制字 */
|
||
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
|
||
uint32_t frameNumber; /* 帧序号 */
|
||
uint8_t check_Bit; /* 校验码 */
|
||
uint8_t end_Flag; /* 结束标志 */
|
||
}HY_QueryChargingControl;
|
||
#define HY_QueryChargingControl_PACK_SIZE (sizeof(HY_QueryChargingControl))
|
||
|
||
/* 充电控制查询响应 */
|
||
typedef struct _HY_QueryChargingControlResponse{
|
||
uint8_t start_Flag; /* 起始标志 */
|
||
uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */
|
||
uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */
|
||
uint8_t controlWord; /* 控制字 */
|
||
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
|
||
uint8_t chargInterface1; /* 充电接口1状态 */
|
||
uint8_t chargInterface2; /* 充电接口2状态 */
|
||
uint32_t frameNumber; /* 帧序号 */
|
||
uint8_t check_Bit; /* 校验码 */
|
||
uint8_t end_Flag; /* 结束标志 */
|
||
}HY_QueryChargingControlResponse;
|
||
#define HY_QueryChargingControlResponse_PACK_SIZE (sizeof(HY_QueryChargingControlResponse))
|
||
#define HY_QueryChargingControlResponse_dataLen 6
|
||
|
||
/* 配置协议类型 */
|
||
typedef struct _HY_configProtocolType{
|
||
uint8_t start_Flag; /* 起始标志 */
|
||
uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */
|
||
uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */
|
||
uint8_t controlWord; /* 控制字 */
|
||
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
|
||
uint32_t frameNumber; /* 帧序号 */
|
||
uint8_t protocolType; /* 协议类型; 0x01表示:汇源协议(波特率9600) 0x02表示:南瑞协议(波特率115200)*/
|
||
uint8_t check_Bit; /* 校验码 */
|
||
uint8_t end_Flag; /* 结束标志 */
|
||
}HY_configProtocolType;
|
||
#define HY_configProtocolType_PACK_SIZE (sizeof(HY_configProtocolType))
|
||
|
||
/* 配置协议类型响应 */
|
||
typedef struct _HY_configProtocolTypeResponse{
|
||
uint8_t start_Flag; /* 起始标志 */
|
||
uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */
|
||
uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */
|
||
uint8_t controlWord; /* 控制字 */
|
||
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
|
||
uint8_t state; /* 状态 */
|
||
uint32_t frameNumber; /* 帧序号 */
|
||
uint8_t check_Bit; /* 校验码 */
|
||
uint8_t end_Flag; /* 结束标志 */
|
||
}HY_configProtocolTypeResponse;
|
||
#define HY_configProtocolTypeResponse_PACK_SIZE (sizeof(HY_configProtocolTypeResponse))
|
||
#define HY_configProtocolTypeResponse_dataLen 5
|
||
|
||
/* 查询电池控制盒当前配置 */
|
||
typedef struct _HY_queryControlBoxConfigurationQuery{
|
||
uint8_t start_Flag; /* 起始标志 */
|
||
uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */
|
||
uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */
|
||
uint8_t controlWord; /* 控制字 */
|
||
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
|
||
uint32_t frameNumber; /* 帧序号 */
|
||
uint8_t check_Bit; /* 校验码 */
|
||
uint8_t end_Flag; /* 结束标志 */
|
||
}HY_queryControlBoxConfigurationQuery;
|
||
#define HY_queryControlBoxConfigurationQuery_PACK_SIZE (sizeof(HY_queryControlBoxConfigurationQuery))
|
||
|
||
/* 查询电池控制盒当前配置响应 */
|
||
typedef struct _HY_queryControlBoxConfigurationResponse{
|
||
uint8_t start_Flag; /* 起始标志 */
|
||
uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */
|
||
uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */
|
||
uint8_t controlWord; /* 控制字 */
|
||
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
|
||
uint8_t protocolType; /* 协议类型; 0x01表示:汇源协议(波特率9600) 0x02表示:南瑞协议(波特率115200)*/
|
||
uint8_t voltageLevel; /* 电压等级 */
|
||
uint8_t mainBoardTemperatureSensorType; /* 主板温度传感器类型 */
|
||
uint8_t batteryTemperatureSensorType; /* 电池温度传感器类型 */
|
||
uint32_t frameNumber; /* 帧序号 */
|
||
uint8_t check_Bit; /* 校验码 */
|
||
uint8_t end_Flag; /* 结束标志 */
|
||
}HY_queryControlBoxConfigurationResponse;
|
||
#define HY_queryControlBoxConfigurationResponse_PACK_SIZE (sizeof(HY_queryControlBoxConfigurationResponse))
|
||
#define HY_queryControlBoxConfigurationResponse_dataLen 8
|
||
|
||
/* 查询电池控制盒软件版本 */
|
||
typedef struct _HY_SoftwareVersionQuery{
|
||
uint8_t start_Flag; /* 起始标志 */
|
||
uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */
|
||
uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */
|
||
uint8_t controlWord; /* 控制字 */
|
||
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
|
||
uint32_t frameNumber; /* 帧序号 */
|
||
uint8_t check_Bit; /* 校验码 */
|
||
uint8_t end_Flag; /* 结束标志 */
|
||
}HY_SoftwareVersionQuery;
|
||
#define HY_SoftwareVersionQuery_PACK_SIZE (sizeof(HY_SoftwareVersionQuery))
|
||
|
||
/* 查询电池控制盒软件版本响应 */
|
||
typedef struct _HY_SoftwareVersionQueryResponse{
|
||
uint8_t start_Flag; /* 起始标志 */
|
||
uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */
|
||
uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */
|
||
uint8_t controlWord; /* 控制字 */
|
||
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
|
||
uint8_t versionInformation[13]; /* 版本信息 */
|
||
uint32_t frameNumber; /* 帧序号 */
|
||
uint8_t check_Bit; /* 校验码 */
|
||
uint8_t end_Flag; /* 结束标志 */
|
||
}HY_SoftwareVersionQueryResponse;
|
||
#define HY_SoftwareVersionQueryResponse_PACK_SIZE (sizeof(HY_SoftwareVersionQueryResponse))
|
||
#define HY_SoftwareVersionQueryResponse_dataLen 17
|
||
|
||
/* 进入配置模式 */
|
||
typedef struct _HY_enterConfigMode{
|
||
uint8_t start_Flag; /* 起始标志 */
|
||
uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */
|
||
uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */
|
||
uint8_t controlWord; /* 控制字 */
|
||
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
|
||
uint32_t frameNumber; /* 帧序号 */
|
||
uint8_t check_Bit; /* 校验码 */
|
||
uint8_t end_Flag; /* 结束标志 */
|
||
}HY_enterConfigMode;
|
||
#define HY_enterConfigMode_PACK_SIZE (sizeof(HY_enterConfigMode))
|
||
|
||
/* 进入配置模式响应 */
|
||
typedef struct _HY_enterConfigModeResponse{
|
||
uint8_t start_Flag; /* 起始标志 */
|
||
uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */
|
||
uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */
|
||
uint8_t controlWord; /* 控制字 */
|
||
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
|
||
uint8_t state; /* 状态 */
|
||
uint32_t frameNumber; /* 帧序号 */
|
||
uint8_t check_Bit; /* 校验码 */
|
||
uint8_t end_Flag; /* 结束标志 */
|
||
}HY_enterConfigModeResponse;
|
||
#define HY_enterConfigModeResponse_PACK_SIZE (sizeof(HY_enterConfigModeResponse))
|
||
#define HY_enterConfigModeResponse_dataLen 5
|
||
|
||
/* 配置控制盒硬件ID号 */
|
||
typedef struct _HY_configHardwareID{
|
||
uint8_t start_Flag; /* 起始标志 */
|
||
uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */
|
||
uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */
|
||
uint8_t controlWord; /* 控制字 */
|
||
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
|
||
uint32_t frameNumber; /* 帧序号 */
|
||
uint8_t newHardwareID[6]; /* 新硬件ID;高字节在前,低字节在后 */
|
||
uint8_t check_Bit; /* 校验码 */
|
||
uint8_t end_Flag; /* 结束标志 */
|
||
}HY_configHardwareID;
|
||
#define HY_configHardwareID_PACK_SIZE (sizeof(HY_configHardwareID))
|
||
|
||
/* 配置控制盒硬件ID号 响应*/
|
||
typedef struct _HY_configHardwareIDResponse{
|
||
uint8_t start_Flag; /* 起始标志 */
|
||
uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */
|
||
uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */
|
||
uint8_t controlWord; /* 控制字 */
|
||
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
|
||
uint8_t state; /* 状态 */
|
||
uint32_t frameNumber; /* 帧序号 */
|
||
uint8_t check_Bit; /* 校验码 */
|
||
uint8_t end_Flag; /* 结束标志 */
|
||
}HY_configHardwareIDResponse;
|
||
#define HY_configHardwareIDResponse_PACK_SIZE (sizeof(HY_configHardwareIDResponse))
|
||
#define HY_configHardwareIDResponse_dataLen 5
|
||
|
||
/* 控制盒硬件ID号及通信ID号(原传感器号)查询 */
|
||
typedef struct _HY_QueryhardwareID_communicationID{
|
||
uint8_t start_Flag; /* 起始标志 */
|
||
uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */
|
||
uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */
|
||
uint8_t controlWord; /* 控制字 */
|
||
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
|
||
uint32_t frameNumber; /* 帧序号 */
|
||
uint8_t check_Bit; /* 校验码 */
|
||
uint8_t end_Flag; /* 结束标志 */
|
||
}HY_QueryhardwareID_communicationID;
|
||
#define HY_QueryhardwareID_communicationID_PACK_SIZE (sizeof(HY_QueryhardwareID_communicationID))
|
||
|
||
/* 控制盒硬件ID号及通信ID号(原传感器号)查询响应 */
|
||
typedef struct _HY_QueryhardwareID_communicationIDResponse{
|
||
uint8_t start_Flag; /* 起始标志 */
|
||
uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */
|
||
uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */
|
||
uint8_t controlWord; /* 控制字 */
|
||
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
|
||
uint8_t hardwareIDR[6]; /* 硬件ID;高字节在前,低字节在后 */
|
||
uint8_t communicationIDR[4]; /* 通信ID;高字节在前,低字节在后 */
|
||
uint32_t frameNumber; /* 帧序号 */
|
||
uint8_t check_Bit; /* 校验码 */
|
||
uint8_t end_Flag; /* 结束标志 */
|
||
}HY_QueryhardwareID_communicationIDResponse;
|
||
#define HY_QueryhardwareID_communicationIDResponse_PACK_SIZE (sizeof(HY_QueryhardwareID_communicationIDResponse))
|
||
#define HY_QueryhardwareID_dataLen 14
|
||
|
||
/* 修改通信ID号(原传感器号) */
|
||
typedef struct _HY_modifyCommunicationIDChange{
|
||
uint8_t start_Flag; /* 起始标志 */
|
||
uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */
|
||
uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */
|
||
uint8_t controlWord; /* 控制字 */
|
||
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
|
||
uint32_t frameNumber; /* 帧序号 */
|
||
uint8_t newHardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */
|
||
uint8_t newCommunicationID[4]; /* 新通信ID;高字节在前,低字节在后 */
|
||
uint8_t check_Bit; /* 校验码 */
|
||
uint8_t end_Flag; /* 结束标志 */
|
||
}HY_modifyCommunicationIDChange;
|
||
#define HY_modifyCommunicationIDChange_PACK_SIZE (sizeof(HY_modifyCommunicationIDChange))
|
||
|
||
/* 修改通信ID号(原传感器号)响应 */
|
||
typedef struct _HY_modifyCommunicationIDChangeResponse{
|
||
uint8_t start_Flag; /* 起始标志 */
|
||
uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */
|
||
uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */
|
||
uint8_t controlWord; /* 控制字 */
|
||
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
|
||
uint8_t state; /* 状态 */
|
||
uint32_t frameNumber; /* 帧序号 */
|
||
uint8_t check_Bit; /* 校验码 */
|
||
uint8_t end_Flag; /* 结束标志 */
|
||
}HY_modifyCommunicationIDChangeResponse;
|
||
#define HY_modifyCommunicationIDChangeResponse_PACK_SIZE (sizeof(HY_modifyCommunicationIDChangeResponse))
|
||
#define HY_modifyCommunicationIDChangeResponse_dataLen 5
|
||
|
||
/* 查询主板温度值 */
|
||
typedef struct _HY_checkMotherboardTemperatureQuery{
|
||
uint8_t start_Flag; /* 起始标志 */
|
||
uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */
|
||
uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */
|
||
uint8_t controlWord; /* 控制字 */
|
||
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
|
||
uint32_t frameNumber; /* 帧序号 */
|
||
uint8_t check_Bit; /* 校验码 */
|
||
uint8_t end_Flag; /* 结束标志 */
|
||
}HY_checkMotherboardTemperatureQuery;
|
||
#define HY_checkMotherboardTemperatureQuery_PACK_SIZE (sizeof(HY_checkMotherboardTemperatureQuery))
|
||
|
||
/* 查询主板温度值响应 */
|
||
typedef struct _HY_checkMotherboardTemperatureResponse{
|
||
uint8_t start_Flag; /* 起始标志 */
|
||
uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */
|
||
uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */
|
||
uint8_t controlWord; /* 控制字 */
|
||
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
|
||
float_t MotherboardTemperature; /* 主板温度 */
|
||
uint32_t frameNumber; /* 帧序号 */
|
||
uint8_t check_Bit; /* 校验码 */
|
||
uint8_t end_Flag; /* 结束标志 */
|
||
}HY_checkMotherboardTemperatureResponse;
|
||
#define HY_checkMotherboardTemperatureResponse_PACK_SIZE (sizeof(HY_checkMotherboardTemperatureResponse))
|
||
#define HY_checkMotherboardTemperatureResponse_dataLen 8
|
||
|
||
/* 恢复默认的对齐设置 */
|
||
#pragma pack(pop)
|
||
|
||
|
||
uint8_t HY_CheckFunc(uint8_t *arr_buff, uint8_t len);
|
||
void HY_read_and_process_uart_data(device_handle device);
|
||
|
||
|
||
|
||
#endif /* APP_INC_HY_PROTOCOL_H_ */
|