Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
J
jensen
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
Skye Yu
jensen
Commits
e1a8f86c
Commit
e1a8f86c
authored
Sep 10, 2025
by
martin hou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 调整和适配surface pro的消息传输
parent
9e8dcfb1
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
11 deletions
+16
-11
index.tsx
src/index.tsx
+8
-8
jensen.js
src/utils/jensen.js
+8
-3
No files found.
src/index.tsx
View file @
e1a8f86c
...
...
@@ -196,15 +196,15 @@ export function Home() {
let
filename
=
''
;
let
filelength
=
0
;
const
transferFile
=
async
()
=>
{
//
if (files == null || files.length == 0) return alert('请先点击List Files');
//
let idx = prompt('请输入需要获取的文件序号(从0开始):', '0');
//
if (idx === undefined || idx === null) return;
//
let num = parseInt(idx);
//
if (isNaN(num) || num < 0 || num >= files.length) return alert('请输入正确的序号');
//
let file = files[num];
if
(
files
==
null
||
files
.
length
==
0
)
return
alert
(
'请先点击List Files'
);
let
idx
=
prompt
(
'请输入需要获取的文件序号(从0开始):'
,
'0'
);
if
(
idx
===
undefined
||
idx
===
null
)
return
;
let
num
=
parseInt
(
idx
);
if
(
isNaN
(
num
)
||
num
<
0
||
num
>=
files
.
length
)
return
alert
(
'请输入正确的序号'
);
let
file
=
files
[
num
];
// 2025Jun24-165914-Wip00.hda, 232704 @ 19392
filename
=
'2025Jun24-165914-Wip00.hda'
;
filelength
=
232704
;
filename
=
file
.
name
;
filelength
=
file
.
length
;
get_file
();
}
...
...
src/utils/jensen.js
View file @
e1a8f86c
...
...
@@ -108,7 +108,7 @@ function Jensen(log, conn) {
this
.
lastTimerInvoked
=
new
Date
().
getTime
();
this
.
wakeupTime
=
null
;
const
RECV_BUFF_SIZE
=
32
00
;
const
RECV_BUFF_SIZE
=
5120
00
;
const
_check_conn_status
=
()
=>
{
if
(
device
?.
opened
===
false
)
{
...
...
@@ -335,6 +335,7 @@ function Jensen(log, conn) {
Logger
.
debug
(
'jensen'
,
'sendNext'
,
pid
+
'-command: '
+
current
+
', data bytes: '
+
data
.
byteLength
);
self
.
timewait
=
cmd
.
command
==
TRANSFER_FILE
||
cmd
.
command
==
GET_FILE_BLOCK
?
1000
:
10
;
// self.timewait = 10000;
console
.
log
(
pid
+
'-send'
,
data
);
if
(
self
.
onprogress
&&
cmd
.
command
==
TRANSFER_FILE
)
{
...
...
@@ -486,11 +487,12 @@ function Jensen(log, conn) {
totalBuffLen
+=
blocks
[
i
].
byteLength
;
}
Logger
.
info
(
'jensen'
,
'transfer'
,
`try to decode buffer with
${
totalBuffLen
}
bytes`
);
console
.
log
(
'blocks'
,
blocks
);
let
stime
=
new
Date
();
let
buff
=
new
ArrayBuffer
(
RECV_BUFF_SIZE
*
2
);
// bview的大小,必须是要大于固件端给出的最大包大小,已知的最大大小为8192字节,但是后面可能会提供整文件大小传输的情况,那个时候大小会变得巨大
let
bview
=
new
Uint8Array
(
10240
);
let
bview
=
new
Uint8Array
(
RECV_BUFF_SIZE
*
2
);
// buff中实际使用的字节数,有效字节数
let
buffLength
=
0
;
let
crash
=
false
;
...
...
@@ -515,7 +517,7 @@ function Jensen(log, conn) {
}
else
Logger
.
info
(
'jensen'
,
'decode'
,
`start:
${
startIndex
}
, length:
${
buffLength
}
, cut:
${
rst
.
length
}
`
);
}
catch
(
e
)
{
//
Logger.error('jensen', 'decode', String(e));
Logger
.
error
(
'jensen'
,
'decode'
,
String
(
e
));
crash
=
true
;
break
;
}
...
...
@@ -579,6 +581,7 @@ function Jensen(log, conn) {
};
const
decodeMessage
=
function
(
dataView
,
startIndex
,
buffLength
)
{
console
.
log
(
'decodeMessage'
,
startIndex
,
buffLength
,
dataView
);
let
dataLen
=
buffLength
-
startIndex
;
if
(
dataLen
<
12
)
return
null
;
if
(
dataView
[
startIndex
+
0
]
!==
0x12
||
dataView
[
startIndex
+
1
]
!==
0x34
)
throw
new
Error
(
'invalid header'
);
...
...
@@ -897,6 +900,8 @@ Jensen.prototype.listFiles = async function () {
}
});
console
.
log
(
'files'
,
files
);
if
((
fc
&&
files
.
length
>=
fc
.
count
)
||
(
fcount
>
-
1
&&
files
.
length
>=
fcount
))
{
// delete jensen[tag];
jensen
[
tag
]
=
null
;
...
...
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