summaryrefslogtreecommitdiff
path: root/src/definitions.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/definitions.rs')
-rw-r--r--src/definitions.rs83
1 files changed, 36 insertions, 47 deletions
diff --git a/src/definitions.rs b/src/definitions.rs
index aa78809..3b07eda 100644
--- a/src/definitions.rs
+++ b/src/definitions.rs
@@ -71,10 +71,8 @@ impl RawECUEntry {
for entry in &ecu.response.values {
if let Some(ref vals) = entry.check {
let has = &payload[entry.offset..(entry.offset + vals.len())];
- trace!("Check: Does {:?} == {:?}", vals, has);
for i in 0..vals.len() {
if has[i] != vals[i] {
- trace!("Oops, not the same");
continue 'ecu;
}
}
@@ -113,51 +111,42 @@ impl RawECUEntry {
for entry in &self.response.values {
if let Some(ref kind) = entry.kind {
let value: Value = match kind.as_ref() {
- "unsigned" => {
- trace!("Unsigned");
- match entry.length {
- 1 => payload[entry.offset].into(),
- 2 => (((payload[entry.offset] as u16) << 8)
- + (payload[entry.offset + 1] as u16))
- .into(),
- 3 => (((payload[entry.offset] as u32) << 16)
- + ((payload[entry.offset + 1] as u32) << 8)
- + (payload[entry.offset + 2] as u32))
- .into(),
- 4 => (((payload[entry.offset] as u32) << 24)
- + ((payload[entry.offset + 1] as u32) << 16)
- + ((payload[entry.offset + 2] as u32) << 8)
- + (payload[entry.offset + 3] as u32))
- .into(),
- _ => panic!("Unhandled length: {}", entry.length),
- }
- }
- "signed" => {
- trace!("Signed");
- match entry.length {
- 1 => (payload[entry.offset] as i8).into(),
- 2 => ((((payload[entry.offset] as u16) << 8)
- + (payload[entry.offset + 1] as u16))
- as i16)
- .into(),
- 3 => ((((payload[entry.offset] as u32) << 16)
- + ((payload[entry.offset + 1] as u32) << 8)
- + (payload[entry.offset + 2] as u32))
- as i32)
- .into(),
- 4 => ((((payload[entry.offset] as u32) << 24)
- + ((payload[entry.offset + 1] as u32) << 16)
- + ((payload[entry.offset + 2] as u32) << 8)
- + (payload[entry.offset + 3] as u32))
- as i32)
- .into(),
- _ => panic!("Unhandled length: {}", entry.length),
- }
- }
- "bit" => {
- trace!("Bit");
- ((payload[entry.offset] & (1 << entry.base.unwrap())) != 0).into()
- }
+ "unsigned" => match entry.length {
+ 1 => payload[entry.offset].into(),
+ 2 => (((payload[entry.offset] as u16) << 8)
+ + (payload[entry.offset + 1] as u16))
+ .into(),
+ 3 => (((payload[entry.offset] as u32) << 16)
+ + ((payload[entry.offset + 1] as u32) << 8)
+ + (payload[entry.offset + 2] as u32))
+ .into(),
+ 4 => (((payload[entry.offset] as u32) << 24)
+ + ((payload[entry.offset + 1] as u32) << 16)
+ + ((payload[entry.offset + 2] as u32) << 8)
+ + (payload[entry.offset + 3] as u32))
+ .into(),
+ _ => panic!("Unhandled length: {}", entry.length),
+ },
+ "signed" => match entry.length {
+ 1 => (payload[entry.offset] as i8).into(),
+ 2 => ((((payload[entry.offset] as u16) << 8)
+ + (payload[entry.offset + 1] as u16))
+ as i16)
+ .into(),
+ 3 => ((((payload[entry.offset] as u32) << 16)
+ + ((payload[entry.offset + 1] as u32) << 8)
+ + (payload[entry.offset + 2] as u32))
+ as i32)
+ .into(),
+ 4 => ((((payload[entry.offset] as u32) << 24)
+ + ((payload[entry.offset + 1] as u32) << 16)
+ + ((payload[entry.offset + 2] as u32) << 8)
+ + (payload[entry.offset + 3] as u32))
+ as i32)
+ .into(),
+ _ => panic!("Unhandled length: {}", entry.length),
+ },
+ "bit" => ((payload[entry.offset] & (1 << entry.base.unwrap())) != 0).into(),
_ => {
panic!("Unhandled");
}