summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2018-04-11 10:13:32 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2018-04-11 10:13:32 +0100
commitb6f881ed668dd80c607fbb893e6f1b4f2f782f2a (patch)
tree7eb936017ec57007c5feff00eb22d5bda8ffb80c
parente57cebf54de16c2c9cb0375cde46d31baea46c66 (diff)
downloadcanopied-b6f881ed668dd80c607fbb893e6f1b4f2f782f2a.tar.bz2
Include unused locations in decode report so that we can track if things change over time
-rw-r--r--src/definitions.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/definitions.rs b/src/definitions.rs
index 3b07eda..20afe38 100644
--- a/src/definitions.rs
+++ b/src/definitions.rs
@@ -2,6 +2,8 @@ use serde_yaml;
use types::{NamedValue, Value};
+use std::collections::HashSet;
+
#[derive(Debug, Deserialize)]
pub struct RawECURequest {
sendto: u16,
@@ -108,7 +110,12 @@ impl RawECUEntry {
return None;
}
+ let mut used_locations: HashSet<usize> = HashSet::new();
+
for entry in &self.response.values {
+ for i in entry.offset..(entry.offset + entry.length) {
+ used_locations.insert(i);
+ }
if let Some(ref kind) = entry.kind {
let value: Value = match kind.as_ref() {
"unsigned" => match entry.length {
@@ -161,6 +168,17 @@ impl RawECUEntry {
}
}
+ for i in 0..payload.len() {
+ if !used_locations.contains(&i) {
+ let name = {
+ let mut n = self.name.clone();
+ n.push_str(&format!(".unused_{}", i));
+ n
+ };
+ ret.push(NamedValue::new(&name, Some(Value::from(payload[i]))));
+ }
+ }
+
Some(ret)
}
}