Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add systick to machine state snapshot #212

Merged
merged 1 commit into from
Apr 27, 2020
Merged
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
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