Hello,

There are two devices(a display and a rfid reader) communicate with modbus protocol. The display is the master and the rfid reader is the slave. I want to extend the system and use a raspberry pi as a bridge between two devices. Because I want to connect the system with a web service and i can't overwrite the sofwate of display. Therefore raspbery pi should act as a master to rfid reader. I have done that part using jamod Serial Master Howto example.

Also raspberry pi should act as a slave to the display. But I couldn't do that part successfully because it gives error ModbusIOException - failed to read.

Please help me to identify what I have missed here.

The request coming from display is 01 03 00 00 00 0A
As I understood, that means it should read 10 registers from 0 address

the code I wrote is

spi = new SimpleProcessImage();
for(int i=0; i<10; i++){
    spi.addRegister(new SimpleRegister(0));
}
spi.setRegister(0, new SimpleRegister(5));
spi.setRegister(1, new SimpleRegister(125));
spi.setRegister(2, new SimpleRegister(203));
spi.setRegister(3, new SimpleRegister(30));
spi.setRegister(4, new SimpleRegister(0));
spi.setRegister(5, new SimpleRegister(0));
spi.setRegister(6, new SimpleRegister(0));
spi.setRegister(7, new SimpleRegister(0));
spi.setRegister(8, new SimpleRegister(0));
spi.setRegister(9, new SimpleRegister(0));

ModbusCoupler.getReference().setProcessImage(spi);
ModbusCoupler.getReference().setMaster(false);
ModbusCoupler.getReference().setUnitID(1);

SerialParameters params = new SerialParameters();
params.setPortName("/dev/ttyUSB0");
params.setBaudRate(9600);
params.setReceiveTimeout(10000);
params.setDatabits(8);
params.setParity("none");
params.setStopbits(1);
params.setEncoding("bin");
params.setEcho(false);

listener = new ModbusSerialListener(params);
listener.setListening(true);

Exception is

net.wimpi.modbus.ModbusIOException: I/O exception - failed to read
at net.wimpi.modbus.io.ModbusBINTransport.readRequest(ModbusBINTransport.java:140)
......

I have used params.setEncoding("bin") here because rtu not supports in slave mode.

Please help
Thank You