Skip to content

Method readArray returns 0 even though data is available for reading #250

@ARZZEZZAN

Description

@ARZZEZZAN

I encountered an interesting problem: when calling the readArray(b, off, Minimum) method, which is called exclusively inside your code(namely RTXTPort#1492), the result is 0(Minimum = 1). The b parameter is not empty, the bytes are readable. Presumably the problem may also be caused by the int a = nativeavailable();(RTXTPort#1467) method, which returns 0, which is why Minimum = 1.

Important note, the problem is not static, i.e. it is periodic, sometimes it can read normally, and sometimes the problem pops and it can freeze for a few minutes up.

My code:

      byte[] buffer = new byte[4096];
      
      inputStream = serialPort.getInputStream();
      
      while (!isInterrupted())
      {
      
        // problem is here, it returns 0 sometimes ->
         int bytesRead = inputStream.read(buffer); //#RTXTPort inputStream 
        
        if (bytesRead == -1)
          break;
        
       ..........
        
        Thread.currentThread().sleep(500);

What the problem is and whether it's yours?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions