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.

  • This topic is deleted!

    1
    0 Votes
    1 Posts
    7 Views
    No one has replied
  • IllegalFunctionException: Function code: 0x3f

    3
    0 Votes
    3 Posts
    2k Views
    JoelHaggarJ
    This means Mango got a response but the function code in the response is not valid. This can happen if your RS-485 wiring is not good and there is noise on the line so some of the messages get corrupted. Playing around with the settings Phillip suggest is also a good idea. It's generally expected that you will occasionally get corrupted messages over RS-485 so if this happens ever once and awhile I wouldn't worry about it as long as you are still getting data reliably.
  • upgrade from 1.x to 2.x

    1
    0 Votes
    1 Posts
    1k Views
    No one has replied
  • How does Modbus4J compare with Jamod library?

    1
    0 Votes
    1 Posts
    2k Views
    No one has replied
  • Modbus4J - Getting started

    2
    0 Votes
    2 Posts
    3k Views
    jeremyhJ
    Hi Adaf/Asaf There are some snippets from another user in this thread that might help: http://infiniteautomation.com/forum/topic/1969/modbus4j-modbus-rtu-master/8
  • Modbus4J Modbus RTU master

    24
    0 Votes
    24 Posts
    30k Views
    jeremyhJ
    No. You would need to do: (1/samples per hour) * (sum of kilowatts over period) = kilowatt-hours i.e. (can't believe you made me type this): (1/60) * (4.872+4.873+4.808+4.896+4.744+4.768+4.896+4.832+4.816+4.776+4.888+4.872+4.760+4.840+4.792) = 1.2kWh This is honestly a really bad and dumb way to do this though. It is very inaccurate and if you miss any measurements your energy will be even further off. Just add the kWh register (rather than MWh) from your panel meter and calculate the difference every period - that is what it's there for! If you ended up with 15-minute energy kWh then to get hourly energy you would just sum the kWh. Energy can be added to energy.
  • getting java.lang.UnsatisfiedLinkError when running as modbusmaster

    2
    0 Votes
    2 Posts
    3k Views
    hussamH
    you run on a linux system. please confirm the serial com name is "/dev/ttyM0"? right? and this should be a jssc environment problem,pleause comfirm if you lose some jar lib
  • Modbus RTU getValue() parameters

    15
    0 Votes
    15 Posts
    10k Views
    amer jamilA
    By the way odious, this is me writing a question in this forum. You can see what I've done so far, and maybe you can help me more. Thank you in advance for any kind of help and guidance. Click here to read and understand more about my problem. My Question
  • Modbus RTU in Android - error with master.init();

    1
    0 Votes
    1 Posts
    2k Views
    No one has replied
  • MODBUS RTU 1ms inter-byte delay ISSUE

    7
    0 Votes
    7 Posts
    8k Views
    terrypackerT
    xbastek, You say: But i don't know how to update this files in my mango installation... It will be far easier for you to upgrade to Mango 2.6.0 that has all the work done for you. It will be pre-released very soon. Thanks, Terry
  • New seroutils and JSSC problem

    7
    0 Votes
    7 Posts
    6k Views
    V
    Hi Terrypacker, I would like to introduce you to scm which is an alternative library to rxtx/javaxcom. Wiki : http://www.embeddedunveiled.com/ Repository : https://github.com/RishiGupta12/serial-communication-manager Video : https://www.youtube.com/watch?v=fYLQbelGunQ It supports RS-232 control signals handshaking, monitoring and has been ported to Linux, MAC, Solaris and Windows operating system. It is consistent, portable, efficient, reliable, testable, extensible, modifiable, scalable library.
  • Proper exception handling of ModbusMaster getValue object

    2
    0 Votes
    2 Posts
    2k Views
    S
    Hi guys, First, I'd like to say I've found the modbus4j libraries an awesome tool and thank you for allowing this to be open source. Also, I'm a bit new to Java programming so I admit my comprehension of error handling is not the best. Now that being said, I have an application where I would really like to get some guidance. The application is simple, main class creates a simple GUI with a Swing JFrame and extends two threads. First thread updates the GUI, second thread polls the modbus registers. Now everything works perfectly fine, but after the GUI runs a bit I begin getting a lot of these exceptions: com.serotonin.messaging.WaitingRoomException: No recipient was found waiting for response for key com.serotonin.modbus4j.ip.xa.XaWaitingRoomKey@8ea at com.serotonin.messaging.WaitingRoom.response(WaitingRoom.java:69) at com.serotonin.messaging.MessageControl.data(MessageControl.java:153) at com.serotonin.messaging.InputStreamListener.run(InputStreamListener.java:76) at java.lang.Thread.run(Thread.java:745) The ModbusMaster functions in the polling thread are the only methods that call the com.serotonin libraries, so it must be from that. The thread is very simple, when it is first called it creates the ModbusFactory, then the ModbusTCIPMaster, and then initializes the modbus locations for all the registers I'm polling. After that it enters a continuous loop with a sleep command to control the polling rate, see below: public void run() { System.out.println(threadName + " thread started"); this.t.setPriority(5); ModbusFactory m = new ModbusFactory(); IpParameters ip = new IpParameters(); ip.setHost(this.IPAdr); ip.setPort(502); ModbusMaster mp = m.createTcpMaster(ip, true); mp.setTimeout(5000); mp.setRetries(3); while (CommError) { try { mp.init(); CommError = false; } catch (Exception MIExc) { System.out.println("Init Error: " + MIExc.getMessage()); CommError = true; try { Thread.sleep(5000); } catch (InterruptedException e) { //Do nothing } } } try { ModbusLocator ProductionSignalLoc = new ModbusLocator(1, 2, ProductionSignalAddr, 1); while (true) { Thread.sleep(NetworkUpdateRate); try { ProductionSignal = ((Boolean) mp.getValue(ProductionSignalLoc)).booleanValue(); CommError = false; } catch (ModbusTransportException | ErrorResponseException MTExc) { System.out.println("Transport Error: " + MTExc.getMessage()); CommError = true; Thread.sleep(5000); } } } I cut a lot out to reduce the verbosity, but as far as I can tell ModbusMaster.getValue only throws "ModbusTransportException" and "ErrorResponseException", how am I missing the exception? Also, any help is always appreciated :) Thanks
  • Modbus4j Android implementation

    2
    0 Votes
    2 Posts
    4k Views
    J
    Hello. I'm trying to create a modbus master application just to read values (function 1 to 4) actually I'm just trying to read coils just for testing and learning this package. I created an Asynctask to make the connection with a single id 0 slave with 2 coils but I get fatal exception Caused by: java.lang.NoSuchMethodError: com.serotonin.messaging.MessageControl.setIoLog I will post here the error and part of my code, so maybe I can get some guidance about this implementation. I have set internet access for my app and also the asynctask to make the connection in the background. here's the error: 02-25 14:57:05.715 20957-21111/com.example.josempd.modbus4jtcpmaster E/AndroidRuntime? FATAL EXCEPTION: AsyncTask #4 Process: com.example.josempd.modbus4jtcpmaster, PID: 20957 java.lang.RuntimeException: An error occured while executing doInBackground() at android.os.AsyncTask$3.done(AsyncTask.java:300) at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355) at java.util.concurrent.FutureTask.setException(FutureTask.java:222) at java.util.concurrent.FutureTask.run(FutureTask.java:242) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) at java.lang.Thread.run(Thread.java:841) Caused by: java.lang.NoSuchMethodError: com.serotonin.messaging.MessageControl.setIoLog at com.serotonin.modbus4j.ModbusMaster.getMessageControl(ModbusMaster.java:307) at com.serotonin.modbus4j.ip.tcp.TcpMaster.openConnection(TcpMaster.java:194) at com.serotonin.modbus4j.ip.tcp.TcpMaster.sendImpl(TcpMaster.java:93) at com.serotonin.modbus4j.ModbusMaster.send(ModbusMaster.java:92) at com.example.josempd.modbus4jtcpmaster.MainActivity$ConnectTask.doInBackground(MainActivity.java:130) at com.example.josempd.modbus4jtcpmaster.MainActivity$ConnectTask.doInBackground(MainActivity.java:85) at android.os.AsyncTask$2.call(AsyncTask.java:288) at java.util.concurrent.FutureTask.run(FutureTask.java:237)             at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)             at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)             at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)             at java.lang.Thread.run(Thread.java:841) and my current asynctask block: @Override protected Void doInBackground(Void... arg0) { ModbusFactory factory = new ModbusFactory(); IpParameters params = new IpParameters(); params.setHost(IPMod); params.setPort(PortMod); params.setEncapsulated(false); ModbusMaster master = factory.createTcpMaster(params, false); master.setTimeout(500); master.setRetries(2); //Descripción de los parámetros Param = "Los parámetros son:" + "\n" + "IP:" + IPMod + "\n" + "Puerto:" + String.valueOf(PortMod) + "\n" + "ID del esclavo:" + String.valueOf(slaveId) + "\n" + "primera dirección:" + String.valueOf(RefMod) + "\n" + "Número de direcciones:" + String.valueOf(CountMod); try { master.init(); ReadCoilsRequest request = new ReadCoilsRequest(slaveId, RefMod, CountMod); ReadCoilsResponse response = (ReadCoilsResponse) master.send(request); Resp = response.getBooleanData().toString(); } catch (ModbusInitException e) { // TODO Auto-generated catch block e.printStackTrace(); Resp = "Error: " + e.toString(); }catch (ModbusTransportException e) { e.printStackTrace(); Resp = "Error: " + e.toString(); } finally { master.destroy(); } return null; } the imported libraries are the next: dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') compile 'com.android.support:appcompat-v7:21.0.3' compile files('C:/Users/Josempd/AndroidStudioProjects/Modbus4JTCPMaster/libs/modbus4j-2.0.2.jar') compile files('C:/Users/Josempd/AndroidStudioProjects/Modbus4JTCPMaster/libs/serotonin-utils-2.1.7.jar') compile files('C:/Users/Josempd/AndroidStudioProjects/Modbus4JTCPMaster/libs/serotonin-timer-2.0.6.jar') compile files('C:/Users/Josempd/AndroidStudioProjects/Modbus4JTCPMaster/libs/maven-ant-tasks-2.1.3.jar') compile files('C:/Users/Josempd/AndroidStudioProjects/Modbus4JTCPMaster/libs/ant-contrib-1.0b3.jar') } I don't know if I'm missing libraries or any package or if I'm doing a bad implementation of the imported classes. Thanks in advance to everyone.
  • Modbus 32 bit

    9
    0 Votes
    9 Posts
    5k Views
    jeremyhJ
    Great!
  • Resilience issues when using TCP with keep-alive transport method

    4
    0 Votes
    4 Posts
    3k Views
    A
    Thank you Terry! I will be following this on the bugtracker.
  • Modbus over RS232 for Android

    2
    0 Votes
    2 Posts
    4k Views
    D
    Hi, I have been working on a project where I need to connect a Android phone to ABB industrial drive. I'm developing an app which connects to the drive via FTDI module (usb to rs232) http://goo.gl/sjSzYO To get serial communication on an Android device I use usb-serial-for-android library from http://goo.gl/1QaQPn What I achieved so far: I have a terminal app http://goo.gl/Wf14Di where I've got communications established by tapping on click (btConnectClick). It detects FTDI chip and selects correct driver. When it all done it runs a listener (SerialInputOutputManager.Listener) and updates method updateReceivedData(data) on received data. To test it I tap on Send button where it sends in hex (converted to bytes[]) a request (string). String has an address x01, request to read Holding Register x03, starts from address 100 (x63) and x07 of them with CRC x45 xD7. The request looks as the following 01030064000745D7. And I get a response 01030E000000000000000000000000012D2E98 which is expected and absolutely correct. I have all zeros and last number is 301 Volt. What is a question: How I can use (or modify) Modbus4j library to match the current serial library InputStream and OutputStream. I have tried to use Transport class with my InputStream and it didn't work. As far as I understand from the Modbus4j test (in library) I have to create a ModbusFactory instance, set serial parameters, create a ModbusMaster and use ModbusLocator to get values. However I don't understand how to implement the android serial Input/OutputStream in the Modbus4J library. Please, could someone help me. Thank you
  • Batch request delay

    2
    0 Votes
    2 Posts
    2k Views
    P
    Hi, I found that using batch requests they are sent one next to each other, but not all devices like this behaviour: crappy devices prefer to have some delay between requests to not stress the CPU. Do you agree? Do you think that adding a programmable delay could be an improvement to Modbus4J?
  • Master and sockets control

    3
    0 Votes
    3 Posts
    3k 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.
  • Modbus4J 2.0.2. Problems with the listener and the threads.

    2
    0 Votes
    2 Posts
    3k 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.
  • Modbus4J 2.0.2 and Maven, How it works?

    3
    0 Votes
    3 Posts
    4k 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.