Modify read-memory to not print bitrate if outputting to stdout
- If writing to stdout, don't print the bitrate. This way, the output is
only the data. Bitrate is still printed if data is stored directly to
a file.
Example command to read an image from memory to stdout:
./opentitantool --conf nexus.json --interface nexus spi read-memory --length 76800 --start 1509949440 -
Change-Id: I3253d5301547a67880ca49dd3ffa107b4ff50e5d
diff --git a/sw/host/opentitantool/src/command/spi.rs b/sw/host/opentitantool/src/command/spi.rs
index 5923f00..da9549e 100644
--- a/sw/host/opentitantool/src/command/spi.rs
+++ b/sw/host/opentitantool/src/command/spi.rs
@@ -407,15 +407,15 @@
if self.filename.to_str() == Some("-") {
self.write_file(io::stdout(), &buffer)?;
+ Ok(None)
} else {
let file = File::create(&self.filename)?;
self.write_file(file, &buffer)?;
+ Ok(Some(Box::new(SpiReadMemoryResponse {
+ length: buffer.len(),
+ bytes_per_second: buffer.len() as f64 / duration,
+ })))
}
-
- Ok(Some(Box::new(SpiReadMemoryResponse {
- length: buffer.len(),
- bytes_per_second: buffer.len() as f64 / duration,
- })))
}
}