Skip to content
Open
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 6 additions & 35 deletions cmd/console-proxy/src/posix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::os::unix::io::AsRawFd;
use std::time::Duration;
use std::{io, thread};

use anyhow::{Context, Result, anyhow, bail};
use anyhow::{Context, Result};
use clap::Parser;
use crossbeam_channel::{Sender, select};
use picocom_map::RemapRules;
Expand Down Expand Up @@ -53,7 +53,7 @@ impl<'a> UartConsoleHandler<'a> {
fn uart_read(&mut self, buf: &mut [u8]) -> Result<usize> {
let op = self.hubris.get_idol_command("ControlPlaneAgent.uart_read")?;

let value = humility_hiffy::hiffy_call(
let v = humility_hiffy::hiffy_call::<u32>(
self.hubris,
self.core,
&mut self.context,
Expand All @@ -63,14 +63,6 @@ impl<'a> UartConsoleHandler<'a> {
Some(buf),
)?;

let v = match value {
Ok(v) => v,
Err(e) => bail!("Got Hiffy error: {e}"),
};

let v =
v.as_base()?.as_u32().ok_or_else(|| anyhow!("Couldn't get U32"))?;

Ok(v as usize)
}

Expand All @@ -80,7 +72,7 @@ impl<'a> UartConsoleHandler<'a> {

let buf = &buf[..usize::min(buf.len(), HIFFY_BUF_SIZE)];

let value = humility_hiffy::hiffy_call(
let v = humility_hiffy::hiffy_call::<u32>(
self.hubris,
self.core,
&mut self.context,
Expand All @@ -90,14 +82,6 @@ impl<'a> UartConsoleHandler<'a> {
None,
)?;

let v = match value {
Ok(v) => v,
Err(e) => bail!("Got Hiffy error: {e}"),
};

let v =
v.as_base()?.as_u32().ok_or_else(|| anyhow!("Couldn't get U32"))?;

Ok(v as usize)
}

Expand Down Expand Up @@ -180,7 +164,7 @@ impl<'a> UartConsoleHandler<'a> {
.hubris
.get_idol_command("ControlPlaneAgent.set_humility_uart_client")?;

let value = humility_hiffy::hiffy_call(
humility_hiffy::hiffy_call::<()>(
self.hubris,
self.core,
&mut self.context,
Expand All @@ -189,19 +173,15 @@ impl<'a> UartConsoleHandler<'a> {
None,
None,
)?;

match value {
Ok(_) => Ok(()),
Err(e) => bail!("Got Hiffy error: {e}"),
}
Ok(())
}

fn current_client(&mut self) -> Result<()> {
let op = self
.hubris
.get_idol_command("ControlPlaneAgent.get_uart_client")?;

let value = humility_hiffy::hiffy_call(
let value = humility_hiffy::hiffy_call::<humility::reflect::Enum>(
self.hubris,
self.core,
&mut self.context,
Expand All @@ -211,15 +191,6 @@ impl<'a> UartConsoleHandler<'a> {
None,
)?;

let value = match value {
Ok(v) => v,
Err(e) => bail!("Got Hiffy error: {e}"),
};

let value = value
.as_enum()
.context("get_uart_client did not return an enum")?;

println!("Current console client: {}", value.disc());
Ok(())
}
Expand Down
8 changes: 6 additions & 2 deletions cmd/hiffy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,15 +311,19 @@ fn hiffy(context: &mut ExecutionContext) -> Result<()> {
};

(
hiffy_call(
match hiffy_call(
hubris,
core,
&mut context,
&op,
&args,
input.as_deref(),
output.as_deref_mut(),
)?,
) {
Ok(s) => Ok(s),
Err(HiffyCallError::Hiffy(s)) => Err(s),
Err(HiffyCallError::Other(e)) => return Err(e),
},
output,
)
};
Expand Down
13 changes: 2 additions & 11 deletions cmd/host/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ fn host_post_codes(

let mut context = HiffyContext::new(hubris, core, 5000)?;
let op = hubris.get_idol_command("Sequencer.post_code_buffer_len")?;
let value = humility_hiffy::hiffy_call(
let count = humility_hiffy::hiffy_call::<u32>(
hubris,
core,
&mut context,
Expand All @@ -362,12 +362,6 @@ fn host_post_codes(
None,
None,
)?;
let Ok(reflect::Value::Base(reflect::Base::U32(count))) = value else {
bail!(
"Got bad value from post_code_buffer_len: \
expected U32, got {value:?}"
);
};

let op = hubris.get_idol_command("Sequencer.get_post_code")?;
let handle_value = |v| {
Expand Down Expand Up @@ -440,7 +434,7 @@ fn host_last_post_code(

let mut context = HiffyContext::new(hubris, core, 5000)?;
let op = hubris.get_idol_command("Sequencer.last_post_code")?;
let value = humility_hiffy::hiffy_call(
let v = humility_hiffy::hiffy_call::<u32>(
hubris,
core,
&mut context,
Expand All @@ -449,9 +443,6 @@ fn host_last_post_code(
None,
None,
)?;
let Ok(reflect::Value::Base(reflect::Base::U32(v))) = value else {
bail!("Got bad value from last_post_code: expected U32, got {value:?}");
};
if raw {
println!("{v:08x}");
} else {
Expand Down
Loading
Loading