Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
re860_factory
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
waterword
re860_factory
Commits
719b5a97
Commit
719b5a97
authored
Oct 27, 2025
by
lyong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:新增指定长度授权方式
parent
1261225a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
73 additions
and
34 deletions
+73
-34
factoryTest_plugin/factory_autoFactoryTestUtil.js
factoryTest_plugin/factory_autoFactoryTestUtil.js
+73
-34
No files found.
factoryTest_plugin/factory_autoFactoryTestUtil.js
View file @
719b5a97
...
...
@@ -381,63 +381,102 @@ function getpectedHexLen(seg) {
function
licParce
(
recvBuf
)
{
var
comallArrLicVal
=
'
4954455F4C4943
'
;
// var allArrLicVal = '3332'; // 外部可改,总段号(16 进制字符串)
var
equal
=
'
3D
'
;
// console.log('licParce recv:' + recvBuf);
var
comallArrLicVal
=
'
4954455F4C4943
'
;
// "AT+WRITE_LIC"
var
equal
=
'
3D
'
;
// "="
var
slash
=
'
2F
'
;
// "/"
console
.
log
(
'
licParce recv:
'
+
recvBuf
);
var
buf
=
recvBuf
;
var
titleBuf
=
recvBuf
;
/* 1. 以 comallArrLicVal 为分隔符劈成两段 */
const
pos
=
buf
.
indexOf
(
comallArrLicVal
);
// console.log("pos:" + pos)
if
(
pos
===
-
1
)
return
0
;
let
core
=
buf
.
slice
(
pos
+
comallArrLicVal
.
length
+
12
);
// 后半段
// console.log("!!!!1_ core:" + core)
let
core
=
buf
.
slice
(
pos
+
comallArrLicVal
.
length
+
12
);
// 后半段
// console.log("1--core:" + core);
/* 2. 去尾 D0D0A0A */
// if (core.endsWith('D0D0A0A'))
core
=
core
.
slice
(
0
,
-
8
);
console
.
log
(
"
recv:
"
+
core
);
// console.log("recv:" + core);
/* 3. 解析帧头 */
const
posT
=
titleBuf
.
indexOf
(
equal
);
let
coreT
=
titleBuf
.
slice
(
posT
+
equal
.
length
);
// console.log("coreT:" + coreT);
const
slashPos
=
coreT
.
indexOf
(
'
2F
'
);
if
(
slashPos
===
1
)
{
return
0
;
}
const
segHex
=
coreT
.
slice
(
0
,
slashPos
);
// 例如 "31"
const
allArrLicVal
=
coreT
.
slice
(
slashPos
+
2
,
slashPos
+
6
);
// 总段数
console
.
log
(
"
allArrLicVal:
"
+
allArrLicVal
);
// Hex 字符串当成 ASCII 解码
// Hex → 字节 → ASCII → 数字
// const segChar = String.fromCharCode(parseInt(segHex, 16)); // '1'
const
slashPos
=
coreT
.
indexOf
(
slash
);
if
(
slashPos
===
-
1
)
return
0
;
const
segHex
=
coreT
.
slice
(
0
,
slashPos
);
// 例如 "01"
const
totSegHex
=
coreT
.
slice
(
slashPos
+
2
,
slashPos
+
6
);
// 总段数
const
curSeg
=
hexToAscii
(
segHex
);
const
totSeg
=
hexToAscii
(
allArrLicVal
);
const
totSeg
=
hexToAscii
(
totSegHex
);
console
.
log
(
"
recv index:
"
+
curSeg
);
console
.
log
(
"
all index:
"
+
totSeg
);
//总长度数据4096
var
expectedHexLen
=
getpectedHexLen
(
totSeg
);
/* 4. 检查是否有指定长度的数据 */
const
optionHex
=
core
.
slice
(
0
,
2
);
// "2F"
console
.
log
(
"
optionHex:
"
+
optionHex
);
if
(
optionHex
==
"
2F
"
)
{
// 有指定长度的数据
const
params
=
{
core
:
core
,
curSeg
:
curSeg
,
totSeg
:
totSeg
};
return
licParceSpecifiedLength
(
params
);
}
else
{
// 没有指定长度的数据,使用默认长度
const
params
=
{
core
:
core
,
curSeg
:
curSeg
,
totSeg
:
totSeg
};
return
licParceFixedLength
(
params
);
}
}
if
(
core
.
length
!==
expectedHexLen
)
{
console
.
log
(
`长度错误:期望
${
expectedHexLen
}
,实际
${
core
.
length
}
`
);
function
licParceFixedLength
(
params
)
{
const
{
core
,
curSeg
,
totSeg
}
=
params
;
var
expectedHexLen
=
getpectedHexLen
(
totSeg
);
if
(
core
.
length
!==
expectedHexLen
)
{
//实际长度应该 / 2,为16进制长度
console
.
log
(
`!!Length error: Expected
${(
expectedHexLen
/
2
)}
, but got
${(
core
.
length
/
2
)}
`
);
return
2
;
}
else
{
console
.
log
(
`
长度正确:期望
${
expectedHexLen
}
,实际
${
core
.
length
}
`
);
}
else
{
console
.
log
(
`
!!Length is correct: Expected
${(
expectedHexLen
/
2
)}
, Actual
${(
core
.
length
/
2
)
}
`
);
}
console
.
log
(
"
!!data:
"
+
core
);
/* 5. 格式化并缓存 */
const
spaced
=
formatHexWithSpace
(
core
);
licSegArray
[
curSeg
-
1
]
=
spaced
;
/* 4. 格式化并缓存 */
// const spaced = formatHexWithSpace(core);
const
spaced
=
core
;
console
.
log
(
`seg=
${
curSeg
}
/
${
totSeg
}
data=
${
spaced
}
`
);
if
(
curSeg
===
totSeg
)
{
return
3
;
}
return
1
;
}
function
licParceSpecifiedLength
(
params
)
{
const
{
core
,
curSeg
,
totSeg
}
=
params
;
const
lengthHex
=
core
.
slice
(
2
,
10
);
const
lengthSeg
=
hexToAscii
(
lengthHex
);
const
dataLen
=
parseInt
(
lengthSeg
,
10
);
// 转换为十进制数字
let
data
=
core
.
slice
(
10
);
licSegArray
[
curSeg
-
1
]
=
spaced
;
console
.
log
(
"
dataLen:
"
+
dataLen
);
console
.
log
(
"
!!data:
"
+
data
);
var
dataLength
=
(
data
.
length
/
2
)
if
(
dataLength
!==
dataLen
)
{
console
.
log
(
`!!Length error: Expected
${
dataLen
}
, but got
${
dataLength
}
`
);
return
2
;
}
else
{
console
.
log
(
`!!Length is correct: Expected
${
dataLen
}
, Actual
${
dataLength
}
`
);
}
/* 5. 格式化并缓存 */
const
spaced
=
formatHexWithSpace
(
data
);
licSegArray
[
curSeg
-
1
]
=
spaced
;
console
.
log
(
`seg=
${
curSeg
}
/
${
totSeg
}
data=
${
spaced
}
`
);
if
(
curSeg
===
totSeg
)
{
...
...
@@ -726,7 +765,7 @@ function gotoWriteHostIdData(fullHex) {
system
(
SECURE_APP_PATH
+
"
-b
"
+
fileName
);
// hostIdSegArray = []; // 清空缓存
// console.log('HostId 已全部写入:', recLic);
},
100
);
}
...
...
@@ -816,7 +855,7 @@ function getTPVersionNew() {
// 转换为10进制
const
decimalValue
=
parseInt
(
version
,
16
);
return
decimalValue
.
toString
();
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment