Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
1b76f37a
D
Docs
项目概览
OpenHarmony
/
Docs
1 年多 前同步成功
通知
159
Star
292
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
1b76f37a
编写于
6月 15, 2023
作者:
O
openharmony_ci
提交者:
Gitee
6月 15, 2023
浏览文件
操作
浏览文件
下载
差异文件
!19761 Fix:Add interface parameter definitions
Merge pull request !19761 from wangyipeng/cherry-pick-1686819368
上级
72d6d5f8
70b79f70
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
95 addition
and
6 deletion
+95
-6
zh-cn/application-dev/reference/apis/js-apis-usbManager.md
zh-cn/application-dev/reference/apis/js-apis-usbManager.md
+95
-6
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-usbManager.md
浏览文件 @
1b76f37a
...
...
@@ -152,7 +152,7 @@ hasRight(deviceName: string): boolean
**示例:**
```
js
let
devicesName
=
"
1-1
"
;
let
devicesName
=
"
1-1
"
;
let
bool
=
usb
.
hasRight
(
devicesName
);
console
.
log
(
`
${
bool
}
`
);
```
...
...
@@ -180,7 +180,7 @@ requestRight(deviceName: string): Promise<boolean>
**示例:**
```
js
let
devicesName
=
"
1-1
"
;
let
devicesName
=
"
1-1
"
;
usb
.
requestRight
(
devicesName
).
then
((
ret
)
=>
{
console
.
log
(
`requestRight =
${
ret
}
`
);
});
...
...
@@ -209,7 +209,7 @@ removeRight(deviceName: string): boolean
**示例:**
```
js
let
devicesName
=
"
1-1
"
;
let
devicesName
=
"
1-1
"
;
if
(
usb
.
removeRight
(
devicesName
))
{
console
.
log
(
`Succeed in removing right`
);
}
...
...
@@ -277,6 +277,16 @@ claimInterface(pipe: USBDevicePipe, iface: USBInterface, force ?: boolean): numb
**示例:**
```
js
let
devicesList
=
usb
.
getDevices
();
if
(
devicesList
.
length
==
0
)
{
console
.
log
(
`device list is empty`
);
return
;
}
let
device
=
devicesList
[
0
];
usb
.
requestRight
(
device
.
name
);
let
devicepipe
=
usb
.
connectDevice
(
device
);
let
interfaces
=
device
.
configs
[
0
].
interfaces
[
0
];
let
ret
=
usb
.
claimInterface
(
devicepipe
,
interfaces
);
console
.
log
(
`claimInterface =
${
ret
}
`
);
```
...
...
@@ -307,7 +317,18 @@ releaseInterface(pipe: USBDevicePipe, iface: USBInterface): number
**示例:**
```
js
let
ret
=
usb
.
releaseInterface
(
devicepipe
,
interfaces
);
let
devicesList
=
usb
.
getDevices
();
if
(
devicesList
.
length
==
0
)
{
console
.
log
(
`device list is empty`
);
return
;
}
let
device
=
devicesList
[
0
];
usb
.
requestRight
(
device
.
name
);
let
devicepipe
=
usb
.
connectDevice
(
device
);
let
interfaces
=
device
.
configs
[
0
].
interfaces
[
0
];
let
ret
=
usb
.
claimInterface
(
devicepipe
,
interfaces
);
ret
=
usb
.
releaseInterface
(
devicepipe
,
interfaces
);
console
.
log
(
`releaseInterface =
${
ret
}
`
);
```
...
...
@@ -337,6 +358,16 @@ setConfiguration(pipe: USBDevicePipe, config: USBConfiguration): number
**示例:**
```
js
let
devicesList
=
usb
.
getDevices
();
if
(
devicesList
.
length
==
0
)
{
console
.
log
(
`device list is empty`
);
return
;
}
let
device
=
devicesList
[
0
];
usb
.
requestRight
(
device
.
name
);
let
devicepipe
=
usb
.
connectDevice
(
device
);
let
config
=
device
.
configs
[
0
];
let
ret
=
usb
.
setConfiguration
(
devicepipe
,
config
);
console
.
log
(
`setConfiguration =
${
ret
}
`
);
```
...
...
@@ -367,7 +398,18 @@ setInterface(pipe: USBDevicePipe, iface: USBInterface): number
**示例:**
```
js
let
ret
=
usb
.
setInterface
(
devicepipe
,
interfaces
);
let
devicesList
=
usb
.
getDevices
();
if
(
devicesList
.
length
==
0
)
{
console
.
log
(
`device list is empty`
);
return
;
}
let
device
=
devicesList
[
0
];
usb
.
requestRight
(
device
.
name
);
let
devicepipe
=
usb
.
connectDevice
(
device
);
let
interfaces
=
device
.
configs
[
0
].
interfaces
[
0
];
let
ret
=
usb
.
claimInterface
(
devicepipe
,
interfaces
);
ret
=
usb
.
setInterface
(
devicepipe
,
interfaces
);
console
.
log
(
`setInterface =
${
ret
}
`
);
```
...
...
@@ -396,6 +438,14 @@ getRawDescriptor(pipe: USBDevicePipe): Uint8Array
**示例:**
```
js
let
devicesList
=
usb
.
getDevices
();
if
(
devicesList
.
length
==
0
)
{
console
.
log
(
`device list is empty`
);
return
;
}
usb
.
requestRight
(
devicesList
[
0
].
name
);
let
devicepipe
=
usb
.
connectDevice
(
devicesList
[
0
]);
let
ret
=
usb
.
getRawDescriptor
(
devicepipe
);
```
...
...
@@ -424,6 +474,14 @@ getFileDescriptor(pipe: USBDevicePipe): number
**示例:**
```
js
let
devicesList
=
usb
.
getDevices
();
if
(
devicesList
.
length
==
0
)
{
console
.
log
(
`device list is empty`
);
return
;
}
usb
.
requestRight
(
devicesList
[
0
].
name
);
let
devicepipe
=
usb
.
connectDevice
(
devicesList
[
0
]);
let
ret
=
usb
.
getFileDescriptor
(
devicepipe
);
```
...
...
@@ -462,6 +520,15 @@ let param = {
index
:
0
,
data
:
null
};
let
devicesList
=
usb
.
getDevices
();
if
(
devicesList
.
length
==
0
)
{
console
.
log
(
`device list is empty`
);
return
;
}
usb
.
requestRight
(
devicesList
[
0
].
name
);
let
devicepipe
=
usb
.
connectDevice
(
devicesList
[
0
]);
usb
.
controlTransfer
(
devicepipe
,
param
).
then
((
ret
)
=>
{
console
.
log
(
`controlTransfer =
${
ret
}
`
);
})
...
...
@@ -498,8 +565,22 @@ bulkTransfer(pipe: USBDevicePipe, endpoint: USBEndpoint, buffer: Uint8Array, tim
//usb.getDevices 接口返回数据集合,取其中一个设备对象,并获取权限 。
//把获取到的设备对象作为参数传入usb.connectDevice;当usb.connectDevice接口成功返回之后;
//才可以调用第三个接口usb.claimInterface.当usb.claimInterface 调用成功以后,再调用该接口。
let
devicesList
=
usb
.
getDevices
();
if
(
devicesList
.
length
==
0
)
{
console
.
log
(
`device list is empty`
);
return
;
}
let
device
=
devicesList
[
0
];
usb
.
requestRight
(
device
.
name
);
let
devicepipe
=
usb
.
connectDevice
(
device
);
let
interfaces
=
device
.
configs
[
0
].
interfaces
[
0
];
let
endpoint
=
device
.
configs
[
0
].
interfaces
[
0
].
endpoints
[
0
];
let
ret
=
usb
.
claimInterface
(
devicepipe
,
interfaces
);
let
buffer
=
new
Uint8Array
(
128
);
usb
.
bulkTransfer
(
devicepipe
,
endpoint
,
buffer
).
then
((
ret
)
=>
{
console
.
log
(
`bulkTransfer =
${
ret
}
`
);
console
.
log
(
`bulkTransfer =
${
ret
}
`
);
});
```
...
...
@@ -528,6 +609,14 @@ closePipe(pipe: USBDevicePipe): number
**示例:**
```
js
let
devicesList
=
usb
.
getDevices
();
if
(
devicesList
.
length
==
0
)
{
console
.
log
(
`device list is empty`
);
return
;
}
usb
.
requestRight
(
devicesList
[
0
].
name
);
let
devicepipe
=
usb
.
connectDevice
(
devicesList
[
0
]);
let
ret
=
usb
.
closePipe
(
devicepipe
);
console
.
log
(
`closePipe =
${
ret
}
`
);
```
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录