steveohara / j2mod

Enhanced Modbus library implemented in the Java programming language
Apache License 2.0
276 stars 110 forks source link

com.ghgande.j2mod.modbus.ModbusIOException:I/O exception - failed to read response for request - Cannot read from serial port #94

Closed haoran8899 closed 5 years ago

haoran8899 commented 5 years ago

j2mod:2.5.3 jSerialComm:2.4.0 test code: SerialParameters sp = new SerialParameters(); sp.setPortName("/dev/ttyUSB0"); sp.setBaudRate(38400); sp.setDatabits(8); sp.setParity(AbstractSerialConnection.NO_PARITY); sp.setStopbits(AbstractSerialConnection.ONE_STOP_BIT); sp.setEncoding(Modbus.SERIAL_ENCODING_RTU); sp.setEcho(false); ModbusSerialMaster master = new ModbusSerialMaster(sp); try { master.connect(); } catch (Exception e) { e.printStackTrace(); } try { master.readInputDiscretes(1,1,1); } catch (ModbusException e) { e.printStackTrace(); }

error: com.ghgande.j2mod.modbus.ModbusIOException:I/O exception - failed to read response for request - Cannot read from serial port

leganas commented 5 years ago

decision - https://github.com/steveohara/j2mod/pull/95