Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
a06b147d
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看板
提交
a06b147d
编写于
3月 10, 2023
作者:
L
luo-wei246
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix:usb Document Modification
Signed-off-by:
N
luo-wei246
<
luowei137@huawei.com
>
上级
1e517d40
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
32 addition
and
21 deletion
+32
-21
zh-cn/application-dev/reference/apis/js-apis-usb-deprecated.md
.../application-dev/reference/apis/js-apis-usb-deprecated.md
+15
-9
zh-cn/application-dev/reference/apis/js-apis-usb.md
zh-cn/application-dev/reference/apis/js-apis-usb.md
+17
-12
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-usb-deprecated.md
浏览文件 @
a06b147d
...
...
@@ -32,7 +32,7 @@ getDevices(): Array<Readonly<USBDevice>>
```
js
let
devicesList
=
usb
.
getDevices
();
console
.
log
(
`devicesList =
${
JSON
.
stringify
(
devicesList
)
}
`
);
console
.
log
(
`devicesList =
${
devicesList
}
`
);
//devicesList 返回的数据结构
//此处提供一个简单的示例,如下
[
...
...
@@ -111,7 +111,7 @@ connectDevice(device: USBDevice): Readonly<USBDevicePipe>
```
js
let
devicepipe
=
usb
.
connectDevice
(
device
);
console
.
log
(
`devicepipe =
${
JSON
.
stringify
(
devicepipe
)
}
`
);
console
.
log
(
`devicepipe =
${
devicepipe
}
`
);
```
## usb.hasRight
...
...
@@ -167,7 +167,7 @@ requestRight(deviceName: string): Promise<boolean>
```
js
let
devicesName
=
"
1-1
"
;
usb
.
requestRight
(
devicesName
).
then
((
ret
)
=>
{
console
.
log
(
`requestRight =
${
JSON
.
stringify
(
ret
)
}
`
);
console
.
log
(
`requestRight =
${
ret
}
`
);
});
```
...
...
@@ -375,8 +375,9 @@ controlTransfer(pipe: USBDevicePipe, controlparam: USBControlParams, timeout ?:
**示例:**
```
js
usb
.
controlTransfer
(
devicepipe
,
USBControlParams
).
then
((
ret
)
=>
{
console
.
log
(
`controlTransfer =
${
JSON
.
stringify
(
ret
)}
`
);
let
param
=
new
usb
.
USBControlParams
();
usb
.
controlTransfer
(
devicepipe
,
param
).
then
((
ret
)
=>
{
console
.
log
(
`controlTransfer =
${
ret
}
`
);
})
```
...
...
@@ -412,7 +413,7 @@ bulkTransfer(pipe: USBDevicePipe, endpoint: USBEndpoint, buffer: Uint8Array, tim
//把获取到的设备对象作为参数传入usb.connectDevice;当usb.connectDevice接口成功返回之后;
//才可以调用第三个接口usb.claimInterface.当usb.claimInterface 调用成功以后,再调用该接口。
usb
.
bulkTransfer
(
devicepipe
,
endpoint
,
buffer
).
then
((
ret
)
=>
{
console
.
log
(
`bulkTransfer =
${
JSON
.
stringify
(
ret
)
}
`
);
console
.
log
(
`bulkTransfer =
${
ret
}
`
);
});
```
...
...
@@ -499,7 +500,7 @@ usbFunctionsToString(funcs: FunctionType): string
**示例:**
```
js
let
funcs
=
ACM
|
ECM
;
let
funcs
=
usb
.
ACM
|
usb
.
ECM
;
let
ret
=
usb
.
usbFunctionsToString
(
funcs
);
```
...
...
@@ -528,7 +529,7 @@ setCurrentFunctions(funcs: FunctionType): Promise\<boolean\>
**示例:**
```
js
let
funcs
=
HDC
;
let
funcs
=
usb
.
HDC
;
let
ret
=
usb
.
setCurrentFunctions
(
funcs
);
```
...
...
@@ -631,7 +632,12 @@ setPortRoles(portId: number, powerRole: PowerRoleType, dataRole: DataRoleType):
**示例:**
```
js
let
ret
=
usb
.
getSupportedModes
(
0
);
let
portId
=
1
;
usb
.
setPortRoles
(
portId
,
usb
.
PowerRoleType
.
SOURCE
,
usb
.
DataRoleType
.
HOST
).
then
(()
=>
{
console
.
info
(
'
usb setPortRoles successfully.
'
);
}).
catch
(
err
=>
{
console
.
error
(
'
usb setPortRoles failed:
'
+
err
.
code
+
'
message:
'
+
err
.
message
);
});
```
## USBEndpoint
...
...
zh-cn/application-dev/reference/apis/js-apis-usb.md
浏览文件 @
a06b147d
...
...
@@ -30,7 +30,7 @@ getDevices(): Array<Readonly<USBDevice>>
```
js
let
devicesList
=
usb
.
getDevices
();
console
.
log
(
`devicesList =
${
JSON
.
stringify
(
devicesList
)
}
`
);
console
.
log
(
`devicesList =
${
devicesList
}
`
);
//devicesList 返回的数据结构
//此处提供一个简单的示例,如下
[
...
...
@@ -119,13 +119,12 @@ connectDevice(device: USBDevice): Readonly<USBDevicePipe>
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
);
console
.
log
(
`devicepipe =
${
JSON
.
stringify
(
devicepipe
)
}
`
);
console
.
log
(
`devicepipe =
${
devicepipe
}
`
);
```
## usb.hasRight
...
...
@@ -183,7 +182,7 @@ requestRight(deviceName: string): Promise<boolean>
```
js
let
devicesName
=
"
1-1
"
;
usb
.
requestRight
(
devicesName
).
then
((
ret
)
=>
{
console
.
log
(
`requestRight =
${
JSON
.
stringify
(
ret
)
}
`
);
console
.
log
(
`requestRight =
${
ret
}
`
);
});
```
...
...
@@ -211,7 +210,7 @@ removeRight(deviceName: string): boolean
```
js
let
devicesName
=
"
1-1
"
;
if
(
usb
.
removeRight
(
devicesName
)
{
if
usb
.
removeRight
(
devicesName
)
{
console
.
log
(
`Succeed in removing right`
);
}
```
...
...
@@ -246,7 +245,7 @@ addRight(bundleName: string, deviceName: string): boolean
```
js
let
devicesName
=
"
1-1
"
;
let
bundleName
=
"
com.example.hello
"
;
if
(
usb
.
addRight
(
bundleName
,
devicesName
)
{
if
usb
.
addRight
(
bundleName
,
devicesName
)
{
console
.
log
(
`Succeed in adding right`
);
}
```
...
...
@@ -455,8 +454,9 @@ controlTransfer(pipe: USBDevicePipe, controlparam: USBControlParams, timeout ?:
**示例:**
```
js
usb
.
controlTransfer
(
devicepipe
,
USBControlParams
).
then
((
ret
)
=>
{
console
.
log
(
`controlTransfer =
${
JSON
.
stringify
(
ret
)}
`
);
let
param
=
new
usb
.
USBControlParams
();
usb
.
controlTransfer
(
devicepipe
,
param
).
then
((
ret
)
=>
{
console
.
log
(
`controlTransfer =
${
ret
}
`
);
})
```
...
...
@@ -492,7 +492,7 @@ bulkTransfer(pipe: USBDevicePipe, endpoint: USBEndpoint, buffer: Uint8Array, tim
//把获取到的设备对象作为参数传入usb.connectDevice;当usb.connectDevice接口成功返回之后;
//才可以调用第三个接口usb.claimInterface.当usb.claimInterface 调用成功以后,再调用该接口。
usb
.
bulkTransfer
(
devicepipe
,
endpoint
,
buffer
).
then
((
ret
)
=>
{
console
.
log
(
`bulkTransfer =
${
JSON
.
stringify
(
ret
)
}
`
);
console
.
log
(
`bulkTransfer =
${
ret
}
`
);
});
```
...
...
@@ -579,7 +579,7 @@ usbFunctionsToString(funcs: FunctionType): string
**示例:**
```
js
let
funcs
=
ACM
|
ECM
;
let
funcs
=
usb
.
ACM
|
usb
.
ECM
;
let
ret
=
usb
.
usbFunctionsToString
(
funcs
);
```
...
...
@@ -608,7 +608,7 @@ setCurrentFunctions(funcs: FunctionType): Promise\<boolean\>
**示例:**
```
js
let
funcs
=
HDC
;
let
funcs
=
usb
.
HDC
;
let
ret
=
usb
.
setCurrentFunctions
(
funcs
);
```
...
...
@@ -711,7 +711,12 @@ setPortRoles(portId: number, powerRole: PowerRoleType, dataRole: DataRoleType):
**示例:**
```
js
let
ret
=
usb
.
getSupportedModes
(
0
);
let
portId
=
1
;
usb
.
setPortRoles
(
portId
,
usb
.
PowerRoleType
.
SOURCE
,
usb
.
DataRoleType
.
HOST
).
then
(()
=>
{
console
.
info
(
'
usb setPortRoles successfully.
'
);
}).
catch
(
err
=>
{
console
.
error
(
'
usb setPortRoles failed:
'
+
err
.
code
+
'
message:
'
+
err
.
message
);
});
```
## USBEndpoint
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录