MangoAutomation / modbus4j

A high-performance and ease-of-use implementation of the Modbus protocol written in Java. Supports ASCII, RTU, TCP, and UDP transports as slave or master, automatic request partitioning and response data type parsing.
GNU General Public License v3.0
892 stars 369 forks source link

NPE for trying to read data from slave ID 0 #31

Open Puckfist opened 5 years ago

Puckfist commented 5 years ago

The stack trace looks like this:

ERROR 2019-09-13T15:49:31,219 (com.serotonin.m2m2.util.timeout.TimeoutTask.run:61) - Uncaught Task Exception 
java.lang.NullPointerException: null
    at com.serotonin.modbus4j.ModbusMaster.sendFunctionGroup(ModbusMaster.java:512) ~[?:?]
    at com.serotonin.modbus4j.ModbusMaster.send(ModbusMaster.java:430) ~[?:?]
    at com.serotonin.m2m2.modbus.rt.ModbusDataSourceRT.doPoll(ModbusDataSourceRT.java:187) ~[?:?]
    at com.serotonin.m2m2.rt.dataSource.PollingDataSource.doPollNoSync(PollingDataSource.java:228) ~[mango-3.6.4.jar:?]
    at com.serotonin.m2m2.rt.dataSource.PollingDataSource.scheduleTimeoutImpl(PollingDataSource.java:183) ~[mango-3.6.4.jar:?]
    at com.serotonin.m2m2.rt.dataSource.PollingDataSource$1.scheduleTimeout(PollingDataSource.java:85) ~[mango-3.6.4.jar:?]
    at com.serotonin.m2m2.util.timeout.TimeoutTask.run(TimeoutTask.java:59) ~[mango-3.6.4.jar:?]
    at com.serotonin.timer.Task.runTask(Task.java:179) ~[mango-3.6.4.jar:?]
    at com.serotonin.timer.TaskWrapper.run(TaskWrapper.java:23) ~[mango-3.6.4.jar:?]
    at com.serotonin.timer.OrderedThreadPoolExecutor$OrderedTaskCollection.run(OrderedThreadPoolExecutor.java:336) ~[mango-3.6.4.jar:?]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[?:1.8.0_172]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[?:1.8.0_172]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_172]

It's possible this is more a validation bug in Mango due to allowing something to be a modbus IP point with slave ID 0 but not restricting its write type to write only.

SummerMineJack commented 1 month ago

Sorry to bother you. Have you solved this problem? I have the same problem. Send a broadcast notification with address 0 to write data.