Skip to content

Commit

Permalink
fixed serial inter transaction delay
Browse files Browse the repository at this point in the history
  • Loading branch information
ssalonen committed Feb 25, 2016
1 parent 10ab727 commit 6f6f194
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,6 @@ public void update(ModbusBinding binding) {

/**
* Updates OpenHAB item with data read from slave device
* works only for type "coil" and "holding"
*
* @param binding ModbusBinding
* @param item item to update
Expand Down Expand Up @@ -402,7 +401,8 @@ private ModbusResponse getModbusData(ModbusRequest request) {
try {
connection = getConnection(endpoint);
if (connection == null) {
logger.warn("ModbusSlave ({}) not connected -- aborting read request {}", name, request);
logger.warn("ModbusSlave ({}) not connected -- aborting read request {}. Endpoint {}", name, request,
endpoint);
return null;
}
request.setUnitID(getId());
Expand All @@ -411,8 +411,9 @@ private ModbusResponse getModbusData(ModbusRequest request) {
try {
transaction.execute();
} catch (Exception e) {
logger.error("ModbusSlave ({}): Error getting modbus data for request {}. Error: {}", name, request,
e.getMessage());
logger.error(
"ModbusSlave ({}): Error getting modbus data for request {}. Error: {}. Endpoint {}. Connection: {}",
name, request, e.getMessage(), endpoint, connection);
invalidate(endpoint, connection);
// Invalidated connections should not be returned
connection = null;
Expand All @@ -429,12 +430,6 @@ private ModbusResponse getModbusData(ModbusRequest request) {
return response;
}

// protected abstract boolean isConnected();
//
// protected abstract boolean connect();
//
// protected abstract void resetConnection();

protected void onConnectionAcquire(ModbusSlaveConnection connection) {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,10 @@ public void activateObject(ModbusSlaveEndpoint endpoint, PooledObject<ModbusSlav
waited, config.getInterBorrowDelayMillis(), obj.getObject(), endpoint);
}
return;
} else {
// invariant: !connection.isConnected()
tryConnectDisconnected(endpoint, obj, connection, config);
}
// invariant: !connection.isConnected()
tryConnectDisconnected(endpoint, obj, connection, config);
lastBorrowMillis.put(endpoint, System.currentTimeMillis());
} catch (Exception e) {
logger.error("Error connecting connection {} for endpoint {}", obj.getObject(), endpoint, e.getMessage());
Expand Down

0 comments on commit 6f6f194

Please sign in to comment.