Commit da554a8b authored by 何锐's avatar 何锐

feat:更新版本号校验

parent 5f521800
...@@ -29,7 +29,6 @@ static uint32_t Protocol_UartRead1(uint8_t *pData, uint32_t len);//扫码枪 ...@@ -29,7 +29,6 @@ static uint32_t Protocol_UartRead1(uint8_t *pData, uint32_t len);//扫码枪
static uint32_t Protocol_UartRead2(uint8_t *pData, uint32_t len);//esp32 static uint32_t Protocol_UartRead2(uint8_t *pData, uint32_t len);//esp32
uint8_t nowdata[4]; uint8_t nowdata[4];
uint8_t lastdata[4]; uint8_t lastdata[4];
uint8_t checkresult;
uint8_t sendmsg[8]; uint8_t sendmsg[8];
uint8_t timenum = 0; uint8_t timenum = 0;
uint8_t firstflag = 0; uint8_t firstflag = 0;
......
...@@ -70,23 +70,37 @@ void Function_Check_Ctrl(uint32_t cmd); ...@@ -70,23 +70,37 @@ void Function_Check_Ctrl(uint32_t cmd);
void MENU_CHECK_STEP_ADD(void) void MENU_CHECK_STEP_ADD(void)
{ {
MENU_CHECK_STEP++; if(checkresult != 1) //版本号检验,如果取消版本号校验屏蔽此条
{
return ;
}
if(MENU_CHECK_STEP > 17) if(AutoCheck == 1) //光感校验,如果取消光感校验屏蔽此条(开发测试使用,正常自动判别在Display_Ctrl.c文件)
{ {
MENU_CHECK_STEP = 0; if((guangganflag != 3) && (MENU_CHECK_STEP == 3))
{
return ;
}
} }
if((guangganflag == 2 || guangganflag == 1 ) && guangganflag != 3)
if((CurrentWrong == 1) && (MENU_CHECK_STEP == 13)) //静态电流检验,如果取消静态电流检验屏蔽此条
{ {
MENU_CHECK_STEP = 3; return ;
}
if(MENU_CHECK_STEP < 17) //循环
{
MENU_CHECK_STEP++;
}
else
{
MENU_CHECK_STEP = 0;
} }
} }
void MENU_CHECK_STEP_SUB(void) void MENU_CHECK_STEP_SUB(void)
{ {
if ( MENU_CHECK_STEP != 0 ); if ( MENU_CHECK_STEP != 0 );
MENU_CHECK_STEP--; MENU_CHECK_STEP--;
} }
void MENU_CHECK_Init(void) void MENU_CHECK_Init(void)
......
...@@ -11,6 +11,44 @@ ...@@ -11,6 +11,44 @@
#include "TimerB.h" #include "TimerB.h"
#include "Analog_Signals.h" #include "Analog_Signals.h"
#include "FreIn_User.h" #include "FreIn_User.h"
#include <stdio.h>
#define PN_Length 15 //零件号长度
typedef struct {
const char *part;
const char *ver1;
const char *ver2;
const char *auto_check;
} PartVersion;
static const PartVersion g_versionTable[] = {
// 零件号 MCU版本号(国民) SOC版本号(ESP32) 是否应用光感
{"37100-C076-0400", "1.06", "1.06", "YES"},
{"37100-A020-0200", "1.07", "1.07", "YES"},
{"37100-C076-0200", "1.06", "1.06", "YES"},
{"37100-C020-0100", "1.10", "1.10", "NO"},
{"37100-C076-0300", "1.07", "1.07", "NO"},
{"37100-A020-0300", "1.05", "1.05", "YES"},
{"37100-C076-0500", "1.01", "1.01", "YES"},
{"37100-A020-0400", "1.00", "1.00", "YES"},
{"37100-G254-0400", "1.21", "1.22", "YES"},
{"37100-C047-0200", "2.33", "2.33", "YES"},
{"37100-C047-0500", "1.03", "1.03", "YES"},
{"37100-G373-0300", "1.05", "1.05", "YES"},
{NULL, NULL, NULL, NULL} // 结束标志
};
typedef enum
{
auto_init = 0,
auto_enable,
auto_disable,
} auto_state_t;
uint8_t checkresult = 0; //校验结果(0无此零件号,1版本号为最新,2版本号非最新
uint8_t CurrentPN = 0xFF; //当前识别零件号
uint8_t AutoCheck = auto_init; //是否需要光感检测(0无效,1需要光感检测,2不需要光感检测
// clang-format off // clang-format off
uint32_t Display_Menu_Type; uint32_t Display_Menu_Type;
uint32_t Page_Refresh = 1; uint32_t Page_Refresh = 1;
...@@ -3572,7 +3610,7 @@ void HW_Static_Current_Check(uint32_t cmd) ...@@ -3572,7 +3610,7 @@ void HW_Static_Current_Check(uint32_t cmd)
// } // }
} }
} }
uint8_t CurrentWrong = 0; uint8_t CurrentWrong = 1;
void Get_static_Current(void) void Get_static_Current(void)
{ {
static uint32_t loc_Timer = 0; static uint32_t loc_Timer = 0;
...@@ -3622,13 +3660,72 @@ void Check_PWM(void) ...@@ -3622,13 +3660,72 @@ void Check_PWM(void)
uint32_t test = Duty_VEHICLE / 10; uint32_t test = Duty_VEHICLE / 10;
GUI_General_Digit_Display(test, Num_15, 3, 1, testNum, 160); 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) {
for (int i = 0; g_versionTable[i].part != NULL; i++) {
if (strcmp(g_versionTable[i].part, partStr) == 0) {
CurrentPN = i;
if((g_versionTable[i].auto_check) == ("YES"))
{
AutoCheck = auto_enable;
}
else if((g_versionTable[i].auto_check) == ("NO"))
{
AutoCheck = auto_disable;
}
if ((strcmp(curVerStr_mcu, g_versionTable[i].ver1) +
strcmp(curVerStr_soc, g_versionTable[i].ver2)) == 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)
{
char partStr[32];
char curVerStr_mcu[16];
char curVerStr_soc[16];
bytesToString(pnBytes, pnLen, partStr);
makeVersionString(major_mcu, minor_mcu, curVerStr_mcu);
makeVersionString(major_soc, minor_soc, curVerStr_soc);
uint8_t result = checkVersion(partStr, curVerStr_mcu, curVerStr_soc);
}
uint32_t leftvoltage; uint32_t leftvoltage;
uint32_t rightvoltage; uint32_t rightvoltage;
uint8_t firstclearflag = 0; uint8_t firstclearflag = 0;
uint8_t nowbanbenhao = 0; // uint8_t nowbanbenhao = 0;
uint8_t nowbanbenhaohoumian = 0; // uint8_t nowbanbenhaohoumian = 0;
uint8_t nowbanbenhaoG031 = 0; // uint8_t nowbanbenhaoG031 = 0;
uint8_t nowbanbenhaoG031houmian = 0; // uint8_t nowbanbenhaoG031houmian = 0;
const uint16_t banebenhao1[] = {35,25}; const uint16_t banebenhao1[] = {35,25};
const uint16_t banebenhao2[] = {190,180}; const uint16_t banebenhao2[] = {190,180};
const uint16_t banebenhao3[] = {105,95}; const uint16_t banebenhao3[] = {105,95};
...@@ -3706,106 +3803,14 @@ void Display_Version_Info(uint32_t ON_OFF) ...@@ -3706,106 +3803,14 @@ void Display_Version_Info(uint32_t ON_OFF)
wuliao[13] = R485_ID4Dh.Sig.MaterialCode14; wuliao[13] = R485_ID4Dh.Sig.MaterialCode14;
wuliao[14] = R485_ID4Dh.Sig.MaterialCode15; wuliao[14] = R485_ID4Dh.Sig.MaterialCode15;
wuliao[15] = 0xFF; wuliao[15] = 0xFF;
if(R485_ID4Dh.Sig.MaterialCode07 == 0x47)
{ checkresult = onReceive(wuliao,
if(R485_ID4Dh.Sig.MaterialCode08 == 0x32) PN_Length,
{ R485_ID4Dh.Sig.G0312,
nowbanbenhao = 1; R485_ID4Dh.Sig.G0311,
nowbanbenhaohoumian = 22; R485_ID4Dh.Sig.ESP322,
nowbanbenhaoG031 = 1; R485_ID4Dh.Sig.ESP321);
nowbanbenhaoG031houmian = 21;
}
else if(R485_ID4Dh.Sig.MaterialCode08 == 0x33)
{
nowbanbenhao = 1;
nowbanbenhaohoumian = 4;
nowbanbenhaoG031 = 1;
nowbanbenhaoG031houmian = 4;
if(R485_ID4Dh.Sig.MaterialCode13 == 0x33) //37100-G373-0300
{
nowbanbenhao = 1;
nowbanbenhaohoumian = 4;
nowbanbenhaoG031 = 1;
nowbanbenhaoG031houmian = 4;
}
}
else
{
}
}
else if(R485_ID4Dh.Sig.MaterialCode07 == 0x43)
{
if(R485_ID4Dh.Sig.MaterialCode10 == 0x37)
{
if(R485_ID4Dh.Sig.MaterialCode13 == 0x32)
{
nowbanbenhao = 2;
nowbanbenhaohoumian = 33;
nowbanbenhaoG031 = 2;
nowbanbenhaoG031houmian = 32;
}
else if(R485_ID4Dh.Sig.MaterialCode13 == 0x35)
{
nowbanbenhao = 1;
nowbanbenhaohoumian = 3;
nowbanbenhaoG031 = 1;
nowbanbenhaoG031houmian = 3;
}
else
{
;
}
}
else if(R485_ID4Dh.Sig.MaterialCode10 == 0x36)
{
nowbanbenhao = 1;
nowbanbenhaohoumian = 1;
nowbanbenhaoG031 = 1;
nowbanbenhaoG031houmian = 1;
if(R485_ID4Dh.Sig.MaterialCode13 == 0x32) //37100-C076-0200
{
nowbanbenhao = 1;
nowbanbenhaohoumian = 5;
nowbanbenhaoG031 = 1;
nowbanbenhaoG031houmian = 5;
}
else if(R485_ID4Dh.Sig.MaterialCode13 == 0x35) //37100-C076-0500
{
nowbanbenhao = 1;
nowbanbenhaohoumian = 1;
nowbanbenhaoG031 = 1;
nowbanbenhaoG031houmian = 1;
}
}
else
{
}
}
else if(R485_ID4Dh.Sig.MaterialCode07 == 0x41)
{
if(R485_ID4Dh.Sig.MaterialCode13 == 0x32) //37100-A020-0200
{
nowbanbenhao = 1;
nowbanbenhaohoumian = 6;
nowbanbenhaoG031 = 1;
nowbanbenhaoG031houmian = 6;
}
else if(R485_ID4Dh.Sig.MaterialCode13 == 0x33) //37100-A020-0300
{
nowbanbenhao = 1;
nowbanbenhaohoumian = 5;
nowbanbenhaoG031 = 1;
nowbanbenhaoG031houmian = 5;
}
}
else
{
;
}
if(wuliao[0] != 0) if(wuliao[0] != 0)
{ {
General_Number_Disp(wuliao, 3, 90+30); General_Number_Disp(wuliao, 3, 90+30);
...@@ -3849,27 +3854,27 @@ void Display_Version_Info(uint32_t ON_OFF) ...@@ -3849,27 +3854,27 @@ 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+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 ); //软件版本号对比 TFT_LCD_Draw_Bmp(3, 90+25+25+30+25+30+30+5, ( uint8_t * )gImage_gImage_SV1X6_Y16 ); //软件版本号对比
if((R485_ID4Dh.Sig.ESP322 != 0) && ( R485_ID4Dh.Sig.G0312 != 0)) // if((R485_ID4Dh.Sig.ESP322 != 0) && ( R485_ID4Dh.Sig.G0312 != 0))
{ // {
if((nowbanbenhao == R485_ID4Dh.Sig.ESP322) && (nowbanbenhaohoumian == R485_ID4Dh.Sig.ESP321) && (nowbanbenhaoG031 <= R485_ID4Dh.Sig.G0312) && (nowbanbenhaoG031houmian <= R485_ID4Dh.Sig.G0311)) // if((nowbanbenhao == R485_ID4Dh.Sig.ESP322) && (nowbanbenhaohoumian == R485_ID4Dh.Sig.ESP321) && (nowbanbenhaoG031 <= R485_ID4Dh.Sig.G0312) && (nowbanbenhaoG031houmian <= R485_ID4Dh.Sig.G0311))
{ // {
TFT_LCD_Draw_Bmp(200, 90+25+25+30+25+30+30, ( uint8_t * )gImage_dui ); //软件版本号对比 对 // TFT_LCD_Draw_Bmp(200, 90+25+25+30+25+30+30, ( uint8_t * )gImage_dui ); //软件版本号对比 对
firstpowerflag = 2; // firstpowerflag = 2;
} // }
else // 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_cuo ); //软件版本号对比 错
firstpowerflag = 3; // firstpowerflag = 3;
MENU_CHECK_STEP = 0; // MENU_CHECK_STEP = 0;
//正在调试取消版本号对比 想要取消版本号对比将上方注释掉并解开下方注释即可 // //正在调试取消版本号对比 想要取消版本号对比将上方注释掉并解开下方注释即可
// TFT_LCD_Draw_Bmp(200, 90+25+25+30+25+30+30, ( uint8_t * )gImage_dui ); //软件版本号对比 对 // // TFT_LCD_Draw_Bmp(200, 90+25+25+30+25+30+30, ( uint8_t * )gImage_dui ); //软件版本号对比 对
// firstpowerflag = 2; // // firstpowerflag = 2;
} // }
} // }
else // else
{ // {
MENU_CHECK_STEP = 0; // MENU_CHECK_STEP = 0;
} // }
// TFT_LCD_Draw_Bmp(200, 90+25+25+30+25+25, ( 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 ); //支持扫码功能个 // TFT_LCD_Draw_Bmp(3, 90+25+25+25+25+25, ( uint8_t * )gImage_gImage_SV1X6_Y16 ); //支持扫码功能个
// TFT_LCD_Draw_Bmp(3, 130, ( uint8_t * )gImage_Dyy_words_4X6_Y107); //供应商编码 // TFT_LCD_Draw_Bmp(3, 130, ( uint8_t * )gImage_Dyy_words_4X6_Y107); //供应商编码
...@@ -3887,8 +3892,8 @@ void Display_Version_Info(uint32_t ON_OFF) ...@@ -3887,8 +3892,8 @@ void Display_Version_Info(uint32_t ON_OFF)
// TFT_LCD_Draw_Bmp(3, 160, ( uint8_t * )gImage_Alarm_12_WordX6_Y165); //24脚输出占空比 // TFT_LCD_Draw_Bmp(3, 160, ( uint8_t * )gImage_Alarm_12_WordX6_Y165); //24脚输出占空比
// TFT_LCD_Draw_Bmp(210, 160, ( uint8_t * )gImage_Alarm_13_ImageX222_Y166); //% // TFT_LCD_Draw_Bmp(210, 160, ( uint8_t * )gImage_Alarm_13_ImageX222_Y166); //%
TFT_LCD_Draw_Bmp(3, 290, ( uint8_t * )gImage_gImage_checkVX6_Y165 ); //检测台版本号 TFT_LCD_Draw_Bmp(3, 290, ( uint8_t * )gImage_gImage_checkVX6_Y165 ); //检测台版本号
// uint8_t mbuff [7] = {2,6,0,1,0,5,0xff}; uint8_t mbuff [7] = {2,6,0,3,1,7,0xff};
uint8_t mbuff [7] = {0,1,2,7,10,1,0xff}; // uint8_t mbuff [7] = {0,1,2,7,10,1,0xff};
General_Number_Disp(mbuff, 160, 290); General_Number_Disp(mbuff, 160, 290);
} }
...@@ -4342,15 +4347,7 @@ void Display_Send_Vspead(uint8_t menu) ...@@ -4342,15 +4347,7 @@ void Display_Send_Vspead(uint8_t menu)
TFT_LCD_Draw_Bmp(180, 40+25, ( uint8_t * )gImage_Dey_words_8X224_Y107); TFT_LCD_Draw_Bmp(180, 40+25, ( uint8_t * )gImage_Dey_words_8X224_Y107);
TFT_LCD_Draw_Bmp(3, 40+25+25+25+25+25+25, ( uint8_t * )gImage_gImage_checkComX6_Y165); TFT_LCD_Draw_Bmp(3, 40+25+25+25+25+25+25, ( uint8_t * )gImage_gImage_checkComX6_Y165);
} }
if(CurrentWrong == 1)
{
MENU_CHECK_STEP = 13;
}
else
{
;
}
switch (menu) switch (menu)
{ {
case 1: case 1:
......
...@@ -49,6 +49,8 @@ enum DisplayFont ...@@ -49,6 +49,8 @@ enum DisplayFont
extern unsigned int Display_Menu_Type; extern unsigned int Display_Menu_Type;
extern uint32_t odo_val_Back ; extern uint32_t odo_val_Back ;
extern uint8_t AutoCheck;
extern uint8_t CurrentWrong;
void GeneralInfoDisp(unsigned char *p, unsigned short x, unsigned short y); void GeneralInfoDisp(unsigned char *p, unsigned short x, unsigned short y);
void Display_Title_Info(void); void Display_Title_Info(void);
void Display_Version_Info(uint32_t ON_OFF); void Display_Version_Info(uint32_t ON_OFF);
......
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