Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.

Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website

Using "Contiguous batches only" causes exceptions


  • When I enable "Contiguous batches only" on my modbus ip datasource, mango produces the following exceptions in the mango tomcat log everytime mango attempts to poll:

    ERROR 2010-09-22 10:48:49,907 (org.quartz.core.JobRunShell.run:211) - Job com.serotonin.mango.rt.dataSource.PollingDataSource.PollingDataSource-8 threw an unhandled Exception:
    com.serotonin.ShouldNeverHappenException: com.serotonin.modbus4j.exception.ModbusTransportException: Invalid number of registers: 314
    at com.serotonin.mango.rt.dataSource.modbus.ModbusDataSource.doPoll(ModbusDataSource.java:252)
    at com.serotonin.mango.rt.dataSource.PollingDataSource.scheduleTimeout(PollingDataSource.java:79)
    at com.serotonin.mango.util.TimeoutJob.execute(TimeoutJob.java:46)
    at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
    at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:525)
    Caused by: com.serotonin.modbus4j.exception.ModbusTransportException: Invalid number of registers: 314
    at com.serotonin.modbus4j.base.ModbusUtils.validateNumberOfRegisters(ModbusUtils.java:77)
    at com.serotonin.modbus4j.msg.ReadNumericRequest.<init>(ReadNumericRequest.java:17)
    at com.serotonin.modbus4j.msg.ReadInputRegistersRequest.<init>(ReadInputRegistersRequest.java:10)
    at com.serotonin.modbus4j.ModbusMaster.sendFunctionGroup(ModbusMaster.java:329)
    at com.serotonin.modbus4j.ModbusMaster.send(ModbusMaster.java:280)
    at com.serotonin.mango.rt.dataSource.modbus.ModbusDataSource.doPoll(ModbusDataSource.java:176)
    ... 4 more
    ERROR 2010-09-22 10:48:49,907 (org.quartz.core.ErrorLogger.schedulerError:2185) - Job (com.serotonin.mango.rt.dataSource.PollingDataSource.PollingDataSource-8 threw an exception.
    org.quartz.SchedulerException: Job threw an unhandled exception. [See nested exception: com.serotonin.ShouldNeverHappenException: com.serotonin.modbus4j.exception.ModbusTransportException: Invalid number of registers: 314]
    at org.quartz.core.JobRunShell.run(JobRunShell.java:213)
    at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:525)
    Caused by: com.serotonin.ShouldNeverHappenException: com.serotonin.modbus4j.exception.ModbusTransportException: Invalid number of registers: 314
    at com.serotonin.mango.rt.dataSource.modbus.ModbusDataSource.doPoll(ModbusDataSource.java:252)
    at com.serotonin.mango.rt.dataSource.PollingDataSource.scheduleTimeout(PollingDataSource.java:79)
    at com.serotonin.mango.util.TimeoutJob.execute(TimeoutJob.java:46)
    at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
    ... 1 more
    Caused by: com.serotonin.modbus4j.exception.ModbusTransportException: Invalid number of registers: 314
    at com.serotonin.modbus4j.base.ModbusUtils.validateNumberOfRegisters(ModbusUtils.java:77)
    at com.serotonin.modbus4j.msg.ReadNumericRequest.<init>(ReadNumericRequest.java:17)
    at com.serotonin.modbus4j.msg.ReadInputRegistersRequest.<init>(ReadInputRegistersRequest.java:10)
    at com.serotonin.modbus4j.ModbusMaster.sendFunctionGroup(ModbusMaster.java:329)
    at com.serotonin.modbus4j.ModbusMaster.send(ModbusMaster.java:280)
    at com.serotonin.mango.rt.dataSource.modbus.ModbusDataSource.doPoll(ModbusDataSource.java:176)
    ... 4 more


  • Can you describe the points you have on this data source?


  • When I observe this in the eclipse debugger, I see ReadFunctionGroups with lengths of 314 and 803. These lengths are greater than ModbusUtils.MAX_READ_REGISTER_COUNT (i.e, 125). The exception is thrown when the ReadNumericRequest constructor discovers this.

    I have over 900 modbus data points in various ranges. I will attempt to upload the json for these.

    Attachment: download link


  • The logic for partitioning the contiguous requests doesn't account for max request sizes. This has been fixed, and will be deployed in the next release.


  • Thanks!


  • Hello,

    I have telemechanique twido with modbus tcp. I noticed earlier Twido was not working with "contiguous batches only" unchecked. I did not have time to investigate what was the reason. Now i noticed this topic and installed mango 1.11. Still it does not work.

    Analysed with wireshark and it seems to fail on always same point where Mango requests read at register 327 and number of registers to read is 124. There should be hundreds of readable registers beyond 327.

    Thanks for the Modbus Read data tester in the datasource page. I tried reading register 0 with different numbers of registers. Seems it works upto 123 registers and then above twido gets nuts. The response is full of zeroes. I did some research and there are also other devices not supporting the modbus spec 125 register count. Some devices are supporting reading max 16 or 32 registers at time.

    The optimised reading is really good feature. It speeds up the reading a lot. (from ~3.5 seconds down to ~0.8 sec). Is there a way to limit the maximum amount of registers mango is trying to read? Would it be possible to add such feature in some future version?

    (making "holes" in the register map, to affect mango optimisation seems to work, but it is causing other troubles)

    Thanks
    -Jokke


  • Hello.
    I'm using version 1.10 of Mango and I need to reduce maximum number of contigous variables request. How can I do it? My Modbus slave accepts request for at maximum 32 words.
    Is there a "secret" parameter to set up?

    Thankyou in advance
    Regards


  • Hello,

    I checked the sources and for me it looks the register limit of 125 is defined in the code. I am not sure it could be over written somehow but maybe mlohbihler can tell this.

    (edit)
    You can use the "holes in registermap" to work around this. If every 33th (adresses 32, 65, 97...) register is not configured to be read then the query is limited to 32 registers.

    I have not tried, but maybe an other workaround could be to configure 2 datasources. One handling registers 0 to 31 and from 64 to 95 and so on... then the second datasource hanling 32 to 63 and 96 to 127 and so on... Idea is to split the register to chunks of 32 and divide between 2 datasources.

    (/edit)
    BR
    -Jokke


  • Hello Jokke and thakyou for your help.
    Unfortunately I can't setup multiple datasources because, after I setup the first one, in the second one I can't choose (for obvious reasons) the same serial interface..
    I tried with "holes in registermap" solution, but I can't use this because my device datamap is filled from holding register 130 to 192 without holes and there are all wanted values there.

    I the meanwhile I downloaded Modbus4J source code and I have found the piece of code to change in order to reduce maximum number of registers asked on one read. Unfortunately after I compile the code and insert it on Mango WEB-INF/lib folder, Mango doesn't start.. It doesn't find a ModbusMaster class. Surely Mango is built using a "modded" version of this library..

    Is there a way to get this customized version, modify the constants on top of ModbusUtils.java file and use it on my application? (question to Serotonine technicians)

    Thankyou again


  • Are you sure that modbus4j compiled successfully? Does the ModbusMaster.class file class exist!


  • It is certainly the case that Modbus4J has evolved along with Mango. Off hand i couldn't tell you whether the current Modbu4J code corresponds with your version of Mango, but as Craig noted ModbusMaster has been in there since the beginning, so maybe it can't be found because of a referenced class, a failing static initializer, or bad compilation.

    Anyway, regarding max request sizes, how complicated can this get exactly? The spec provides different max size for input ranges (2000), and register ranges (125). So, i assume a device that supports something else could also have two different sizes. There is also a max write count (120), which presumably could also be different.

    Also, would this be something that should be set at the master level, or per device?


  • The difference between specs and real devices is abysmal a lot of times!
    In fact the device I'm polling is not the first one I've found that behaves like this.. :?

    Surely, depending on every different device firmware, these params should be at device level but, looking at Mango datasource structure, probably it is too difficult to implement it at that level.. If you need help on modbus protocol, please contact me. We are fieldbus experts and we have a lot of experience on modbus protocol.

    In order to solve my current problem, can you send me a modbusutils.class with MAX_REGISTER set at 16 words?

    Thankyou very much


  • Because Modbus4J is continuously evolving, i recommend against using a separate branch of the project. Stay tuned as we may end up dealing more permanently with this issue.


  • Update: the setting of max batch sizes has been added to Modbus4J and Mango.