working past scsi inquiry response issue

This commit is contained in:
bunnie 2023-01-06 03:54:02 +08:00
parent 17831fe82b
commit 5c5bed2722
5 changed files with 22 additions and 1 deletions

1
Cargo.lock generated
View file

@ -4408,6 +4408,7 @@ version = "0.1.1"
dependencies = [
"embedded-hal",
"itm_logger",
"log",
"nb 0.1.3",
"packing 0.2.0",
"typenum",

View file

@ -175,7 +175,7 @@ pub(crate) fn main_hw() -> ! {
let mut ums = usbd_scsi::Scsi::new(
&ums_alloc,
16,
64,
bd,
"Kosagi".as_bytes(),
"Kosagi Precursor".as_bytes(),

View file

@ -175,6 +175,9 @@ impl<B: UsbBus> BulkOnlyTransport<'_, B> {
data_done: false,
}
}
pub fn debug(&self) {
log::debug!("data_i: {}, buffer_i: {}, buf: {:x?}", self.data_i, self.buffer_i, self.buffer);
}
fn max_packet_size(&self) -> u16 {
self.inner.max_packet_size()
@ -338,6 +341,7 @@ impl<B: UsbBus> BulkOnlyTransport<'_, B> {
let e = s + len;
self.buffer_i += len;
self.command_status_wrapper.data_residue = self.buffer_i as u32;
Ok(&mut self.buffer[s..e])
} else {
@ -391,6 +395,15 @@ impl<B: UsbBus> BulkOnlyTransport<'_, B> {
let end = start + len;
log::debug!("write_packet: start {} end {} buffer_i {} data_i {} residue {} packet_size{}, buf {:x?}",
start, end,
self.buffer_i,
self.data_i,
residue,
packet_size,
self.buffer,
);
let bytes = self.inner.write_packet(&self.buffer[start..end])?;
self.last_packet_full = bytes == packet_size;
@ -445,7 +458,9 @@ impl<B: UsbBus> BulkOnlyTransport<'_, B> {
fn end_data_transfer(&mut self) -> Result<(), Error> {
// Get the csw ready to send
log::debug!("data_i: {}, buffer_i: {}, buf: {:x?}", self.data_i, self.buffer_i, self.buffer);
self.pack_csw();
log::debug!("data_i: {}, buffer_i: {}, buf: {:x?}", self.data_i, self.buffer_i, self.buffer);
// We only send a zero length packet if the last write was a full packet AND we are sending
// less total bytes than the command header asked for
@ -489,6 +504,7 @@ impl<B: UsbBus> BulkOnlyTransport<'_, B> {
}
fn check_end_data_transfer(&mut self) -> Result<(), Error> {
self.flush()?;
match self.state {
State::ReceivingDataFromHost => {
// Check if we've read everything we were expecting

View file

@ -23,6 +23,7 @@ uf2_block = { version = "0.1.0", path = "../uf2_block" }
usbd_mass_storage = { version = "0.1.0", path = "../usbd_mass_storage" }
packing = { version = "0.2.0", path = "../packing/packing" }
usbd_bulk_only_transport = { version = "0.1.0", path = "../usbd_bulk_only_transport" }
log = "0.4.17"
[features]
trace-bot-headers = [ "usbd_bulk_only_transport/trace-bot-headers" ]

View file

@ -129,7 +129,10 @@ impl<B: UsbBus, BD: BlockDevice> Scsi<'_, B, BD> {
// for descriptor based response data.
Command::Inquiry(_) => {
let buf = self.inner.take_buffer_space(InquiryResponse::BYTES)?;
log::debug!("{:x?}", buf);
self.inquiry_response.pack(buf)?;
log::debug!("{:x?}", buf);
log::debug!("{:x?}", self.inquiry_response);
Done
},