Skip to content

连续读取数据 #7

Answered by LUJIAN2020
guchainews asked this question in Q&A
Sep 13, 2024 · 2 comments · 1 reply
Discussion options

You must be logged in to vote

大神,能否写一个连续读取数据的DEMO。我照着https://github.com/anotherlab/UsbSerialForAndroid写了一个,使用的是 Dispatcher.UIThread while(true) { step() } ,但是只能读一次数据,第二次就报错: "Read failed,Result:-1,Address:132,Direction:In,EndpointNumber:4,Type:XferBulk,MaxPacketSize:64,Buffer:,Offset:0,Length:2048,Timeout:10000"

如果没有数据可以读取的话是会报错的,这个需要自己处理,下面是读取的代码

Mono.Android的注释是 传输的数据长度(或零)表示成功,或负值表示失败,我这里做了抛出异常处理

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@guchainews
Comment options

Answer selected by guchainews
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #6 on September 13, 2024 12:57.