• Recent
    • Tags
    • Popular
    • Register
    • Login
    1. Home
    2. ramonhl
    3. Topics

    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
    • Profile
    • Following 0
    • Followers 0
    • Topics 6
    • Posts 16
    • Best 0
    • Controversial 1
    • Groups 0

    Topics created by ramonhl

    • ramonhlR

      Master and sockets control

      Modbus4J general discussion
      • • • ramonhl
      3
      0
      Votes
      3
      Posts
      2.4k
      Views

      ramonhlR

      The problem is solved.
      When we create the master we can see a paramer keepalive in the constructor.

      ModbusMaster master = modbusFactory.createTcpMaster(ipParameters, keepalive);

      I was keepalive=false. If keepalive = false then every time that the client (master) read of the server (slave) the socket is open------close.

      If keepalive = true then the master close the socket at the end of all the readings. But I do not know how the keepalive works exactly, is it parametrizable...

      Do you know How the keepalive works exactly? And Where Can I find Modbus4j documentation?

      Best regards.

    • ramonhlR

      Modbus4J 2.0.2. Problems with the listener and the threads.

      Modbus4J general discussion
      • • • ramonhl
      2
      0
      Votes
      2
      Posts
      2.4k
      Views

      ramonhlR

      Hello.
      I am testing the ListeterTest2.java and works fine.

      public class ListenerTest2Mon1 { static Random random = new Random(); static float ir1Value = -100; public static void main(String[] args) throws Exception { ModbusFactory modbusFactory = new ModbusFactory(); final ModbusSlaveSet listener = modbusFactory.createTcpSlave(false); listener.addProcessImage(getModscanProcessImage(127)); // When the "listener" is started it will use the current thread to run. So, if an exception is not thrown // (and we hope it won't be), the method call will not return. Therefore, we start the listener in a separate // thread so that we can use this thread to modify the values. new Thread(new Runnable() { public void run() { try { listener.start(); } catch (ModbusInitException e) { e.printStackTrace(); } } }).start(); while (true) { updateProcessImage1((BasicProcessImage) listener.getProcessImage(127)); synchronized (listener) { listener.wait(100); } } } static void updateProcessImage1(BasicProcessImage processImage) { processImage.setNumeric(RegisterRange.HOLDING_REGISTER, 0, DataType.TWO_BYTE_INT_UNSIGNED, random.nextInt(10000)); processImage.setNumeric(RegisterRange.HOLDING_REGISTER, 2, DataType.FOUR_BYTE_INT_UNSIGNED_SWAPPED, random.nextInt(10000)); processImage.setNumeric(RegisterRange.HOLDING_REGISTER, 10, DataType.TWO_BYTE_INT_UNSIGNED, random.nextInt(10000)); processImage.setNumeric(RegisterRange.HOLDING_REGISTER, 12, DataType.FOUR_BYTE_INT_UNSIGNED_SWAPPED, random.nextInt(10000)); processImage.setNumeric(RegisterRange.HOLDING_REGISTER, 20, DataType.TWO_BYTE_INT_UNSIGNED, random.nextInt(10000)); processImage.setNumeric(RegisterRange.HOLDING_REGISTER, 22, DataType.FOUR_BYTE_INT_UNSIGNED_SWAPPED, random.nextInt(10000)); } static BasicProcessImage getModscanProcessImage(int slaveId) { BasicProcessImage processImage = new BasicProcessImage(slaveId); processImage.setAllowInvalidAddress(true); processImage.setInvalidAddressValue(Short.MIN_VALUE); processImage.setExceptionStatus((byte) 151); return processImage; } }

      But when I try to insert this code in my java program I have problems with the threads.
      I do:

      Change the code of the listener test and create a new class. In java I have a jframe with two buttons, start server, stop server. In the jframe I create a new instance of my listener class. In the start button I start using my class the listener.start(). The start button freezes, if I debug in the listener.start() the code stops.

      Do you have some example with listener in jframe or similar?

      Thanks in advance.

      Best regards.

    • ramonhlR

      Modbus4J 2.0.2 and Maven, How it works?

      Modbus4J general discussion
      • • • ramonhl
      3
      0
      Votes
      3
      Posts
      3.6k
      Views

      ramonhlR

      Problem solved.
      In the pom.xml file I can see the libraries that we need.
      I can find these libraries in ~/.m2/repository and in modbus4j-maven-local.
      I added these libraries *.jar, in my project and all works fine.

    • ramonhlR

      Modbus4J. ListenerTest (TCP). java.net.BindException

      Modbus4J general discussion
      • • • ramonhl
      4
      0
      Votes
      4
      Posts
      3.8k
      Views

      ramonhlR

      Thanks for the information.
      If I execute Eclipse using the sudo command (administrator) I can run the ListenerTest.

      See you

    • ramonhlR

      Modbus4j the best way for do a polling

      Modbus4J general discussion
      • • • ramonhl
      3
      0
      Votes
      3
      Posts
      2.5k
      Views

      M

      Modbus4J does not have any internal polling mechanisms, no. In Android it would probably be best to create a service that does the polling at the desired rate. If polling, as you say, once per second you should, of course, not be initializing and destroying each time.

    • ramonhlR

      Modbus4j and Android application

      Modbus4J general discussion
      • • • ramonhl
      4
      0
      Votes
      4
      Posts
      3.5k
      Views

      ramonhlR

      Hello.
      Thanks for the information.
      I have created and asynctask and I use the master.ini() in this new thread. Works fine.

      Best regards.