Fazecast / jSerialComm

Platform-independent serial port access for Java
GNU Lesser General Public License v3.0
1.34k stars 287 forks source link

JVM crash with 2.8.2 on ARMv5 #391

Closed neeme-praks-sympower closed 2 years ago

neeme-praks-sympower commented 2 years ago

I'm trying to get RS-485 communication working under Linux on ARM926EJ-S rev 5 (v5l) (Nuvoton NUC980).

It works in a C program that initialises like this:

    rs485conf.flags |= SER_RS485_ENABLED;
    /* Set rts delay before send*/
    rs485conf.flags |= SER_RS485_RTS_ON_SEND;
    rs485conf.delay_rts_before_send = 1;
    /* Set rts delay after send */
    rs485conf.flags &= ~(SER_RS485_RTS_AFTER_SEND);
    rs485conf.delay_rts_after_send = 1;
    ioctl (rs485_fd, TIOCSRS485, &rs485conf);

I have not gotten it to work yet with JSerialComm. I initialise the port in Java like this:

  private SerialPort configurePort(SerialPort port, PortConfig config) {
    port.setBaudRate(config.baudRate);
    port.setNumDataBits(config.numDataBits);
    if (config.numStopBits == 1) {
      port.setNumStopBits(SerialPort.ONE_STOP_BIT);
    }
    else if (config.numStopBits == 2) {
      port.setNumStopBits(SerialPort.TWO_STOP_BITS);
    }
    if (config.parity.equals(PortConfig.PARITY_EVEN)) {
      port.setParity(SerialPort.EVEN_PARITY);
    }
    else if (config.parity.equals(PortConfig.PARITY_ODD)) {
      port.setParity(SerialPort.ODD_PARITY);
    }
    else if (config.parity.equals(PortConfig.PARITY_NONE)) {
      port.setParity(SerialPort.NO_PARITY);
    }
    port.setFlowControl(SerialPort.FLOW_CONTROL_DISABLED);
    port.setRs485ModeParameters(true, true, false, false, 1000, 1000);
    if (!port.isOpen()) {
      log.debug("Opening port: {}", config);
      boolean wasSuccess = port.openPort();
      System.out.println("Tried to open port: " + port.getSystemPortName() + " " + wasSuccess);
      System.out.println("Is open? " + port.isOpen());
      if (!wasSuccess) {
        System.out.println("Error: " + port.getLastErrorCode() + " " + port.getLastErrorLocation());
        port.closePort();
      }
    }
    return port;
  }

With version 2.8.1

With version 2.8.2

hedgecrw commented 2 years ago

Thanks so much for the detailed bug report!

Please test the following library version and see if it resolves your issue:

https://www.dropbox.com/t/s6TAYAXp5FiXVIGB

neeme-praks-sympower commented 2 years ago

Thanks, the 2.8.3-beta1 version that you provided on Dropbox worked like a charm! When can I expect the 2.8.3 final release? :-)

hedgecrw commented 2 years ago

Just released. Thanks!