Modbus Serial Master Jamod Watkins

Steveohara / j2mod. Pull requests 1. Projects 0 Wiki Insights. This implementation supports Modbus TCP, UDP, RTU over TCP, Serial RTU and Serial ASCII in both Master and Slave configurations. The serial comms is implemented using jSerialComm and does not require any outside dependencies over and above the logging facade slf4j. Unable to read modbus data using jamod 2( wimpi.modbus ) Ask Question. Up vote 0 down vote favorite. I am new to java serial port programming, I have trying to read data from the modbus slave device through modbus RTU over serial port from my java application. Writing to modbus with Jamod. Ask Question. Up vote 4 down vote favorite. I came across with a curious situation when using jamod to write to modbus. Following read code works perfectly. Java Modbus Library (jamod). This project represents a Modbus implementation in 100% Java. ASCII, RTU (Master only), BIN.

Balasubramaniam - 2014-09-15

​Hi, i am new to java serial port programming​,

I have trying to read data from the modbus slave device through modbus RTU over serial port from my java application.

i am using the Jamod java library to read modbus protocal.

  • Modbus4J Modbus RTU master This topic has been deleted. I want to read the data from the device and show the value in my system. So far, I discover J2mod, Jamod and Modbus4Java library. I used all modbus4java to connect and get the device's data. Modbus Master Init Error: com.serotonin.io.serial.SerialPortException: gnu.io.
  • Jamod - Java Modbus implementation. Modbus serial RTU. Utility modpoll is a command line based Modbus master simulator and test utility. Modpoll runs on.
  • Hardware Programming with modbus libraries: jamod (java) nmodbus (c#) oscat(structured text).

In my case my application failed to receive entire modbus response from the device. please find my java coding and error log for your reference.

Any one can suggest me what may be the reason for the error.

Thanks in advance

ERROR
Serial Port Connection
Connection..net.wimpi.modbus.net.SerialConnection@11210ee
Serial port status..true
Sent: 01 04 03 e8 00 05 b0 79
Last request: 01 04 03 e8 00 05 b0 79
CRC Error in received frame: 0 bytes:
Response: 01 84
execute try 1 error: I/O exception - failed to read
Clear input: 02 c2 c1
Sent: 01 04 03 e8 00 05 b0 79
Last request: 01 04 03 e8 00 05 b0 79
CRC Error in received frame: 0 bytes:
execute try 2 error: I/O exception - failed to read
Response: 01 84
Clear input: 02 c2 c1
Sent: 01 04 03 e8 00 05 b0 79
Last request: 01 04 03 e8 00 05 b0 79
CRC Error in received frame: 0 bytes:
Response: 01 84
net.wimpi.modbus.ModbusIOException: I/O exception - failed to read
at net.wimpi.modbus.io.ModbusRTUTransport.readResponse(ModbusRTUTransport.java:163)
at net.wimpi.modbus.io.ModbusSerialTransaction.execute(ModbusSerialTransaction.java:187)
at modbusnewapplication.ModbusConnection.main(ModbusConnection.java:8

Serial Port modbus Program ---------------------------

package modbusnewapplication;

import java.io.;
import javax.comm.;
import net.wimpi.modbus.ModbusCoupler;
import net.wimpi.modbus.io.ModbusSerialTransaction;
import net.wimpi.modbus.msg.ReadInputRegistersRequest;
import net.wimpi.modbus.msg.ReadInputRegistersResponse;
import net.wimpi.modbus.net.SerialConnection;
import net.wimpi.modbus.util.SerialParameters;

public class ModbusConnection {

public static void main(String[] args) {
//if (args.length < 4) {
// System.out.println('not enough args');
// System.exit(1);
//}else{
try {
System.out.println('Serial Port Connection');
/ The important instances of the classes mentioned before /
SerialConnection con = null; //the connection
ModbusSerialTransaction trans = null; //the transaction
ReadInputRegistersRequest req = null; //the request
ReadInputRegistersResponse res = null; //the response

/ Variables for storing the parameters /
String portname= 'COM1'; //the name of the serial port to be used
int unitid = 1; //the unit identifier we will be talking to
int ref = 1000; //the reference, where to start reading from
int count = 5; //the count of IR's to read
int repeat = 1; //a loop for repeating the transaction
boolean isopen = false;
// 2. Set master identifier
// ModbusCoupler.createModbusCoupler(null);
// ModbusCoupler.getReference().setMaster(master); I added this in
// ModbusCoupler.getReference().setMaster(true);
// ModbusCoupler.getReference().setUnitID(1);

// 3. Setup serial parameters
SerialParameters params = new SerialParameters();
params.setPortName('COM1');
params.setBaudRate(9600);
params.setDatabits(8);
params.setParity('None');
params.setStopbits(1);
params.setEncoding('RTU');
params.setEcho(false);

System.setProperty('net.wimpi.modbus.debug', 'true');
// 4. Open the connection
con = new SerialConnection(params);
System.out.println('Connection..' + con.toString());
con.open();

isopen = con.isOpen();
System.out.println('Serial port status..' + isopen);
// 5. Prepare a request
req = new ReadInputRegistersRequest(ref, count);
req.setUnitID(unitid);
req.setHeadless();

// 6. Prepare a transaction
trans = new ModbusSerialTransaction(con);
trans.setRequest(req);

// 7. Execute the transaction repeat times
int k = 0;
do {
trans.execute();
res = (ReadInputRegistersResponse) trans.getResponse();
for (int n = 0; n < res.getWordCount(); n++) {
System.out.println('Word ' + n + '=' + res.getRegisterValue(n));
}
k++;
} while (k < repeat);

Serial master i margarita smotret youtube

// 8. Close the connection
con.close();

} catch (Exception ex) {
ex.printStackTrace();
}
//}//else
}//main

Puthuyugam Korean Serial Master Sun In Tamil

}//class SerialAITest

Viewed 10k times

I need to write Modbus RTU master app in Java that support 03 - Read Holding Registers and 16 - Write Multiple Registers.

Modbus Serial Driver

I found three java libraries: jamod, j2mod, modbus4j. I try all of these libraries (I spend about 4 hours) and it still doesn't work.

Do you know any step-by-step tutorial or example code?

Free software for pc. Version 4.82 adds or updates the following features.

I'm using USB->RS-485 converter. If I testing in QModBus, it works good.

Thank you.

.

martinmartin

Mb Serial Master Query

7874 gold badges16 silver badges48 bronze badges
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.

protected by CommunityDec 14 '16 at 10:16

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?

Browse other questions tagged javaserial-portrxtxmodbus or ask your own question.