int dataOffset, long timeout) throws SCSIException,
TimeoutException, InterruptedException {
final IDEDevice dev = (IDEDevice) getDevice();
final IDEBus bus = (IDEBus) dev.getBus();
final IDEPacketCommand cmd = new IDEPacketCommand(
dev.isPrimary(), dev.isMaster(), cdb.toByteArray(), data,
dataOffset);
bus.executeAndWait(cmd, timeout);
if (!cmd.isFinished()) {
throw new TimeoutException("Timeout in SCSI command");
} else if (cmd.hasError()) {
throw new SCSIException("Command error 0x" + NumberUtils.hex(cmd.getError(), 2));
} else {
return cmd.getDataTransfered();
}
}