Skip to content

Commit

Permalink
Support NVM hard resetting
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshLafleur committed Nov 11, 2024
1 parent eb2a40e commit 7ca3b30
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
7 changes: 7 additions & 0 deletions conUDS/src/arguments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub enum ArgSubCommands {
Reset(SubArgReset),
BootloaderDownload(SubArgBootloaderDownload),
ReadDID(SubArgReadDID),
NVMHardReset(SubArgNVMHardReset),
}

/// Download an application to an ECU
Expand Down Expand Up @@ -66,3 +67,9 @@ pub struct SubArgReadDID {
#[argh(positional)]
pub id: String,
}

/// Hard reset entire NVM including internal values
#[derive(Debug, FromArgs)]
#[argh(subcommand, name = "nvmHardReset")]
pub struct SubArgNVMHardReset {
}
19 changes: 15 additions & 4 deletions conUDS/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,24 @@ async fn main() -> Result<()> {
}
}
ArgSubCommands::ReadDID(did) => {
debug!(
"Performing DID read on {:#?} for node `{}`",
did, args.node
);
info!("Performing DID read on id {:#?} for node `{}`", did.id, args.node);
let id = u16::from_str_radix(&did.id, 16).unwrap();
let _ = uds_client.did_read(id).await;
}
ArgSubCommands::NVMHardReset(_) => {
info!(
"Performing NVM hard reset for node `{}`",
args.node
);
if let Err(e) = uds_client.routine_start(0xf0f0, None).await {
error!("While downloading app: {}", e);
}
else {
let result = uds_client.routine_get_results(0xf0f0).await;
/// TODO: Implement error checking
info!("Successful NVM erase");
}
}
}

app.lock().unwrap().exit = true;
Expand Down
2 changes: 1 addition & 1 deletion conUDS/src/modules/uds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ impl UdsClient {
.await?
.await
{
Ok(resp) => debug!("Start routine response: {:02x?}", resp),
Ok(resp) => info!("Start routine response: {:02x?}", resp),
Err(e) => {
error!("When waiting for response from ECU: {}", e);
return Err(e.into());
Expand Down

0 comments on commit 7ca3b30

Please sign in to comment.