• Recent
    • Tags
    • Popular
    • Register
    • Login

    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 Mango 5 Documentation Website

    Modbus4J changes in Mango 1.8.2

    Modbus4J general discussion
    2
    8
    6.6k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      Andras
      last edited by

      Hi,

      I upgraded from 1.8.0 to Mango 1.8.2. I'm since getting frequent exception messages from Modbus4J that I didn't get in 1.8.0, like this:

      WARN 2010-04-07 10:23:07,562 (com.serotonin.mango.rt.dataSource.modbus.ModbusDataSource.receivedException:226) - Modbus exception
      com.serotonin.modbus4j.exception.IllegalFunctionException
      at com.serotonin.modbus4j.msg.ModbusResponse.createModbusResponse(ModbusResponse.java:50)
      at com.serotonin.modbus4j.serial.rtu.RtuMessageResponse.createRtuMessageResponse(RtuMessageResponse.java:16)
      at com.serotonin.modbus4j.serial.rtu.RtuMessageParser.parseMessageImpl(RtuMessageParser.java:21)
      at com.serotonin.modbus4j.base.BaseMessageParser.parseMessage(BaseMessageParser.java:17)
      at com.serotonin.messaging.MessageControl.data(MessageControl.java:129)
      at com.serotonin.messaging.InputStreamListener.run(InputStreamListener.java:76)
      at java.lang.Thread.run(Thread.java:619)

      As an illegal function exception is reported, I'm guessing that the Modbus4J is using a modbus function that wasn't used before. Despite these error reports, my data is still comming in OK in Mango by the way.

      I'm polling holding registers with Mango. The modbus device supports the modbus function 3 (read block), 6 (write single reg), 16 (write block). I know that Modbus4J reads with function 3 and writes with function 6 in the Modbus4J version that shipped with Mango 1.8.0. Did this mechanism perhaps change in the latest version ?

      1 Reply Last reply Reply Quote 0
      • M
        mlohbihler
        last edited by

        Hi Andras,

        That message is being thrown by the incoming message processing. Data is coming back from the modbus device, and Modbus4J is trying to parse it into a response message, but the function code is not recognized. I've enhanced the exception to report the function code that was sent. To implement, replace the Modbus4J jar file with the attached.

        The Modbus4J package did recently undergo some changes as a result of an overhaul of the messaging system within seroUtils. But these changes were only to make it compliant to the new base, not to change any functionality. In any case, a change is a change, and so could be responsible for what you are seeing.

        Can you please implement the attached and post the function code that you are getting. We can use this as a starting point in diagnosing the problem.

        Attachment: download link

        Best regards,
        Matthew

        1 Reply Last reply Reply Quote 0
        • M
          mlohbihler
          last edited by

          Hi Andras,

          If it is possible to also get a dump of the serial line communication, that would be helpful.

          Best regards,
          Matthew

          1 Reply Last reply Reply Quote 0
          • A
            Andras
            last edited by

            Hi Matthew,

            I replaced the Modbus4J.jar and set my modbus source to poll holding register 6 and 8 every 5 seconds (serial settings: 9600 8N1). I noticed that most of the time there is no error reported. About 1 out of 10 times I get an error message like this:

            WARN 2010-04-09 10:09:05,029 (com.serotonin.mango.rt.dataSource.modbus.ModbusDa
            taSource.receivedException:226) - Modbus exception
            com.serotonin.modbus4j.exception.IllegalFunctionException: Function code: 0x28
            at com.serotonin.modbus4j.msg.ModbusResponse.createModbusResponse(Modbus
            Response.java:50)
            at com.serotonin.modbus4j.serial.rtu.RtuMessageResponse.createRtuMessage
            Response(RtuMessageResponse.java:16)
            at com.serotonin.modbus4j.serial.rtu.RtuMessageParser.parseMessageImpl(R
            tuMessageParser.java:21)
            at com.serotonin.modbus4j.base.BaseMessageParser.parseMessage(BaseMessag
            eParser.java:17)
            at com.serotonin.messaging.MessageControl.data(MessageControl.java:129)
            at com.serotonin.messaging.InputStreamListener.run(InputStreamListener.j
            ava:76)
            at java.lang.Thread.run(Thread.java:619)
            tried to access field gnu.io.RXTXPort.IOLocked from class gnu.io.RXTXHack

            The function code 0x28 reported above isn't always the same; it changes now and then. If we look at the serial trace it becomes clear why:

            Request: 9-4-2010 10:09:04.25764 (+4.9375 seconds)
            01 03 00 06 00 03 E5 CA ......åÊ
            Answer: 9-4-2010 10:09:04.28864 (+0.0313 seconds)
            01 03 06 00 00 00 00 00 D2 A1 28 ........Ò¡(

            It looks like the 0x28 is the last byte of the CRC. Normally I see only 1 request and 1 reply in the trace every 5 secs, but when this error occurs Modbus4J retries and we see a second try shortly after the one that didn't succeed:

            Request: 9-4-2010 10:09:05.77264 (+0.4375 seconds)
            01 03 00 06 00 03 E5 CA ......åÊ
            Answer: 9-4-2010 10:09:05.80464 (+0.0313 seconds)
            01 03 06 00 00 00 00 00 D2 A1 28 ........Ò¡(

            I suppose that's why I still get the data in Mango despite the errors.

            Note that the request-reply that preceded the one with timestamp 10:09:04.25764 looks like this:

            Request: 9-4-2010 10:08:59.25764 (+4.9688 seconds)
            01 03 00 06 00 03 E5 CA ......åÊ
            Answer: 9-4-2010 10:08:59.31964 (+0.0625 seconds)
            01 03 06 00 01 00 00 00 D2 9C E8 ........Ò?è

            So the 0x28 didn't appear in the answer message prior to the one that didn't succeed.

            1 Reply Last reply Reply Quote 0
            • M
              mlohbihler
              last edited by

              Hi Andras,

              The new code wasn't marking the buffer in case of incomplete messages. Can you please replace the existing seroUtils with the attached and let me know if it helps.

              Attachment: download link

              Best regards,
              Matthew

              1 Reply Last reply Reply Quote 0
              • A
                Andras
                last edited by

                Yes, that did the trick. I no longer get the error messages :) Thanks !

                1 Reply Last reply Reply Quote 0
                • M
                  mlohbihler
                  last edited by

                  No problem. Thanks for getting back.

                  Best regards,
                  Matthew

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post