use of net.wimpi.modbus.msg.ReadInputDiscretesResponse in project openhab1-addons by openhab.
the class ModbusSerialMaster method readInputDiscretes.
// writeMultipleCoils
/**
* Reads a given number of input discrete states from the slave.
* <p/>
* Note that the number of bits in the bit vector will be
* forced to the number originally requested.
*
* @param unitid the slave unit id.
* @param ref the offset of the input discrete to start reading from.
* @param count the number of input discrete states to be read.
* @return a <tt>BitVector</tt> instance holding the received input discrete
* states.
* @throws ModbusException if an I/O error, a slave exception or
* a transaction error occurs.
*/
public synchronized BitVector readInputDiscretes(int unitid, int ref, int count) throws ModbusException {
m_ReadInputDiscretesRequest.setUnitID(unitid);
m_ReadInputDiscretesRequest.setReference(ref);
m_ReadInputDiscretesRequest.setBitCount(count);
m_Transaction.setRequest(m_ReadInputDiscretesRequest);
m_Transaction.execute();
BitVector bv = ((ReadInputDiscretesResponse) m_Transaction.getResponse()).getDiscretes();
bv.forceSize(count);
return bv;
}
use of net.wimpi.modbus.msg.ReadInputDiscretesResponse in project openhab1-addons by openhab.
the class ModbusTCPMaster method readInputDiscretes.
// writeMultipleCoils
/**
* Reads a given number of input discrete states from the slave.
* <p/>
* Note that the number of bits in the bit vector will be
* forced to the number originally requested.
*
* @param ref the offset of the input discrete to start reading from.
* @param count the number of input discrete states to be read.
* @return a <tt>BitVector</tt> instance holding the received input discrete
* states.
* @throws ModbusException if an I/O error, a slave exception or
* a transaction error occurs.
*/
public synchronized BitVector readInputDiscretes(int ref, int count) throws ModbusException {
m_ReadInputDiscretesRequest.setReference(ref);
m_ReadInputDiscretesRequest.setBitCount(count);
m_Transaction.setRequest(m_ReadInputDiscretesRequest);
m_Transaction.execute();
BitVector bv = ((ReadInputDiscretesResponse) m_Transaction.getResponse()).getDiscretes();
bv.forceSize(count);
return bv;
}
Aggregations