改为中英文

This commit is contained in:
sunbeam 2024-10-09 09:09:01 +08:00
parent d5c72c6d82
commit 3df8c235b0
10 changed files with 131 additions and 22 deletions

View File

@ -3,16 +3,20 @@ import win.ui;
/*DSG{{*/
mainForm = win.form(text="CAN_Bootloader";right=699;bottom=465;border="dialog frame";max=false)
mainForm.add(
btnFlashLeft={cls="button";text="左侧刷写";left=30;top=129;right=168;bottom=243;z=2};
btnFlashRight={cls="button";text="右侧刷写";left=181;top=131;right=319;bottom=245;z=7};
btnStopBoot={cls="button";text="停止";left=29;top=272;right=319;bottom=346;z=3};
btnFlashLeft={cls="button";text="左侧刷写
Left side flashing";left=30;top=129;right=168;bottom=243;z=2};
btnFlashRight={cls="button";text="右侧刷写
Right side flashing";left=181;top=131;right=319;bottom=245;z=7};
btnStopBoot={cls="button";text="停止
Stop";left=29;top=272;right=319;bottom=346;z=3};
edit={cls="edit";left=361;top=19;right=692;bottom=401;autovscroll=false;edge=1;multiline=1;vscroll=1;z=1};
plus={cls="plus";text="等待刷写";left=33;top=380;right=318;bottom=434;bgcolor=12639424;z=10};
plus={cls="plus";text="等待刷写
Waiting for flashing";left=33;top=375;right=316;bottom=460;bgcolor=12639424;z=10};
progress={cls="progress";left=361;top=435;right=689;bottom=463;edge=1;max=100;min=0;z=4};
static={cls="static";text='\uF127';left=43;top=30;right=114;bottom=98;align="center";center=1;color=255;font=LOGFONT(h=-56;name='FontAwesome');transparent=1;z=8};
static2={cls="static";text="设备未连接,请先连接设备";left=126;top=42;right=326;bottom=91;transparent=1;z=9};
static3={cls="static";text="刷写进度";left=361;top=410;right=414;bottom=430;transparent=1;z=5};
static5={cls="static";text="V0.1_20240711";left=545;top=1;right=689;bottom=17;align="right";center=1;notify=1;transparent=1;z=6}
static3={cls="static";text="刷写进度 Brush writing progress";left=361;top=410;right=688;bottom=430;transparent=1;z=5};
static5={cls="static";text="V0.2_20240921";left=545;top=1;right=689;bottom=17;align="right";center=1;notify=1;transparent=1;z=6}
)
/*}}*/
@ -32,9 +36,13 @@ CANHw = usb2canfd.USB2CANHW();//尝试加载CAN dll
var ret = CANHw.LoadDll();
if(ret == 0){
Display("DLL加载成功");
Display("DLL loaded successfully
");
}
else {
Display("DLL加载失败");
Display("DLL loading failed
");
}
@ -64,6 +72,8 @@ listener.$SetProgress = function(pos){
listener.$Connected = function(){
Display("设备连接成功");
Display("Device connection successful
");
thrdTable.设备连接状态 = 1;
}
listener.$SendEnd = function(isSuccess){
@ -72,13 +82,17 @@ listener.$SendEnd = function(isSuccess){
bootstate = false;
if(isSuccess == true){
Display("刷写成功,用时 " + usetime + " S")
mainForm.plus.text = "刷写完成";
Display("Brushed successfully, took "+usetime+" S
");
mainForm.plus.text = "刷写完成\Brushed successfully";
//mainForm.plus.bgcolor = 0x32CD32;
mainForm.plus.background = 0xFF32CD32;
}
else {
Display("刷写失败");
mainForm.plus.text = "刷写失败";
Display("Flashing failed
");
mainForm.plus.text = "刷写失败 Flashing failed";
//mainForm.plus.bgcolor = 0x2200E3;
mainForm.plus.background = 0xFFE30022;
}
@ -108,7 +122,9 @@ var CanThread = function(){
var DiagBootReq = function(id){
::PostThreadMessage(thrdId,102,id,0)//自定义消息
mainForm.plus.text = "刷写中请勿断开电源或USB连接";
mainForm.plus.text = "刷写中请勿断开电源或USB连接
During flashing, do not disconnect the power
or USB connection";
//mainForm.plus.bgcolor = 0x00CCFF;
mainForm.plus.background = 0xFF00CCFF;
}
@ -123,6 +139,8 @@ var DiagStopReq = function(){
mainForm.btnFlashLeft.oncommand = function(id,event){
if(thrdTable.设备连接状态 == 0){
Display("设备未连接");
Display("device not connected
");
return;
}
if(bootstate == true){
@ -130,12 +148,16 @@ mainForm.btnFlashLeft.oncommand = function(id,event){
}
if(thrdTable["文件加载状态"] == false){
Display("烧录文件加载错误");
Display("Burning file loading error
");
return;
}
bootstate = true;
mainForm.edit.text = "";
::PostThreadMessage(thrdId,106,0x720,0x620);//自定义消息
Display("开始刷写流程");
Display("Start flashing process
");
starttime = time.now();
DiagBootReq(1);//左侧
}
@ -156,7 +178,7 @@ autoconnect.onTimer = function(){
if(thrdTable.设备连接状态 == 0){
//断开
mainForm.static.text='\uF127'
mainForm.static2.text = "设备未连接,请先连接设备";
mainForm.static2.text = "设备未连接,请先连接设备 The device is not connected, please connect the device first";
mainForm.static.color=0xff0;
::PostThreadMessage(thrdId,100,0,0);
//Display("刷新");
@ -200,7 +222,7 @@ autoconnect.onTimer = function(){
if(thrdTable["文件加载状态"] == true){
mainForm.static.color=0xff00;
mainForm.static.text='\uF0C1';
mainForm.static2.text = "设备已连接,可以开始刷写";
mainForm.static2.text = "设备已连接,可以开始刷写 The device is connected and can start flashing";
::PostThreadMessage(thrdId,115,1,0);//连接
autoconnect_state = 4;
}
@ -225,6 +247,8 @@ autoconnect.onTimer = function(){
mainForm.btnFlashRight.oncommand = function(id,event){
if(thrdTable.设备连接状态 == 0){
Display("设备未连接");
Display("device not connected
");
return;
}
if(bootstate == true){
@ -232,12 +256,16 @@ mainForm.btnFlashRight.oncommand = function(id,event){
}
if(thrdTable["文件加载状态"] == false){
Display("烧录文件加载错误");
Display("Burning file loading error
");
return;
}
bootstate = true;
mainForm.edit.text = "";
::PostThreadMessage(thrdId,106,0x710,0x610);//自定义消息
Display("开始刷写流程");
Display("Start flashing process
");
starttime = time.now();
DiagBootReq(2);//左侧
}
@ -251,7 +279,6 @@ autoconnect.enable();
//import console;
//console.log("io.exis = ",io.exist("\res\P417_SWTL_20240709.S19"));
thrdHandle,thrdId = thread.create( CanThread );
mainForm.show();
return win.loopMessage();

View File

@ -73,7 +73,8 @@ FuncReadDeviceVersion = function(id){
var v1 = (DeviceInfo.FirmwareVersion>>24)&0xff;
var v2 = (DeviceInfo.FirmwareVersion>>16)&0xff;
var v3 = DeviceInfo.FirmwareVersion&0xffff;
FuncDisplay("固件版本"++v1++"."++v2++"."++v3)
FuncDisplay("固件版本"++v1++"."++v2++"."++v3);
FuncDisplay("Firmware version:"++v1++"."++v2++"."++v3)
}
else {
FuncDisplay("读取失败");
@ -116,8 +117,10 @@ FuncLoadAPPFile = function(){
var ret = FuncOpenS19File(1,"\res\P417_SWTL_20240722.S19");
if(ret != null){
FuncDisplay("加载左侧烧录文件");
FuncDisplay("Load the left burning file");
var crc32 = FuncGetFlashCRC(1);
FuncDisplay("CRC = " ++ string.format("%X",crc32));
FuncDisplay("CRC = " ++ string.format("%X",crc32)++"
");
if(string.format("%X",crc32) != "F6570262"){
FuncDisplay("CRC校验错误文件已损坏");
thrdTable["文件加载状态"] = false;
@ -132,8 +135,10 @@ FuncLoadAPPFile = function(){
var ret = FuncOpenS19File(2,"\res\P417_SWTR_20240722.S19");
if(ret != null){
FuncDisplay("加载右侧烧录文件");
FuncDisplay("Load the right burning file");
var crc32 = FuncGetFlashCRC(2);
FuncDisplay("CRC = " ++ string.format("%X",crc32));
FuncDisplay("CRC = " ++ string.format("%X",crc32)++"
");
if(string.format("%X",crc32) != "1F3D406C"){
FuncDisplay("CRC校验错误文件已损坏");
thrdTable["文件加载状态"] = false;
@ -168,7 +173,9 @@ FuncFreshHw = function(){
//mainForm.cbbDev.text = "未找到硬件"
}
else {
FuncDisplay("找到硬件")
FuncDisplay("找到硬件");
FuncDisplay("Find hardware
");
thrdTable.设备 = CANHw.GetAvailableHW()
}
}
@ -262,6 +269,9 @@ FuncStartBoot = function(id){
boottimer.enable();
FuncDisplay("开始刷写");
FuncDisplay("Start flashing
");
stopflag = 0;
}
@ -370,5 +380,7 @@ timer1.onTimer = function(){
FuncLoadAPPFile();
timer1.enable();
FuncDisplay("CAN线程正在运行");
FuncDisplay("CAN thread is running
");
DelayTest();

View File

@ -20,12 +20,18 @@ FuncDiag10Pro = function(data){
select(data[1]) {
case 1 {
FuncDisplay("进入默认会话成功")
FuncDisplay("Successfully entered default session
")
}
case 2 {
FuncDisplay("进入编程会话成功")
FuncDisplay("Successfully entered programming session
")
}
case 3 {
FuncDisplay("进入扩展会话成功")
FuncDisplay("Successfully entered the extended session
")
}
else {
}

View File

@ -28,9 +28,13 @@ FuncDiag22Pro = function(data){
if(data[3] != 0){
var str = string.pack(table.slice(data,3,len+3));
FuncDisplay("硬件版本号:" ++ str);
FuncDisplay("Hardware Version:" ++ str++"
");
}
else {
FuncDisplay("硬件版本号未读到");
FuncDisplay("Hardware version number not read
");
}
@ -40,9 +44,13 @@ FuncDiag22Pro = function(data){
if(data[3] != 0){
var str = string.pack(table.slice(data,3,len+3));
FuncDisplay("软件版本号:" ++ str);
FuncDisplay("Software Version:" ++ str++"
");
}
else {
FuncDisplay("软件版本号未读到");
FuncDisplay("Software version number not read
");
}
}
case 0xF198 {
@ -59,8 +67,9 @@ FuncDiag22Pro = function(data){
}
case 0xF18A {
FuncDisplay("系统供应商公司名称代码");
FuncDisplay(string.pack(table.slice(data,3)));
FuncDisplay("软件日期:"++string.pack(table.slice(data,3)));
FuncDisplay("Software date:"++string.pack(table.slice(data,3))++"
");
}
case 0xF197 {

View File

@ -37,12 +37,16 @@ FuncDiag27Pro = function(data){
select(data[1]) {
case 1,3,5,7,9,11,0x11 {
var str = "收到种子";
var str1 = "Received seeds";
for(i=1;4;1){
SecuretySeed[i] = data[i+1];
str += " " + tostring(SecuretySeed[i],16);
str1 += " " + tostring(SecuretySeed[i],16);
lockstate = 1;
}
FuncDisplay(str)
FuncDisplay(str1++"
");
SecuretyKey = securetyKeyCalc(SecuretySeed,data[1]);
if(#SecuretyKey >= 4){
FuncReq27(data[1]+1,SecuretyKey);
@ -51,6 +55,8 @@ FuncDiag27Pro = function(data){
str += " " + tostring(SecuretyKey[i],16);
}*/
FuncDisplay(str);
FuncDisplay("Calculate the key
");
}
else {
FuncDisplay("计算失败");
@ -59,6 +65,8 @@ FuncDiag27Pro = function(data){
}
case 2,4,6,8,10,12,0x12 {
FuncDisplay("解锁成功");
FuncDisplay("Unlocked successfully
");
lockstate = 2;
}
else {

View File

@ -39,5 +39,6 @@ FuncReq2E = function(did,data){
FuncDiag2EPro = function(data){
var did = (data[1]<<8) + data[2];
FuncDisplay("写入" + tostring(did,16) + "成功");
FuncDisplay("Write in " + tostring(did,16) + " success
");
}

View File

@ -1,6 +1,8 @@
FuncReq31EraseFlash = function(addr,len){
FuncDisplay("开始擦除数据")
FuncDisplay("开始擦除数据");
FuncDisplay("Start erasing data
");
var data = {0xff,0x00,0x44,addr>>24,addr>>16,addr>>8,addr,len>>24,len>>16,len>>8,len};
FuncReq31(data);
}
@ -52,10 +54,14 @@ FuncDiag31Pro = function(data){
FuncDisplay("擦除成功")
}
case 0x0202 {
FuncDisplay("校验成功")
FuncDisplay("校验成功");
FuncDisplay("Verification successful
");
}
case 0xFF01 {
FuncDisplay("检查标志成功")
FuncDisplay("Check flag successfully
")
}
case 0xF518 {
FuncDisplay("数字签名错误")

View File

@ -13,8 +13,12 @@ var maxlen = 0;
FuncDiag34Pro = function(data){
//console.dumpJson(data);
FuncDisplay("请求下载成功")
FuncDisplay("Request download successful
")
maxlen = (data[2]<<8) + data[3];
FuncDisplay("最大长度:" + maxlen);
FuncDisplay("Maximum Length:" + maxlen++"
");
}
FuncGetSengLen = function(){

View File

@ -33,6 +33,8 @@ FuncDiag7FPro = function(data){
case 0x78 {
if(errSID != 0x36){
FuncDisplay("服务正忙")
FuncDisplay("Service is busy
")
}
}

View File

@ -19,6 +19,8 @@ FuncWait = function(sid){
}
else {
FuncDisplay("刷写错误 步骤" + bootstate);
FuncDisplay("Brushing error steps" + bootstate++"
");
boottimer.disable();
thread.command.$SendEnd(false);
return 1; //负响应
@ -27,6 +29,8 @@ FuncWait = function(sid){
}
if(stopflag == 1){
FuncDisplay("停止");
FuncDisplay("Stop
");
boottimer.disable();
thread.command.$SendEnd(false);
return 2;//停止命令
@ -34,6 +38,8 @@ FuncWait = function(sid){
bootcount += 1;
if(bootcount >= 400){
FuncDisplay("步骤" + bootstate + "超时 " + tostring(sid,16));
FuncDisplay("Step" + bootstate + " Timeout " + tostring(sid,16)++"
");
thread.command.$SendEnd(false);
boottimer.disable();
return 3;//超时
@ -90,6 +96,8 @@ FuncSendBlockInit = function(id){
blocknum = 1;
if(alldata == null){
FuncDisplay("错误:空数据");
FuncDisplay("Error: Empty data
");
alldata_blocknum = 0;
sendblockstate = 0xff;
return 1;
@ -116,6 +124,8 @@ FuncSendBlockApp = function(){
case 0{
if(FuncSendBlockApp_sendflag == 0){
FuncDisplay("请求下载");
FuncDisplay("Request to download
");
FuncReq34(alldata[blocknum]["address"],#alldata[blocknum]["data"]);
FuncSendBlockApp_sendflag = 1;
RespState = 0;
@ -135,6 +145,8 @@ FuncSendBlockApp = function(){
FuncSendBlockApp_sendflag = 0;
sendblockstate += 1;
FuncDisplay("发送App数据中...");
FuncDisplay("Sending App Data...
");
}
case 2 {
if(FuncSendBlockApp_sendflag == 0){
@ -175,6 +187,8 @@ FuncSendBlockApp = function(){
}
else {
FuncDisplay("所有App数据发送完成");
FuncDisplay("All app data has been sent
");
return 0;
}
@ -223,6 +237,8 @@ FuncBootSeq = function(){
//nextstate(0);
if(sendstate == 0){
FuncDisplay("读取版本");
FuncDisplay("Read version
");
FuncReadDID(0xF195);//读取软件版本
FuncClearState();
}
@ -299,6 +315,8 @@ FuncBootSeq = function(){
case 6 {
if(sendstate == 0){
FuncDisplay("进入编程会话");
FuncDisplay("Enter programming session
");
FuncReq10(false,0x02);//进入编程会话
FuncClearState();
}
@ -316,6 +334,8 @@ FuncBootSeq = function(){
case 7 {
if(sendstate == 0){
FuncDisplay("等待解锁");
FuncDisplay("Waiting to unlock
");
FuncReq27(0x03);//解密
FuncClearState();
}
@ -371,6 +391,8 @@ FuncBootSeq = function(){
case 11 {
if(sendstate == 0){//CheckLogicBlock
FuncDisplay("擦除APP");
FuncDisplay("Erase APP
");
FuncReq31EraseFlash(0x18000,0x20000);
FuncClearState();
}
@ -409,6 +431,8 @@ FuncBootSeq = function(){
case 15 {
if(sendstate == 0){//CheckLogicBlock
FuncDisplay("CRC校验");
FuncDisplay("CRC check
");
var crc = FuncGetFlashCRC(senddataid);
FuncReq31CheckLogicBlock(crc);
FuncClearState();
@ -421,6 +445,8 @@ FuncBootSeq = function(){
case 16 {
if(sendstate == 0){////Programming Dependencies
FuncDisplay("检查标志");
FuncDisplay("Check Mark
");
FuncReq31CheckPD();
FuncClearState();
}
@ -432,6 +458,8 @@ FuncBootSeq = function(){
case 17 {
if(sendstate == 0){//复位
FuncDisplay("复位");
FuncDisplay("Reset
");
FuncClearState();
FuncReq11(0x01);
}
@ -472,6 +500,8 @@ FuncBootSeq = function(){
if(sendstate == 0){
FuncDisplay("写入刷写信息");
FuncDisplay("Write flashing information
");
FuncClearState();
FuncDIDWriteStr(0xf198,"DM_Reworker ");//写入repair_shopcode LEN=16
@ -524,9 +554,11 @@ FuncBootSeq = function(){
case 23 {
if(sendstate == 0){
FuncDisplay("读取版本");
FuncDisplay("Read version
");
FuncReadDID(0xF195);//读取软件版本
FuncClearState();
delaycount = 0;
FuncClearState();
}
else {
delaycount++;
@ -539,6 +571,8 @@ FuncBootSeq = function(){
case 24 {
if(sendstate == 0){
FuncDisplay("读取软件日期");
FuncDisplay("Read software date
");
FuncReadDID(0xF18A);//读取软件版本
FuncClearState();
}