Package net.wimpi.modbus

Examples of net.wimpi.modbus.ModbusIOException


      if (m_Echo) {
        // read back the echoed message
        readEcho(len + 4);
      }
    } catch (Exception ex) {
      throw new ModbusIOException("I/O failed to write");
    }
  }//writeMessage
View Full Code Here


        done = true;
      } while (!done);
      return request;
    } catch (Exception ex) {
      if(Modbus.debug) System.out.println(ex.getMessage());
      throw new ModbusIOException("I/O exception - failed to read.");
    }

  }//readRequest
View Full Code Here

        done = true;
      } while (!done);
      return response;
    } catch (Exception ex) {
      if(Modbus.debug) System.out.println(ex.getMessage());
      throw new ModbusIOException("I/O exception - failed to read.");
    }
  }//readResponse
View Full Code Here

      if (isCheckingValidity()) {
        checkValidity();
      }
    } catch (InterruptedException ex) {
      throw new ModbusIOException("Thread acquiring lock was interrupted.");
    } finally {
      m_TransactionLock.release();
    }
  }//execute
View Full Code Here

        m_ByteOut.reset();
        msg.writeTo((DataOutput) m_ByteOut);
        m_Terminal.sendMessage(m_ByteOut.toByteArray());
      }
    } catch (Exception ex) {
      throw new ModbusIOException("I/O exception - failed to write.");
    }
  }//write
View Full Code Here

        req = ModbusRequest.createModbusRequest(functionCode);
        req.readFrom(m_ByteIn);
      }
      return req;
    } catch (Exception ex) {
      throw new ModbusIOException("I/O exception - failed to read.");
    }
  }//readRequest
View Full Code Here

        res = ModbusResponse.createModbusResponse(functionCode);
        res.readFrom(m_ByteIn);
      }
      return res;
    } catch (InterruptedIOException ioex) {
      throw new ModbusIOException("Socket timed out.");
    } catch (Exception ex) {
      ex.printStackTrace();
      throw new ModbusIOException("I/O exception - failed to read.");
    }
  }//readResponse
View Full Code Here

      if (!m_Terminal.isActive()) {
        try {
          m_Terminal.activate();
          m_IO = m_Terminal.getModbusTransport();
        } catch (Exception ex) {
          throw new ModbusIOException("Activation failed.");

        }
      }

      //3. Retry transaction m_Retries times, in case of
      //I/O Exception problems.
      m_RetryCounter = 0;

      while (m_RetryCounter <= m_Retries) {
        try {
          //toggle the id
          m_Request.setTransactionID(c_TransactionID.increment());
          //3. write request, and read response,
          //   while holding the lock on the IO object
          synchronized (m_IO) {
            //write request message
            m_IO.writeMessage(m_Request);
            //read response message
            m_Response = m_IO.readResponse();
            break;
          }
        } catch (ModbusIOException ex) {
          m_RetryCounter++;
          continue;
        }
      }

      //4. deal with "application level" exceptions
      if (m_Response instanceof ExceptionResponse) {
        throw new ModbusSlaveException(
            ((ExceptionResponse) m_Response).getExceptionCode()
        );
      }

      if (isCheckingValidity()) {
        checkValidity();
      }
    } catch (InterruptedException ex) {
      throw new ModbusIOException("Thread acquiring lock was interrupted.");
    } finally {
      m_TransactionLock.release();
    }

  }//execute
View Full Code Here

TOP

Related Classes of net.wimpi.modbus.ModbusIOException

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.