Skip to content

Commit

Permalink
Merge pull request #212 from makers-for-life/telemetry-add-systick-to…
Browse files Browse the repository at this point in the history
…-machine-state

Add systick to machine state snapshot
  • Loading branch information
dsferruzza committed Apr 27, 2020
2 parents cc888d9 + 387fd4e commit fc1e248
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/software/firmware/srcs/telemetry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,13 @@ void sendMachineStateSnapshot(uint32_t cycleValue,

Serial6.print("\t");

byte systick[8]; // 64 bits
uint64_t systickValue = (millis() * 1000) + (micros() % 1000);
toBytes64(systick, systickValue);
Serial6.write(systick, 8);

Serial6.print("\t");

byte cycle[4]; // 32 bits
toBytes32(cycle, cycleValue);
Serial6.write(cycle, 4);
Expand Down
7 changes: 7 additions & 0 deletions src/software/telemetry/src/parsers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ named!(
>> device_id2: be_u32
>> device_id3: be_u32
>> sep
>> systick: be_u64
>> sep
>> cycle: be_u32
>> sep
>> peak_command: be_u8
Expand All @@ -189,6 +191,7 @@ named!(
>> (TelemetryMessage::MachineStateSnapshot(MachineStateSnapshot {
version: software_version.to_string(),
device_id: format!("{}-{}-{}", device_id1, device_id2, device_id3),
systick,
cycle,
peak_command,
plateau_command,
Expand Down Expand Up @@ -464,6 +467,7 @@ mod tests {
device_id1 in (0u32..),
device_id2 in (0u32..),
device_id3 in (0u32..),
systick in (0u64..),
cycle in (0u32..),
peak_command in (0u8..),
plateau_command in (0u8..),
Expand All @@ -477,6 +481,7 @@ mod tests {
let msg = MachineStateSnapshot {
version,
device_id: format!("{}-{}-{}", device_id1, device_id2, device_id3),
systick,
cycle,
peak_command,
plateau_command,
Expand All @@ -497,6 +502,8 @@ mod tests {
&device_id2.to_be_bytes(),
&device_id3.to_be_bytes(),
b"\t",
&msg.systick.to_be_bytes(),
b"\t",
&msg.cycle.to_be_bytes(),
b"\t",
&[msg.peak_command],
Expand Down
1 change: 1 addition & 0 deletions src/software/telemetry/src/structures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ pub struct DataSnapshot {
pub struct MachineStateSnapshot {
pub version: String,
pub device_id: String,
pub systick: u64,
pub cycle: u32,
pub peak_command: u8,
pub plateau_command: u8,
Expand Down

0 comments on commit fc1e248

Please sign in to comment.