Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmsisdap: Fix block transfer response parsing #767

Merged
merged 1 commit into from
Aug 21, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions probe-rs/src/probe/cmsisdap/commands/transfer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use super::{CommandId, Request, SendError};
use crate::architecture::arm::PortType;
use scroll::{Pread, Pwrite, LE};

#[derive(Copy, Clone, Debug)]
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum RW {
R = 1,
W = 0,
Expand Down Expand Up @@ -252,12 +252,16 @@ impl Request for TransferBlockRequest {
num_transfers
);

for data_offset in 0..num_transfers {
data.push(
buffer
.pread_with(3 + data_offset * 4, LE)
.map_err(|_| SendError::NotEnoughData)?,
);
// if it's a read, process the read data.
// If it's a write, there's no interesting data in the response.
if self.transfer_request.r_n_w == RW::R {
for data_offset in 0..transfer_count as usize {
data.push(
buffer
.pread_with(3 + data_offset * 4, LE)
.map_err(|_| SendError::NotEnoughData)?,
);
}
}

Ok(TransferBlockResponse {
Expand Down