Menu

TCP Slave responses

Darius
2012-12-07
2013-05-28
  • Darius

    Darius - 2012-12-07

    Hi, i am quite new in programing with java and with the example from the page i am trying to create a TCP Slave, which would accept WriteMultipleRegisters (fc16) requests and send appropriate responses. code:

    //1. Prepare a process image
                              
                         for (int i = 0; i < 200; i++)
                            spi.addRegister(new SimpleRegister(0));
                         
                          ModbusCoupler.getReference().setProcessImage(spi);
                          ModbusCoupler.getReference().setMaster(false);
                          ModbusCoupler.getReference().setUnitID(254);

                          //3. create a listener with 3 threads in pool
                          if (Modbus.debug) System.out.println("Listening…");
                        
                          listener = new ModbusTCPListener(1, addr);
                          listener.setPort(port);                                                            
                          listener.start();

    with this code i am able to get requests (write in it) but i am wondering why it didn't sending any responses?

     
  • Darius

    Darius - 2012-12-10

    One more question would be, how can i get ip address of the master device which is connecting to slave?

     

Log in to post a comment.