Skip to content

Latest version not working on Windows #192

Closed

Description

@tresf

JSSC 2.10.1 is not able to receive serial data on Windows 11.

List Ports Open Port Send Data Receive Data
Linux ✅ ✅ ✅ ✅
macOS ✅ ✅ ✅ ✅
Windows ✅ ✅ ✅ 🚫
  • I'm testing using a Mettler Toledo P90 scale.
    • In previous versions of JSSC, sending W\n would return the weight value on this scale. This still works on Linux, and macOS but Windows no longer returns a value.
    • As a baseline for sending data, I testested Z\n to zero the scale and that works to "ZERO" the scale for all platforms so I believe JSSC is sending data just fine but unable to receive data on Windows.

Workaround:

  • Downgrade to JSSC 2.9.6

Possible causes:

@hiddenalpha FYI

Activity

  1. added this to the 2.10.2 milestone on Jun 10, 2025
  2. added
    bugSomething isn't working
    help wantedExtra attention is needed
    on Jun 10, 2025
  3. hiddenalpha commented on Jun 10, 2025

    @hiddenalpha

    What are the exact symptoms? Any exceptions? Other errors logged? How does the read behave? Is it just blocking? Returning null? etc ...?

  4. tresf commented on Jun 10, 2025

    @tresf
    Author

    What are the exact symptoms? Any exceptions? Other errors logged? How does the read behave? Is it just blocking? Returning null? etc ...?

    I've updated the issue description to be much more specific. No visible errors currently. In short, TX is OK, RX is broken. TX and RX work fine on Linux and macOS.

  5. tresf commented on Jun 10, 2025

    @tresf
    Author

    How does the read behave? Is it just blocking? Returning null? etc ...?

    I'm using the listener to receive the read events and they're never firing (at least not with the app I'm testing). I'll put the app into debug to see if anything at all is firing because I do some sanity filtering before it hits the client.

  6. tresf commented on Jun 10, 2025

    @tresf
    Author

    Testing my app in debug, 2.10.1 is working OK. I'm scratching my head here...

  7. tresf commented on Jun 10, 2025

    @tresf
    Author

    @hiddenalpha found it... For some reason debug slowed it down just enough to not throw an error... This is what I see...

    Exception in thread "EventThread COM5" java.lang.IllegalArgumentException: byteCount 0. Expected range: 1..2147483647
    	at jssc.SerialNativeInterface.readBytes(Native Method)
    	at jssc.SerialPort.readBytes(SerialPort.java:514)
    	at jssc.SerialPort.readBytes(SerialPort.java:661)
    	at qz.communication.SerialIO.processSerialEvent(SerialIO.java:85)
    	at qz.utils.SerialUtilities.lambda$setupSerialPort$0(SerialUtilities.java:259)
    	at jssc.SerialPort$EventThread.run(SerialPort.java:1217)
    

    This means the regression was introduced in #175

  8. hiddenalpha commented on Jun 10, 2025

    @hiddenalpha

    Very good :) This message enlightens the situation.

    The result surprises me. I did not expect any code trying to read zero bytes (I've no idea why one should do this). If reading zero bytes really should work, I can adapt it, so a read of zero bytes is not considered an error.

    Yep, agree with 175 introducing it.

  9. tresf commented on Jun 10, 2025

    @tresf
    Author

    The listener fires and then my code filters for SerialPortEvent.isRXCHAR() and I simply read the bytes, so there must be cases on Windows when the events are triggered before the buffer has had time to fill. AFAIR, this has been a long standing issue with JSSC as my code around this particular serial scale has always require STX/ETX to concat messages on the listener. This may be an underlying bug with how polling is occurring on Windows but that's how it's worked historically and unless we fix the underlying polling bug, we'll have to accomodate 0-byte messages.

    Testing my app in debug, 2.10.1 is working OK. I'm scratching my head here...

    Comically, the debugger must be allowing enough time for the buffer to be filling up, circumventing the underlying issue.

  10. tresf commented on Jun 10, 2025

    @tresf
    Author

    @hiddenalpha I was going to write my own patch to this, but then realized that I'm not entirely sure how the behavior should be for zero bytes. Please feel free to push directly to this branch:

    https://github.com/java-native/jssc/tree/zero-bytecount

  11. hiddenalpha commented on Jun 10, 2025

    @hiddenalpha

    @hiddenalpha I was going to write my own patch to this, but then realized that I'm not entirely sure how the behavior should be for zero bytes. Please feel free to push directly to this branch:

    https://github.com/java-native/jssc/tree/zero-bytecount

    Hmm. I'm getting a 404 there. Nevermind :) I opened pull #193 meanwhile.

  12. tresf commented on Jun 10, 2025

    @tresf
    Author

    @hiddenalpha I was going to write my own patch to this, but then realized that I'm not entirely sure how the behavior should be for zero bytes. Please feel free to push directly to this branch:
    https://github.com/java-native/jssc/tree/zero-bytecount

    Hmm. I'm getting a 404 there. Nevermind :) I opened pull #193 meanwhile.

    I deleted it when I saw the new PR come in.

  13. tresf commented on Jun 10, 2025

    @tresf
    Author

    Tested against master-precompiled-natives (which was manually run to create the updated binaries) and this is fixed. Thanks @hiddenalpha. @pietrygamat we should bump the release to use this build when convenient/possible.

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

    bugSomething isn't workinghelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions