Closed Kosmachevskiy closed 7 years ago
It shouldn't be throwing an NPE but I suspect it's because it cannot create a JSerialComm wrapper around "/dev/ttyUSB1"
Does SerialPort.getCommPort("/dev/ttyUSB1")
return anything?
I ran into the same(or similar) problem recently, and finally found the cause is current user didn't have the permission to access the serial port (not in dialout
group).
By the way, would you mind add some checks when opening the serial port? Making it fails early at opening the serial port instead of fails at first operation could reduce the difficulty of debugging such problems.
Problem really with permissions. Thanks.
I've created https://github.com/steveohara/j2mod/issues/45 so that I don't forget about it
Library version: 2.3.1
Hi!
I have some trouble with ModbusSerialMaster. I got a NPE during reading registers.
My code:
`
` And stack:
Exception in thread "main" java.lang.NullPointerException at com.ghgande.j2mod.modbus.net.SerialConnection.setComPortTimeouts(SerialConnection.java:221) at com.ghgande.j2mod.modbus.io.ModbusSerialTransport.setTimeout(ModbusSerialTransport.java:142) at com.ghgande.j2mod.modbus.io.ModbusSerialTransport.open(ModbusSerialTransport.java:131) at com.ghgande.j2mod.modbus.io.ModbusSerialTransport.writeMessage(ModbusSerialTransport.java:73) at com.ghgande.j2mod.modbus.io.ModbusSerialTransaction.execute(ModbusSerialTransaction.java:143) at com.ghgande.j2mod.modbus.facade.AbstractModbusMaster.readMultipleRegisters(AbstractModbusMaster.java:236)