/** * Read the capacity data of a given SCSI device. * * @param dev * @return the capacity */ public static CapacityData readCapacity(SCSIDevice dev) throws SCSIException, TimeoutException, InterruptedException { final byte[] data = new byte[CapacityData.DEFAULT_LENGTH]; final CDB cdb = new CDBReadCapacity(); dev.executeCommand(cdb, data, 0, SCSIConstants.GROUP1_TIMEOUT); return new CapacityData(data); }
/** * Start/stop/eject/load/idle/standby/sleep the device. * * @throws SCSIException * @throws TimeoutException * @throws InterruptedException */ public static void startStopUnit( SCSIDevice dev, CDBStartStopUnit.Action action, boolean returnASAP) throws SCSIException, TimeoutException, InterruptedException { final CDB cdb = new CDBStartStopUnit(action, returnASAP); dev.executeCommand(cdb, null, 0, SCSIConstants.GROUP1_TIMEOUT); }
/** * Set the media removal state to locak / unlock the device. * * @param prevent * @param persistent * @throws SCSIException * @throws TimeoutException * @throws InterruptedException */ public static void setMediaRemoval(SCSIDevice dev, boolean prevent, boolean persistent) throws SCSIException, TimeoutException, InterruptedException { final CDB cdb = new CDBMediaRemoval(prevent, persistent); dev.executeCommand(cdb, null, 0, SCSIConstants.GROUP1_TIMEOUT); }
/** * Read data from the given device. * * @param dev * @param lba * @param nrBlocks * @param data * @param dataOffset * @throws SCSIException * @throws TimeoutException * @throws InterruptedException */ public static void readData(SCSIDevice dev, int lba, int nrBlocks, byte[] data, int dataOffset) throws SCSIException, TimeoutException, InterruptedException { final CDB cdb = new CDBRead10(lba, nrBlocks); dev.executeCommand(cdb, data, dataOffset, SCSIConstants.GROUP1_TIMEOUT); }