• 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 on Android

    Modbus4J general discussion
    2
    7
    5.0k
    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.
    • B
      BigCat
      last edited by

      I'm writing a modbus polling app on android, mostly as an excercise in getting my feet wet in android programing.

      I started initially with jamodbus, but I see a few advantages for what I'm doing in modbus4j, but with jamodbus I had to strip out all the serial port references.

      Is that something that would be possible with parts of modbus4j being closed source? Or would that break everything so badly it isn't even funny?

      Thanks!

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

        No idea. Both Modbus4J and the "closed" part (i.e. SeroUtils) are build to Java 1.5 compliance. I believe this is ok with Android, but i haven't tried these libraries myself. Best to just give it a go, and report back here on how it went.

        Best regards,
        Matthew

        1 Reply Last reply Reply Quote 0
        • B
          BigCat
          last edited by

          I'll give it a go, but because Android has its own virtual machine, it doesn't support all the stock java components.

          For jamodbus I had to strip out anything that referenced a serial library.

          I should be able to tackle it this weekend, and I'll see if I can do a modbus4a or something and post it back to the forum.

          On a related note, I thought I read somewhere there are enhancements for polling? Or am I confusing that with the batching (which is pretty cool even if it isn't super applicable for my current plan).

          If there are some enhancements for polling, where might I find some info on that.

          1 Reply Last reply Reply Quote 0
          • B
            BigCat
            last edited by

            So I took out all the RTU and serial parts classes, commented out the masters and slaves in the factory class, and imported the seroUtils into eclipse and it pretty much stopped giving me errors.

            What I'm trying to figure out now is if there is an 'is connected' type of method for any of the masters.

            What I did with jamodbus was span a polling thread that looped as long as the connection wasn't closed for some reason (or until it was interrupted by the UI thread). It was pretty simple cuz they had an isConnected method. But I'm not seeing something analogous in modbus4j.

            Am I blind, or is there a simple way to monitor the connection status?

            Thanks!
            Ben

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

              On a related note, I thought I read somewhere there are enhancements for polling? Or am I confusing that with the batching (which is pretty cool even if it isn't super applicable for my current plan).

              You're probably thinking about batching.

              Am I blind, or is there a simple way to monitor the connection status?

              The problem with "isConnected" is that it's meaning changes, and is meaningless in certain conditions. Just because you're connected to a serial port (i know, you're not using serial) doesn't mean that there's anything listening on the other side. With UDP you're metaphorically sitting in dark room shouting requests and hoping for responses; how are you connected? Even TCP with keep-alive is at best like a serial connection.

              Maybe it's splitting hairs. But, in fact, there is an "isInitialized" method that will tell you whether you got the serial port or the TCP keep-alive, even though you would have received an exception otherwise. Does that help?

              Best regards,
              Matthew

              1 Reply Last reply Reply Quote 0
              • B
                BigCat
                last edited by

                Yeah, I think that will work. And then for my 'disconnect' button I'll just call the destroy, and re-instance the TCPmaster w/ a new init() if the user tries to re-connect.

                Thanks!

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