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
7eef828e
Commit
7eef828e
authored
Oct 20, 2025
by
lyong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化evm校验
parent
d1d27272
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
6 deletions
+22
-6
factoryTest_plugin/factory_autoFactoryTestUtil.js
factoryTest_plugin/factory_autoFactoryTestUtil.js
+22
-6
No files found.
factoryTest_plugin/factory_autoFactoryTestUtil.js
View file @
7eef828e
...
...
@@ -760,13 +760,29 @@ function verifyHostIDChecksum() {
* @param {string} s 输入字符串
* @returns {string} 返回 "0xXX" 格式校验和
*/
function
calculateSumChecksum
(
s
)
{
if
(
!
s
)
return
"
0X00
"
;
let
sum
=
0
;
for
(
let
i
=
0
;
i
<
s
.
length
;
i
++
)
{
if
(
s
[
i
]
!==
'
-
'
)
sum
+=
s
.
charCodeAt
(
i
)
&
0xFF
;
function
calculateSumChecksum
(
dataString
)
{
console
.
log
(
"
calculateSumChecksum dataString:
"
+
dataString
);
if
(
!
dataString
)
return
"
0X00
"
;
try
{
// 1. 移除可能的空格并按连字符分割
let
parts
=
dataString
.
replace
(
/-/g
,
""
);
let
totalSum
=
0
;
// 2. 遍历每个字符,将其转换为整数并累加
for
(
let
i
=
0
;
i
<
parts
.
length
;
i
++
)
{
totalSum
+=
parseInt
(
parts
[
i
],
10
);
}
// 3. 取低 8 位 (等效于 totalSum & 0xFF)
let
checksum
=
"
0X
"
+
(
totalSum
&
0xFF
).
toString
(
16
).
toUpperCase
().
padStart
(
2
,
'
0
'
);
console
.
log
(
`累加和为
${
checksum
}
`
);
return
checksum
;
}
catch
(
e
)
{
console
.
error
(
`计算累加和校验时出错: 数据包含非数字部分。
${
e
}
`
);
return
"
0X00
"
;
// 或返回错误码/None
}
return
"
0X
"
+
(
sum
&
0xFF
).
toString
(
16
).
padStart
(
2
,
'
0
'
).
toUpperCase
();
}
...
...
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