Skip to content

连续读取数据 #6

Closed
Closed

Description

@guchainews

大神,能否写一个连续读取数据的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"

Activity

  1. LUJIAN2020 commented on Sep 13, 2024

    @LUJIAN2020
    Owner

    大神,能否写一个连续读取数据的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"

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

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

  2. LUJIAN2020 commented on Sep 13, 2024

    @LUJIAN2020
    Owner

    现在我更新了一些代码,抛出异常代码已经删除,如果读不到数据将返回空

  3. Repository owner locked and limited conversation to collaborators on Sep 13, 2024
  4. converted this issue into a discussion #7 on Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions