Package net.wimpi.modbusme.io

Examples of net.wimpi.modbusme.io.ModbusTransport


  private void listen() {
    try {
      m_Listening = true;
      m_SerialCon.open();
      //System.out.println("Opened Serial connection.");
      ModbusTransport transport = m_SerialCon.getModbusTransport();
      do {
        if (m_Listening) {
          try {
            //1. read the request
            ModbusRequest request = transport.readRequest();
            ModbusResponse response = null;

            //test if Process image exists
            if (ModbusCoupler.getReference().getProcessImage() == null) {
              response =
                  request.createExceptionResponse(Modbus.ILLEGAL_FUNCTION_EXCEPTION);
            } else {
              response = request.createResponse();
            }

            if (Modbus.debug)
              System.out.println("Request:" + request.getHexMessage());
            if (Modbus.debug)
              System.out.println("Response:" + response.getHexMessage());

            transport.writeMessage(response);

            count();
          } catch (ModbusIOException ex) {
            ex.printStackTrace();
            continue;
View Full Code Here

TOP

Related Classes of net.wimpi.modbusme.io.ModbusTransport

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.