dasoops opened a new issue, #1724:
URL: https://github.com/apache/plc4x/issues/1724

   ### What happened?
   
   Execute this code
   
   ```java
   public class ModbusRtuPingTest {
       @Test
       void testPing() throws Exception {
           var connection = 
PlcDriverManager.getDefault().getConnectionManager().getConnection("modbus-rtu:tcp://localhost:502");
           Assertions.assertDoesNotThrow(() -> connection.ping().join());
       }
   }
   ```
   
   Then 
   
   ```log
   org.opentest4j.AssertionFailedError: Unexpected exception thrown: 
java.lang.NullPointerException: Cannot invoke "Object.getClass()" because "tag" 
is null
   
        at 
org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:152)
        at 
org.junit.jupiter.api.AssertDoesNotThrow.createAssertionFailedError(AssertDoesNotThrow.java:84)
        at 
org.junit.jupiter.api.AssertDoesNotThrow.assertDoesNotThrow(AssertDoesNotThrow.java:75)
        at 
org.junit.jupiter.api.AssertDoesNotThrow.assertDoesNotThrow(AssertDoesNotThrow.java:58)
        at 
org.junit.jupiter.api.Assertions.assertDoesNotThrow(Assertions.java:3228)
        at 
org.apache.plc4x.java.modbus.rtu.ModbusRtuPingTest.testPing(ModbusRtuPingTest.java:30)
        at java.base/java.lang.reflect.Method.invoke(Method.java:580)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1597)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1597)
   Caused by: java.lang.NullPointerException: Cannot invoke "Object.getClass()" 
because "tag" is null
        at 
org.apache.plc4x.java.modbus.base.protocol.ModbusProtocolLogic.getReadRequestPdu(ModbusProtocolLogic.java:149)
        at 
org.apache.plc4x.java.modbus.rtu.protocol.ModbusRtuProtocolLogic.ping(ModbusRtuProtocolLogic.java:68)
        at 
org.apache.plc4x.java.spi.connection.AbstractPlcConnection.ping(AbstractPlcConnection.java:183)
        at 
org.apache.plc4x.java.spi.messages.DefaultPlcPingRequest.execute(DefaultPlcPingRequest.java:40)
        at 
org.apache.plc4x.java.spi.connection.DefaultNettyPlcConnection.ping(DefaultNettyPlcConnection.java:205)
        at 
org.apache.plc4x.java.modbus.rtu.ModbusRtuPingTest.lambda$0(ModbusRtuPingTest.java:30)
        at 
org.junit.jupiter.api.AssertDoesNotThrow.assertDoesNotThrow(AssertDoesNotThrow.java:71)
        ... 6 more
   ```
   
   The `pingAddress` attribute of `ModbusRtuProtocolLogic` seems to have never 
been assigned, which is different from `ModbusTcpProtocolLogic`. 
   
   
https://github.com/apache/plc4x/blob/b1864375daa1b295b918d8de46fe929ccdb28255/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/rtu/protocol/ModbusRtuProtocolLogic.java#L48-L54
   
   Furthermore, its `ModbusRtuProtocolLogic.ping()` and 
`ModbusRtuDriver.canPing()` are both overridden, so I think this is unexpected. 
   
   
https://github.com/apache/plc4x/blob/b1864375daa1b295b918d8de46fe929ccdb28255/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/rtu/protocol/ModbusRtuProtocolLogic.java#L61-L63
   
   
https://github.com/apache/plc4x/blob/b1864375daa1b295b918d8de46fe929ccdb28255/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/rtu/ModbusRtuDriver.java#L100-L103
   
   Additionally, `ModbusAsciiProtocolLogic` also seems to have this issue.
   
   ### Version
   
   v0.12.0, v0.13.0-SNAPSHOT
   
   ### Programming Languages
   
   - [X] plc4j
   - [ ] plc4go
   - [ ] plc4c
   - [ ] plc4net
   
   ### Protocols
   
   - [ ] AB-Ethernet
   - [ ] ADS /AMS
   - [ ] BACnet/IP
   - [ ] CANopen
   - [ ] DeltaV
   - [ ] DF1
   - [ ] EtherNet/IP
   - [ ] Firmata
   - [ ] KNXnet/IP
   - [X] Modbus
   - [ ] OPC-UA
   - [ ] S7


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to