Commit c9dc0bfb authored by lyong's avatar lyong

feat:自动化测试授权增加2、4、6、8、16、32段 ;2、增加lcd测试时间 1秒切换一个画面;3、优化触摸

parent a8f35efa
...@@ -126,7 +126,7 @@ ...@@ -126,7 +126,7 @@
ledtimerSet: function () { ledtimerSet: function () {
this.resetLcd(); this.resetLcd();
this.clearTimer(); this.clearTimer();
idTimeOut = this.$setInterval(this.normalTimerOut, 300, [], this); idTimeOut = this.$setInterval(this.normalTimerOut, 1000, [], this);
// this.$setTimeout(this.LedTimerOut, 5000, [], this); // this.$setTimeout(this.LedTimerOut, 5000, [], this);
}, },
......
...@@ -41,7 +41,8 @@ function event(fd, recvBuf) { ...@@ -41,7 +41,8 @@ function event(fd, recvBuf) {
if (hit) return hit.fn(fd, recvBuf); if (hit) return hit.fn(fd, recvBuf);
} }
function eventHex(fd, recvBuf) { function eventHex(fd, recvBuf) {
console.log('RXHEX:' + recvBuf); console.debug(`RXHEX:${recvBuf}`);
//console.debug(`!!!!will go to main globalThis.appAliveValue!=1 ${globalThis.appAliveValue}`)
const hit = cmdTableHex.find(item => recvBuf.includes(item.kw)); const hit = cmdTableHex.find(item => recvBuf.includes(item.kw));
if (hit) return hit.fn(fd, recvBuf); if (hit) return hit.fn(fd, recvBuf);
} }
...@@ -167,15 +168,21 @@ function doWriteLic(fd, recvBuf) { ...@@ -167,15 +168,21 @@ function doWriteLic(fd, recvBuf) {
console.log("recvBuf:" + recvBuf) console.log("recvBuf:" + recvBuf)
var ret = autoUtil.licParce(recvBuf); var ret = autoUtil.licParce(recvBuf);
if (ret == 1) { if (ret == 1) {
console.log("licParce ret:" + ret)
send(fd, '+OK'); send(fd, '+OK');
} else if (ret == -2) { }
else if (ret == 2) {
console.log("licParce error");
if (uartMode == 1) { if (uartMode == 1) {
restartUart(); restartUart();
} else if (uartMode == 2) { } else if (uartMode == 2) {
restartUartCarrieWave(); restartUartCarrieWave();
} }
}
else if (ret == 3) {
console.log("licParce ret:" + ret)
send(fd, '+OK');
autoUtil.gotoWriteLic();
} }
// console.log('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'); // console.log('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!');
// console.log('write lic:' + recvBuf); // console.log('write lic:' + recvBuf);
......
...@@ -135,12 +135,12 @@ function getWifiScan(value) { ...@@ -135,12 +135,12 @@ function getWifiScan(value) {
// return "FAIL"; // return "FAIL";
// } // }
var matchingAPs = resultsWifiList.filter(ap => ap.name === ssid); var matchingAPs = resultsWifiList.filter(ap => ap.name === ssid);
if (matchingAPs.length === 0) { if (matchingAPs.length === 0) {
return "FAIL"; return "FAIL";
} }
console.log("matchingAPs :" + JSON.stringify(matchingAPs) + "------") console.log("matchingAPs :" + JSON.stringify(matchingAPs) + "------")
var bestAP = matchingAPs.sort((a, b) => b.rssi - a.rssi)[0]; var bestAP = matchingAPs.sort((a, b) => b.rssi - a.rssi)[0];
return `name:${bestAP.name},rssi:${bestAP.rssi},mac:${bestAP.mac}`; return `name:${bestAP.name},rssi:${bestAP.rssi},mac:${bestAP.mac}`;
} }
function writeSn(sn) { function writeSn(sn) {
...@@ -276,6 +276,7 @@ function setAutoModeUI(mode) { ...@@ -276,6 +276,7 @@ function setAutoModeUI(mode) {
console.log("!!setAutoModeUI: " + mode) console.log("!!setAutoModeUI: " + mode)
switch (mode) { switch (mode) {
case "LCD": case "LCD":
ciclkAutoFactory(3);
that.ledtimerSet() that.ledtimerSet()
// that.$hide("id_yes") // that.$hide("id_yes")
// that.$hide("id_ng") // that.$hide("id_ng")
...@@ -331,12 +332,39 @@ function hexToAscii(hexStr) { ...@@ -331,12 +332,39 @@ function hexToAscii(hexStr) {
} }
/* ========== 全局 ========== */ /* ========== 全局 ========== */
const licSegArray = []; // 下标 = 段号-1 var licSegArray = []; // 下标 = 段号-1
function getpectedHexLen(seg) {
// 总长度数据4096
console.log("seg: " + seg);
var hexLen = 0;
switch (seg) {
case "32":
hexLen = 128; // 64 字节 = 128 个十六进制字符
break;
case "16":
hexLen = 256;
break;
case "08":
hexLen = 512;
break;
case "04":
hexLen = 1024;
break;
case "02":
hexLen = 2048;
break;
default:
hexLen = 128;
break;
}
console.log("hexLen: " + hexLen);
return hexLen;
}
function licParce(recvBuf) { function licParce(recvBuf) {
var comallArrLicVal = '4954455F4C4943'; var comallArrLicVal = '4954455F4C4943';
var allArrLicVal = '3332'; // 外部可改,总段号(16 进制字符串) // var allArrLicVal = '3332'; // 外部可改,总段号(16 进制字符串)
var equal = '3D'; var equal = '3D';
// console.log('licParce recv:' + recvBuf); // console.log('licParce recv:' + recvBuf);
var buf = recvBuf; var buf = recvBuf;
...@@ -345,7 +373,7 @@ function licParce(recvBuf) { ...@@ -345,7 +373,7 @@ function licParce(recvBuf) {
/* 1. 以 comallArrLicVal 为分隔符劈成两段 */ /* 1. 以 comallArrLicVal 为分隔符劈成两段 */
const pos = buf.indexOf(comallArrLicVal); const pos = buf.indexOf(comallArrLicVal);
// console.log("pos:" + pos) // console.log("pos:" + pos)
if (pos === -1) return -1; if (pos === -1) return 0;
let core = buf.slice(pos + comallArrLicVal.length + 12); // 后半段 let core = buf.slice(pos + comallArrLicVal.length + 12); // 后半段
// console.log("!!!!1_ core:" + core) // console.log("!!!!1_ core:" + core)
...@@ -356,22 +384,15 @@ function licParce(recvBuf) { ...@@ -356,22 +384,15 @@ function licParce(recvBuf) {
core = core.slice(0, -8); core = core.slice(0, -8);
console.log("recv:" + core); console.log("recv:" + core);
const expectedHexLen = 128; // 64 字节 = 128 个十六进制字符
if (core.length !== expectedHexLen) {
console.log(`长度错误:期望 ${expectedHexLen},实际 ${core.length}`);
return -2;
} else {
console.log(`长度正确:期望 ${expectedHexLen},实际 ${core.length}`);
}
const posT = titleBuf.indexOf(equal); const posT = titleBuf.indexOf(equal);
let coreT = titleBuf.slice(posT + equal.length); let coreT = titleBuf.slice(posT + equal.length);
// console.log("coreT:" + coreT); // console.log("coreT:" + coreT);
const slashPos = coreT.indexOf('2F'); const slashPos = coreT.indexOf('2F');
if (slashPos === -1) { return -1; } if (slashPos === -1) { return 0; }
const segHex = coreT.slice(0, slashPos); // 例如 "31" const segHex = coreT.slice(0, slashPos); // 例如 "31"
const allArrLicVal = coreT.slice(slashPos + 2, slashPos + 6); // 总段数
console.log("allArrLicVal:" + allArrLicVal);
// Hex 字符串当成 ASCII 解码 // Hex 字符串当成 ASCII 解码
// Hex → 字节 → ASCII → 数字 // Hex → 字节 → ASCII → 数字
// const segChar = String.fromCharCode(parseInt(segHex, 16)); // '1' // const segChar = String.fromCharCode(parseInt(segHex, 16)); // '1'
...@@ -380,6 +401,17 @@ function licParce(recvBuf) { ...@@ -380,6 +401,17 @@ function licParce(recvBuf) {
console.log("recv index:" + curSeg); console.log("recv index:" + curSeg);
console.log("all index:" + totSeg); console.log("all index:" + totSeg);
//总长度数据4096
var expectedHexLen = getpectedHexLen(totSeg);
if (core.length !== expectedHexLen) {
console.log(`长度错误:期望 ${expectedHexLen},实际 ${core.length}`);
return -2;
} else {
console.log(`长度正确:期望 ${expectedHexLen},实际 ${core.length}`);
}
/* 4. 格式化并缓存 */ /* 4. 格式化并缓存 */
// const spaced = formatHexWithSpace(core); // const spaced = formatHexWithSpace(core);
const spaced = core; const spaced = core;
...@@ -390,39 +422,52 @@ function licParce(recvBuf) { ...@@ -390,39 +422,52 @@ function licParce(recvBuf) {
console.log(`seg=${curSeg}/${totSeg} data=${spaced}`); console.log(`seg=${curSeg}/${totSeg} data=${spaced}`);
if (curSeg === totSeg) {
// /* 5. 末段到齐 → 拼接写入 */ return 3;
if (curSeg === totSeg && licSegArray.every(v => v)) {
fullLic = licSegArray.join('').replace(/\s+/g, '');
// const fullLic = licSegArray.join('').replace(/\s+/g, '');
writeLic(fullLic);
console.log('Full license written:' + fullLic);
licSegArray.length = 0;
} }
return 1; return 1;
} }
function gotoWriteLic() {
console.log("--enter gotoWriteLic");
// 确保 _timeOutId 是函数的静态属性
if (gotoWriteLic._timeOutId == undefined) {
gotoWriteLic._timeOutId = null;
}
// 清理之前的定时器
if (gotoWriteLic._timeOutId) {
clearTimeout(gotoWriteLic._timeOutId);
gotoWriteLic._timeOutId = null;
}
// 设置新的定时器
gotoWriteLic._timeOutId = setTimeout(() => {
console.log("!!!!!!!!!!!!!!!!!!!!gotoWriteLic");
// 检查 licSegArray 是否包含所有段的数据
if (licSegArray.length > 0 && licSegArray.every(v => v)) {
var recLic = licSegArray.join('').replace(/\s+/g, '');
fullLic = recLic;
// 写入许可证
writeLic(fullLic);
console.log('Full license written:' + fullLic);
// 计算校验和
var cksum = figureChecksum(recLic, 2048);
console.log('checksum = ' + cksum);
console.log("0X" + cksum.toString(16).padStart(2, '0').toUpperCase());
// 清空 licSegArray
licSegArray = [];
} else {
console.log("License segments are incomplete or invalid.");
}
}, 100);
}
function testLicParce() { function testLicParce() {
// var fullLic = "202C3AE80810DA0000000000000000005F93DC7F18DDC42C761F2EADA48223F1D966861A2AC39B28F7C267BB282775556A57312196FC891E77BC3423E9685DD3CBE6DE5637B4D4BA26994AE0C94B103E3CE725C09825E2BCF2D0FBF5A\
// 4A72250EA508EA8CA3450BB82EA7972C3B621134714E7485299C095D05AB13BC8A9A8BC952AFBD0F003F72C29C5B6B3EC95EC12D3EA67CDDF0CA5324AC7C15A69D0D72B0F7951FDB05D6D6C5196AD1FD27074D08E13A5088B8B2C8C65A5EB21AE379E313F78E15\
// 6ACB89E4216AAAB3C2374CCF9BD64829FB55C83E98883FC385B34AEBD2C39BE5AE52A7EA41F1DA928859CE10BA28C6F42073792CD083D060DF501677D818ED55AF9CCCBFE7F0B8DD58C720F52A08B53049E9C0B88CD85BB4BC8D389C635F3A7815D38CF8A4DAA3\
// E75D27A45CD7F677728E86E8FA02392A9245CBE0C723D6C400483244A2AA3C78FD27692833BF6B4FCE9CF469DAF22A4AFEFAC0F1E04AC8A7A35931DC5A253A3BC35677F561CA128A28B5A3C2F76D6B283A84A14F60AB1B905CBDB9CDA45B585ECDE579834D8540\
// 2EEA279CBB75F4A7585AF311EE856A41E4A1174C0A9835C24B8AD55EE94E1F51F25E03AB3AE4DEC4153909F30D4A263961275F82C7599128450C3937068BCF2D8A6217DC7ED515AFB8FA5D19A4C7E97D7D43A54D128CBFE49AA5A06B189D59BB3AEC89525C4C3E\
// 09244CD6E8D8F94A055E00C16B6A3AFEF08860ECD9F83FC6D9549DBE54D8C0703C5052741C4C8791CD0B3CCB7C01F0114F340DC5778B6659515E8117A3720336DB4C8AD9388937107925BE11D69C0052EE614B989450E8E59108483E1AFFEA3004D05E13F27DBE\
// 37D31B2DC6F5D05A417E802D226F2A200021D906EFBE492E3507C22EF3C12427625E696847104EEAD6DBBC4256ABCA03C8A0330D23F9D412798F1AC7DAEA0DD4848C77EE97391CFD9C0DC6262DAE0CF09806CE17A17D8FB90AEA8FA1BFB9DE32ED05C1C3FB817E\
// 657F320466748643E3A7B5748982F080EF83B9E61063F4A7AA65BC16CA3A0713FF4C522F8C5CF5044B5074FFA9D0901837B83FEFE6C4E101EB4B8BED41B078F044071FCE51798B41905AA5A8C7AD83110F57303B9CE9685FB507F8912A12576968138B3C2191A9\
// E23BE7F7EB74E40EFAEDD84891C9990F44D1003B9AD75462DB7E1388097D36BC7460BAF70FAA748A68BFBB6DB4062504548F99703A7BD0220582A54913A9556DF9E75B5B49FC2A6868A05FC0FD9E9A6AFE11E2FA6BE61B63ECA9B824F5FEFAED65EE6E717DF77F\
// 0AA7EA169BC592DFE9B259F631BDF500913675EC3B6C9EC590713E55FFDFC0755D59BF061E24DA89EA57043BF7C336A0C6194BF9858D7384E68B90E3FE6977E873FA274FE087079D33003537B5748982F080EF83B9E61063F4A7AA675D0DB5DFCC4FE811ED5783\
// B7224413642146428096DA280CEA85F5378279C3F5794DCCFA3579127BF0BD098B127099889F0170E39920C1B19C9042BB28ECD2C656FF58FA4C48A7DC463F04E4AFE977096E6B7BF282B5545D54090A7E3C1BF49B154DD733C2617A33AB7CE39446C398E0A6F9\
// 0EA70526A299B8FEBFFCEB3A791FEA790CAA610E878DFE6540F6909B9C07DDB22072BA29F88462049F4EB6337764CCA84ADE9F9C07FE097C27E15B5D35BA03F9EC1829C73ED33C2297915EC047BE6E617A5B251BF0B79206FE7BDF694AAE408DC705DB7918081E\
// E71EBC5276B22B6F817AC47DC8D44EC363A849CA57BA736AA18A5110FE6BC60490165B17A7CDA7B5748982F080EF83B9E61063F4A7AA632298B6D8E21B368DBD9FE04DADE18BE74CF0BF181510CE7A3AE5C059A7FA2F990DF6DD94932D5C269EFD96337776AF60\
// 88DAC20D5F4F3E57A521803F3F0B9EC740B79EAF795A3A44F54F9528DF80B7B10C80830C248C0DA0A0390C8A413A3C38BB7CF499B93B2E3787AAEB70276EB6B87255B8CA730F64EABD9D908422C10762AD22E0B869BDA06198E50F5B21A7D8F002A38537B03D45\
// FCADD5DC61AC5BD01FD29A924C67B38C32DDA61EB15CD5542C6E44790CD77A1ACF499855426A086F464767F0E366FD4C952A0C5532A3E2481FF9097C1674B49F3BEE0B290E321AE8EFF623D08E8413FF0866B6785DFCD770886DBB220648812D5330788301F8AF\
// 3F07B5748982F080EF83B9E61063F4A7AA6720A13ECEF43B746BDE51C48F760503D7A9399EF5DD8F5FA7F09321BBAA0945B233C6469B520F357A6C9DDA6BCCE46CC958178FCD173DB951D15559F1147BB40897A06C2B27D7EEC04AAF191A38B297AF5CEE70BCB0\
// CBF6AE6139BF31F619FBB67B7381761C6B45ED8CA07B43DB8A72D7F1F8E94ECA1916249B4D0338BC1BB17627FBC2DAAD8145329492721B8698475415278BA579696419F378CB387A811D2B8E678A7E5154DD5692D61632ABB7A51B5F03BCB17B9A971C39E1C2C9\
// 2266F8433901D31261F04FB8C6C3EAF59BCAB4022079AA2A651C95199371A3465A5E98F052B959D669B89C114A3BDD69E973598FF907C495ABFFD326BB66A6503F697245F93DC7F18DDC42C761F2EADA48223F1D966861A2AC39B28F7C267BB28277555C80FC78\
// 8423B3E667442E56A6AEA5D4CD0707E03103DF2AF339F2AD67F4AAEBF00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
// 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000BBE7700481CE78FC040BB1DDE4D8FE55985227C9A42401FA7D33DD09E5CD83A4"
if (!fullLic || fullLic == undefined) { if (!fullLic || fullLic == undefined) {
console.log("fullLic error") console.log("fullLic error")
...@@ -430,6 +475,7 @@ function testLicParce() { ...@@ -430,6 +475,7 @@ function testLicParce() {
} }
// console // console
const cksum = figureChecksum(fullLic, 2048); const cksum = figureChecksum(fullLic, 2048);
fullLic = "";
// console.log('checksum = 0x' + cksum.toString(16).padStart(2, '0')); // console.log('checksum = 0x' + cksum.toString(16).padStart(2, '0'));
return "0X" + cksum.toString(16).padStart(2, '0').toUpperCase(); return "0X" + cksum.toString(16).padStart(2, '0').toUpperCase();
} }
...@@ -538,5 +584,6 @@ module.exports = { ...@@ -538,5 +584,6 @@ module.exports = {
setSsid: setSsid, setSsid: setSsid,
getssid: getssid, getssid: getssid,
initautoFactorySetting: initautoFactorySetting, initautoFactorySetting: initautoFactorySetting,
getWifiInfo: getWifiInfo getWifiInfo: getWifiInfo,
gotoWriteLic: gotoWriteLic
} }
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <signal.h> #include <signal.h>
#include <sys/stat.h> // 放在现有 #include 区域任意位置 #include <sys/stat.h> // 放在现有 #include 区域任意位置
#include <stdint.h> // 就有 uint8_t #include <stdint.h> // 就有 uint8_t
#include <sched.h>
#define DEBUG 0 /* 1=打开调试 0=关闭打印 */ #define DEBUG 0 /* 1=打开调试 0=关闭打印 */
#if DEBUG #if DEBUG
...@@ -30,6 +31,14 @@ static int g_rxlen = 0; /* 有效长度 ...@@ -30,6 +31,14 @@ static int g_rxlen = 0; /* 有效长度
static int g_rxHexlen = 0; /* 有效长度 */ static int g_rxHexlen = 0; /* 有效长度 */
static pthread_mutex_t g_rx_mutex = PTHREAD_MUTEX_INITIALIZER; /* 互斥锁 */ static pthread_mutex_t g_rx_mutex = PTHREAD_MUTEX_INITIALIZER; /* 互斥锁 */
void set_realtime_priority(pthread_t thread, int priority) {
struct sched_param param;
param.sched_priority = priority;
pthread_setschedparam(thread, SCHED_FIFO, &param);
}
/* ---------------- 串口底层 ---------------- */ /* ---------------- 串口底层 ---------------- */
/** /**
* @brief 接收数据 * @brief 接收数据
...@@ -332,6 +341,9 @@ int uart_init(const char *port, const char *baud_str) ...@@ -332,6 +341,9 @@ int uart_init(const char *port, const char *baud_str)
pthread_t tid; pthread_t tid;
pthread_create(&tid, NULL, rx_thread, (void *)(long)fd); pthread_create(&tid, NULL, rx_thread, (void *)(long)fd);
set_realtime_priority(tid, 10);
pthread_detach(tid); /* 自生自灭 */ pthread_detach(tid); /* 自生自灭 */
return fd; return fd;
} }
......
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