StrawberryBlue commented on issue #1212: URL: https://github.com/apache/plc4x/issues/1212#issuecomment-1955501803
I am using a serial device on Windows, `public static String MODBUS_RTU_CONNECT_OPTION = "modbus-rtu:serial://COM30?request-timeout=5000&unit-identifier=1&serial.baud-rate=9600&serial.num-data-bits=8&serial.num-stop-bits=1&serial.parity=NO_PARITY"; public static String MODBUS_TCP_CONNECT_OPTION = "modbus-tcp:tcp://127.0.0.1:502"; @Test public void modbusRtuRead(){ try (PlcConnection connection = PlcDriverManager.getDefault().getConnectionManager().getConnection(MODBUS_RTU_CONNECT_OPTION)) { // Check if this connection support reading of data. if (!connection.getMetadata().isReadSupported()) { log.error("This connection doesn't support reading."); return; } PlcReadRequest.Builder builder = connection.readRequestBuilder(); builder.addTagAddress("value-1", "400001:UINT[10]"); PlcReadRequest readRequest = builder.build(); PlcReadResponse response = readRequest.execute().get(5000, TimeUnit.MILLISECONDS); for (String tagName : response.getTagNames()) { if(response.getResponseCode(tagName) == PlcResponseCode.OK) { int numValues = response.getNumberOfValues(tagName); // If it's just one element, output just one single line. if(numValues == 1) { log.info("Value[" + tagName + "]: " + response.getObject(tagName)); } // If it's more than one element, output each in a single row. else { log.info("Value[" + tagName + "]:"); for(int i = 0; i < numValues; i++) { log.info(" - " + response.getObject(tagName, i)); } } } // Something went wrong, to output an error message instead. else { log.error("Error[" + tagName + "]: " + response.getResponseCode(tagName).name()); } } }catch (Exception e){ e.printStackTrace(); log.error("connect fail"); } }` Like the code , when attempting to establish a connection, the program throws an exception. `2024-02-21T08:16:30.878+08:00 INFO 3276 --- [ main] o.a.plc4x.java.DefaultPlcDriverManager : Instantiating new PLC Driver Manager with class loader jdk.internal.loader.ClassLoaders$AppClassLoader@2b193f2d 2024-02-21T08:16:30.879+08:00 INFO 3276 --- [ main] o.a.plc4x.java.DefaultPlcDriverManager : Registering available drivers... 2024-02-21T08:16:30.884+08:00 INFO 3276 --- [ main] o.a.plc4x.java.DefaultPlcDriverManager : Registering driver for Protocol modbus-ascii (Modbus ASCII) 2024-02-21T08:16:30.885+08:00 INFO 3276 --- [ main] o.a.plc4x.java.DefaultPlcDriverManager : Registering driver for Protocol modbus-rtu (Modbus RTU) 2024-02-21T08:16:30.886+08:00 INFO 3276 --- [ main] o.a.plc4x.java.DefaultPlcDriverManager : Registering driver for Protocol modbus-tcp (Modbus TCP) 2024-02-21T08:16:30.889+08:00 INFO 3276 --- [ main] o.a.plc4x.java.DefaultPlcDriverManager : Registering driver for Protocol s7 (Siemens S7 (Basic)) org.apache.plc4x.java.api.exceptions.PlcConnectionException: Unsupported transport serial` -- 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: issues-unsubscr...@plc4x.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org