Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ARZZEZZAN opened this issue Jan 16, 2024 · 0 comments
Open

Comments

@ARZZEZZAN
Copy link

ARZZEZZAN commented Jan 16, 2024

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant