Skip to content

Commit

Permalink
implemented read capacity scsi command.
Browse files Browse the repository at this point in the history
add partially read capacity response parser.
  • Loading branch information
janseeger committed Sep 7, 2014
1 parent 4f03214 commit e087156
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package net.alphadev.usbstorage.scsi.answer;

/**
* @author Jan Seeger <[email protected]>
*/
public class ReadCapacityResponse {
public static final int LENGTH = 8;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package net.alphadev.usbstorage.scsi.command;

import net.alphadev.usbstorage.bbb.CommandBlockWrapper;
import net.alphadev.usbstorage.scsi.answer.ReadCapacityResponse;

import static net.alphadev.usbstorage.util.BitStitching.setBytesFromInt;

/**
* @author Jan Seeger <[email protected]>
*/
@SuppressWarnings("unused")
public class ReadCapacity extends ScsiCommand {
public static final byte READ_CAPACITY = 0x25;

private int mLogicalBlockAddress;
private byte mControl;

public ReadCapacity() {
super(READ_CAPACITY);
}

@Override
public CommandBlockWrapper.Direction getDirection() {
return CommandBlockWrapper.Direction.DEVICE_TO_HOST;
}

@Override
public byte[] asBytes() {
byte[] retval = new byte[10];
retval[0] = READ_CAPACITY; // opcode
// retval[1] is reserved
setBytesFromInt(mLogicalBlockAddress, retval, 2);
// retval[6-8] is reserved
retval[9] = mControl;
return retval;
}


@Override
public int getExpectedAnswerLength() {
return ReadCapacityResponse.LENGTH;
}

public int getLogicalBlockAddress() {
return mLogicalBlockAddress;
}

public void setLogicalBlockAddress(int logicalBlockAddress) {
this.mLogicalBlockAddress = logicalBlockAddress;
}

public void setControl(byte control) {
this.mControl = control;
}
}

0 comments on commit e087156

Please sign in to comment.