Commit f3e5466d authored by 何锐's avatar 何锐

feat:修改版本号校验

parent e4cbe3d2
......@@ -38,7 +38,6 @@ static uint32_t Protocol_UartRead1(uint8_t *pData, uint32_t len);//扫码枪
static uint32_t Protocol_UartRead2(uint8_t *pData, uint32_t len);//esp32
uint8_t nowdata[4];
uint8_t lastdata[4];
uint8_t checkresult;
uint8_t sendmsg[8];
uint8_t timenum = 0;
uint8_t firstflag = 0;
......
......@@ -73,24 +73,30 @@ void Function_Check_Ctrl(uint32_t cmd);
void MENU_CHECK_STEP_ADD(void)
{
if(jiaoyan == 1)
if(CheckResult != 1) //版本号校验,取消校验屏掉此条
{
if(guangganflag == 3) //光感锁
{
MENU_CHECK_STEP++;
if((CurrentWrong == 1) && (MENU_CHECK_STEP == 2))
{
MENU_CHECK_STEP = 1;
}
}
if(MENU_CHECK_STEP > 9) //循环
{
MENU_CHECK_STEP = 0;
guangganflag = 0;
}
return ;
}
if(guangganflag != 3) //光感锁校验,取消校验屏掉此条
{
return ;
}
if((CurrentWrong == 1) && (MENU_CHECK_STEP == 2)) //静态电流校验,取消校验屏掉此条
{
return ;
}
if(MENU_CHECK_STEP <= 9)
{
MENU_CHECK_STEP++;
}
else //循环
{
MENU_CHECK_STEP = 0;
guangganflag = 0;
}
}
void MENU_CHECK_STEP_SUB(void)
{
......
......@@ -12,7 +12,26 @@
#include "Analog_Signals.h"
#include "FreIn_User.h"
#include "Key.h"
// clang-format off
#include <stdio.h>
#define PN_Length 15 //零件号长度
typedef struct {
const char *part;
const char *ver1;
const char *ver2;
const char *ver3;
} PartVersion;
static const PartVersion g_versionTable[] = {
//零件号 MCU版本号(普冉) SOC版本号(7926) 蓝牙芯片版本号(7106)
{"37100-A197-0400", "1.43", "1.43", "1.43"},
{"37100-A265-0200", "1.22", "1.22", "1.43"},
{"37100-G389-0200", "1.22", "1.22", "1.43"},
{NULL, NULL, NULL, NULL} // 结束标志
};
uint8_t checkresult = 0; //校验结果
uint8_t CurrentPN = 0xFF; //当前零件号
uint32_t Display_Menu_Type;
uint32_t Page_Refresh = 1;
uint32_t PageNum_history = 0xff;
......@@ -4734,6 +4753,62 @@ void Check_PWM(void)
uint32_t test = Duty_VEHICLE / 10;
GUI_General_Digit_Display(test, Num_15, 3, 1, testNum, 160);
}
//将接收到的零件号转化为字符串格式
void bytesToString(const uint8_t *bytes, int len, char *out) {
for (int i = 0; i < len; i++) {
out[i] = (char)bytes[i];
}
out[len] = '\0';
}
//将接收到的版本号转换为字符串格式
void makeVersionString(int major, int minor, char *out) {
sprintf(out, "%d.%02d", major, minor); // 次版本固定两位,不足补零
}
//遍历表格寻找零件号,对比校验
int checkVersion(const char *partStr,
const char *curVerStr_mcu,
const char *curVerStr_soc,
const char *curVerStr_bt) {
for (int i = 0; g_versionTable[i].part != NULL; i++) {
if (strcmp(g_versionTable[i].part, partStr) == 0) {
CurrentPN = i;
if ((strcmp(curVerStr_mcu, g_versionTable[i].ver1) +
strcmp(curVerStr_soc, g_versionTable[i].ver2) +
strcmp(curVerStr_bt, g_versionTable[i].ver3)) == 0) {
return 1; // 匹配
} else {
return 2; // 不匹配
}
}
}
return 3; // 零件号不存在
}
uint8_t onReceive(const uint8_t *pnBytes,
int pnLen,
int major_mcu,
int minor_mcu,
int major_soc,
int minor_soc,
int major_bt,
int minor_bt)
{
char partStr[32];
char curVerStr_mcu[16];
char curVerStr_soc[16];
char curVerStr_bt[16];
bytesToString(pnBytes, pnLen, partStr);
makeVersionString(major_mcu, minor_mcu, curVerStr_mcu);
makeVersionString(major_soc, minor_soc, curVerStr_soc);
makeVersionString(major_bt, minor_bt, curVerStr_bt);
uint8_t result = checkVersion(partStr, curVerStr_mcu, curVerStr_soc, curVerStr_bt);
}
uint32_t leftvoltage;
uint32_t rightvoltage;
uint8_t firstclearflag = 0;
......@@ -4749,7 +4824,7 @@ uint8_t TCSflaglast;
uint8_t SlopeDescentflaglast;
uint8_t RampParkflaglast;
uint8_t Autoheadlightflaglast;
uint8_t jiaoyan = 0;
uint8_t CheckResult = 0;
uint8_t up_key_press_number;
void Display_Version_Info(uint32_t ON_OFF)
{
......@@ -4904,6 +4979,15 @@ void Display_Version_Info(uint32_t ON_OFF)
wuliao[14] = R485_IDB4h.Sig.MaterialCode15;
wuliao[15] = 0xFF;
CheckResult = onReceive(wuliao,
PN_Length,
R485_IDB4h.Sig.PY32F072_APP_PV,
R485_IDB4h.Sig.PY32F072_APP_SV,
R485_IDB4h.Sig.JL7926_APP_PV,
R485_IDB4h.Sig.JL7926_APP_SV,
R485_IDB4h.Sig.JL7106_APP_PV,
R485_IDB4h.Sig.JL7106_APP_SV);
if(wuliao[12] == 0x32) //4.3寸
{
nowpuran = 18;
......@@ -4998,30 +5082,15 @@ void Display_Version_Info(uint32_t ON_OFF)
TFT_LCD_Draw_Bmp(3, 90+25+25+30+30+30+5, ( uint8_t * )gImage_gImage_LEDwaif1X6_Y16 ); //硬线指示灯外发对比
TFT_LCD_Draw_Bmp(3, 90+25+25+30+25+30+30+5, ( uint8_t * )gImage_gImage_SV1X6_Y16 ); //软件版本号对比
if((puranhoumian + houmian7926 + houmian7106) != 0)
if(CheckResult == 1)
{
jiaoyan = 2;
if((puranhoumian == nowpuran) && (houmian7926 == now7926) && (houmian7106 == now7106) && \
((R485_IDB4h.Sig.PY32F072_APP_PV == 1) && (R485_IDB4h.Sig.JL7926_APP_PV == 1) && (R485_IDB4h.Sig.JL7106_APP_PV == 1)))
{
TFT_LCD_Draw_Bmp(200, 90+25+25+30+25+30+30, ( uint8_t * )gImage_dui ); //软件版本号对比 对
jiaoyan = 1;
}
else
{
TFT_LCD_Draw_Bmp(200, 90+25+25+30+25+30+30, ( uint8_t * )gImage_cuo ); //软件版本号对比 错
//正在调试取消版本号对比 想要取消版本号对比将上方注释掉并解开下方注释即可
// TFT_LCD_Draw_Bmp(200, 90+25+25+30+25+30+30, ( uint8_t * )gImage_dui ); //软件版本号对比 对
// firstpowerflag = 2;
}
TFT_LCD_Draw_Bmp(200, 90+25+25+30+25+30+30, ( uint8_t * )gImage_dui ); //软件版本号对比 对
}
else
{
TFT_LCD_Draw_Bmp(200, 90+25+25+30+25+30+30, ( uint8_t * )gImage_cuo ); //软件版本号对比 错
}
// TFT_LCD_Draw_Bmp(200, 90+25+25+30+25+25, ( uint8_t * )gImage_cuo ); //软件版本号对比 错
// TFT_LCD_Draw_Bmp(3, 90+25+25+25+25+25, ( uint8_t * )gImage_gImage_SV1X6_Y16 ); //支持扫码功能个
......
......@@ -102,7 +102,7 @@ extern void Get_static_Current(void);
extern uint32_t Get_Display_Type(void);
extern uint8_t guangganflag;
extern uint8_t CurrentWrong;
extern uint8_t jiaoyan;
extern uint8_t CheckResult;
extern const uint8_t *Num_15[];
#define PCodeText_Space_size 2//故障文字 英文空格的像素数
#endif
......@@ -407,7 +407,7 @@ void EnterVersionNumber(void)
if(enterdelaytime <= 600) //等待开机动画
{
if((jiaoyan == 1) || (jiaoyan == 2))
if(CheckResult != 0)
{
if(entermenutime <= 200)
{
......
......@@ -127,12 +127,12 @@ void Sys_Startup_Init(void)
EN_5V_CUT_ENABLE = 1;
Display_TFT_Clear();
GUI_Display_Version_Code_Service(25, 20, "Please Scan The Code ", Letter_Num_11, PCodeText_Space_size);
// Display_TFT_Clear();
// GUI_Display_Version_Code_Service(25, 20, "Please Scan The Code ", Letter_Num_11, PCodeText_Space_size);
/*上电扫码校验功能如果需要扫码校验注释掉firstpowerflag = 2,saomafinish = 3;打开上面两行的注释即可*/
// firstpowerflag = 2;
// saomafinish = 4;
firstpowerflag = 2;
saomafinish = 4;
}
/***********************************************************************
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment