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.

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

    4
    0 Votes
    4 Posts
    4k Views
    ramonhlR
    Thanks for the information. If I execute Eclipse using the sudo command (administrator) I can run the ListenerTest. See you
  • SetValue() and getValue() methods

    2
    0 Votes
    2 Posts
    3k Views
    P
    I'm trying to read and write to a PLC via a gateway using modbus4j. I've gotten the read function to work, but I'm not getting anywhere on the setValue() method. I've tried various variations of this: IpParameters params = new IpParameters(); params.setHost("192.168.0.100"); params.setPort(502); //create modbus TCP master ModbusMaster master = new ModbusFactory().createTcpMaster(params, false); master.init(); int regValue=0; regValue = regValue | 1 << 0; ModbusLocator loc0 = new ModbusLocator(1,RegisterRange.HOLDING_REGISTER,0,DataType.TWO_BYTE_INT_UNSIGNED); master.setValue(loc0,8); Also the getValue() method only works sporadically maybe 30% of the time I call getValue() I get the response I expect, and the other times I get all 0s out. System.out.println(master.getValue(33,RegisterRange.HOLDING_REGISTER,70,2)); Am I misunderstanding some aspect of the get and set value methods? Thanks.
  • StreamTransport null pointer exception

    6
    0 Votes
    6 Posts
    5k Views
    M
    The line is not in the CVS code. Perhaps it still is in the src jar file. Try using the repo source instead.
  • Automatic transmission?

    2
    0 Votes
    2 Posts
    2k Views
    M
    Hello, I'm currently working on a MODBUS TCP project. Right now, I'm able to read out and write to the network/sensors. My next task is to automaticly read out the values of the sensor. The sensor are sending some kind of push notification with the current value to the network (every 20 seconds). Is the Listener function the correct way of getting these automatic transmissions? greets (sorry for my bad english)
  • Hi.Can anybody give suggestions regarding the Modbus Tcp/Ip

    6
    0 Votes
    6 Posts
    4k Views
    N
    Why not trying to poll your slave withj a command line tool like "modpoll" ? once you'll be sure that everythning is allright with it, then switch back to Mango. Also use the log functionality in Mango (check the Log I/O Box in the modbus Data Source) and make a tail -f on the modbusIO-1.log file
  • Why using function 0x16 when writing to only one register

    2
    0 Votes
    2 Posts
    2k Views
    N
    Hi, I'm facing a problem. My slave doesn't support function 0x16 so I would prefer mango to use function 0x06 instead. i've notice that Mango uses it when writing a integer value to a register but uses 0x16 to write a "BIT" value (The Data point is declared as a holding Register, but a simple bit si addressed)? Does anybody knows why ? isn't it possible to force use of function 0x06 to when writing to only one register ? Thanks, i'm not good in java and i cannot imagine put my hand in the code ... :-( nico Examples : below I try to write value 1 to bit 1 of holding register 7 into slave 3 2014/04/07-18:50:42,920 O 03160007fffd0002e23a 2014/04/07-18:50:42,965 I 0396512f9c My slave responds with an error because it doesn't handle function 16 Below when i try to write integer value 2 to same register 7 (my locator is then declared as a 2 byte integer value) 2014/04/07-19:06:49,813 O 030600070002b828 2014/04/07-19:06:49,848 I 030600070002b828 ... Then it works
  • ¿Does anybody else get Response times of this magnitude?

    2
    0 Votes
    2 Posts
    2k Views
    N
    Hi. I made a software to get some values from my PLC and it is certainly ok.. but I get response times mostly of 50 ms (although somethimes they vary between 9 to 60 ms). This was my first time working with an industrial protocol and I'm not sure if this results are "the expected ones" or if I'm doing something wrong. I'll leave some images of my results using the CurrentTimeInMillis() method. Thanks. Attachment: download link
  • Data is Always False & RXTXHack

    2
    0 Votes
    2 Posts
    2k Views
    T
    Hi; For a term project I need to connect to a PLC over Modbus Serial. I've searched and used for many different Java Modbus libraries but none of them worked. Modbus4J seems to be working. At least no error on initialization state. Should've turned to RTU mode, my bad. It works fine now.
  • NullPointerException when trying to create RTU or ASCII Slave

    3
    0 Votes
    3 Posts
    3k Views
    R
    Adding to this discussion: the listener.start() calls into RtuSlave.start(), which immediately calls SerialSlave.start(): in SerialSlave: @Override public void start() throws ModbusInitException { try { serialPort = SerialUtils.openSerialPort(serialParameters); transport = new StreamTransport(serialPort.getInputStream(), serialPort.getOutputStream()); transport.start("Modbus4J SerialSlave"); // <--- This line throws the exception } catch (Exception e) { throw new ModbusInitException(e); } } The line that throws the NullPointerException is the third line, the transport.start("Modbus4J SerialSlave"). This calls into the StreamTransport class of seroUtils.jar, which we do not have the source code for. Would it be possible for me to get this source code so that I can debug this problem?
  • Write several float registers

    2
    0 Votes
    2 Posts
    2k Views
    N
    Hi mlohbihler I recently figured out how to write several registers in one request but I can't find how to change data types too, is it even posible? Thank you.
  • Writing multiple registers at once

    2
    0 Votes
    2 Posts
    2k Views
    N
    Hi mlohbihler That's my doubt. How can I write a bunch of registers at once. I was looking at WriteRegistersRequest and WriteRegistersResponse but I don't know. Thank you.
  • What does the "encapsulated" value do?

    4
    0 Votes
    4 Posts
    2k Views
    N
    Has something to do with RTU over TCP, I think.
  • SetParity(int parity) method

    2
    0 Votes
    2 Posts
    2k Views
    N
    Hi, I have a little doubt with setParity parameters.. I wanna know how to set non parity and I don't really see how. Is it 0 = none, 1 = odd, 2 = even, 3 = mark, 4 = space? thx
  • Is the seroUtils.jar source code available?

    3
    0 Votes
    3 Posts
    2k Views
    JoelHaggarJ
    No, not at this time but it may be made available some time in the future. Joel.
  • Handling of IEC 61131-3 data type BYTE

    3
    0 Votes
    3 Posts
    3k Views
    J
    Hello, so far getting byte values is working but I'd like some opinions on the byte order. Should byte 0 be the LSB or MSB? Modbus being big-endian the first byte in the register (register is a 16-bit word) is the MSB. The second is the LSB. But in my PLC when I configure the variables the first byte value at a given address is the LSB, the second the MSB. To summarize: PLC configuration BYTE first AT %QB616 BYTE second AT %QB617 MODBUS register 308 (word value) second | first modbus4j should this be batchRead.addLocator("second", slaveId, RegisterRange.INPUT_REGISTER, 308, DataType.BYTE, (byte) 0); batchRead.addLocator("first", slaveId, RegisterRange.INPUT_REGISTER, 308, DataType.BYTE, (byte) 1); or batchRead.addLocator("first", slaveId, RegisterRange.INPUT_REGISTER, 308, DataType.BYTE, (byte) 0); batchRead.addLocator("second", slaveId, RegisterRange.INPUT_REGISTER, 308, DataType.BYTE, (byte) 1); I would prefer the latter. Regards jmbsps
  • Request for multiple-register reading example

    4
    0 Votes
    4 Posts
    2k Views
    N
    Hey thanks :D. And I don't feel bad 'cause that code is really strange to me. I'd never figured it out by myself.
  • Modbus Request Logging

    3
    0 Votes
    3 Posts
    3k Views
    N
    HI ! Did someone face the same problem than me concerning modbus logs ? I'm facing a lot of trouble with my modbus and logging would be very usefull... Bye
  • Read more than a register in one request

    4
    0 Votes
    4 Posts
    5k Views
    V
    Hi, I'm not bkhashfeh but I have the same problem and I'd apreciate the help :D . Here is my code where I'm reading three registers per second (or trying). package modbusmastertest; import com.serotonin.modbus4j.ModbusFactory; import com.serotonin.modbus4j.ModbusMaster; import com.serotonin.modbus4j.code.DataType; import com.serotonin.modbus4j.ip.IpParameters; import java.io.FileWriter; import java.io.PrintWriter; import java.util.Calendar; class MBMasterTest { public static void main(String[] args) throws Exception { // Modbus master settings ModbusFactory factory = new ModbusFactory(); IpParameters params = new IpParameters(); params.setHost("192.168.0.1"); params.setPort(502); params.setEncapsulated(false); ModbusMaster master = factory.createTcpMaster(params, false); master.setTimeout(333); master.setRetries(1); // CSV writter settings FileWriter fwriter; fwriter = new FileWriter("C:/Users/NESTOR/Dropbox/Siemens_S7-1200.csv"); PrintWriter outputFile = new PrintWriter(fwriter); outputFile.println("Date,Sensor_1,Sensor_2,Sensor_3"); // Primera línea Object []Register = new Object[3]; // Date settings Calendar cal = Calendar.getInstance(); long elapsedTime = 0; long time = 0; // Cuerpo del programa long start = System.currentTimeMillis(); // Tiempo de inicio try { master.init(); while(System.currentTimeMillis()<(start+10000)) { time = System.currentTimeMillis(); for(int i = 0; i<3; i++) { Register* = master.getValue(1,40001+i,DataType.TWO_BYTE_INT_SIGNED); } System.out.println(Register[0]+","+Register[1]+","+Register[2]); System.out.println("" + ""); elapsedTime = System.currentTimeMillis()-time; cal.setTimeInMillis(cal.getTime().getTime() + elapsedTime); outputFile.println(cal.getTime().toString()+","+Register[0]+","+Register[1]+","+Register[2]); // Se escribe nueva linea en archivo } outputFile.close(); // Se cierra el archivo } finally { master.destroy(); //Se destruye el objeto master } System.out.println("" + ""); System.out.println("Tardo " + (System.currentTimeMillis()-start) + "ms"); } }
  • Modbus4j modbus/tcp client with Siemens s7 1200 slave "Test" code

    4
    0 Votes
    4 Posts
    6k Views
    V
    I got help and figured it out. My PLC can't read encapsulated data.. at least with my current configuration I think.. It works perfectly.
  • IP Parameters, Encapuled or Not? Role of transaction ID?

    2
    0 Votes
    2 Posts
    2k Views
    F
    Hi, I just want understand what's the difference of the field encapsulated of IpParameters Here the source code // Wrap the modbus request in a ip request. OutgoingRequestMessage ipRequest; if (ipParameters.isEncapsulated()) ipRequest = new EncapMessageRequest(request); else ipRequest = new XaMessageRequest(request, getNextTransactionId()); I work with a plc wago with the UdpMaster. Thanks