Skip to content

Commit

Permalink
add "prioritize_live_data" option
Browse files Browse the repository at this point in the history
  • Loading branch information
amokfa committed Nov 28, 2024
1 parent caf55a8 commit 52d0d9a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion tools/utils/src/push_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ struct ShadowPayload {

#[tokio::main]
async fn main() {
let stream = std::env::args().nth(1).unwrap_or_else(|| "c2c_can".to_string());
let port = std::env::args().nth(2).unwrap_or_else(|| "127.0.0.1:5050".to_string());
let mut framed = Framed::new(TcpStream::connect(port).await.unwrap(), LinesCodec::new());
let mut idx = 0;
loop {
idx += 1;
// calculate and send consecutive squares
let data = ShadowPayload {
stream: "c2c_can".to_string(),
stream: stream.clone(),
sequence: idx,
timestamp: SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_millis() as u64,
can_id: idx % 1024,
Expand Down
3 changes: 2 additions & 1 deletion uplink/src/base/serializer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ impl<C: MqttClient> Serializer<C> {

let mut packet_to_write = Some(publish);
let (storage, live_data, live_data_version) = self.sorted_storages.get_mut(&sk).unwrap();
if false {
if self.config.prioritize_live_data {
std::mem::swap(&mut packet_to_write, live_data);
*live_data_version = self.live_data_counter;
}
Expand Down Expand Up @@ -637,6 +637,7 @@ pub fn construct_publish(
#[cfg(test)]
pub mod tests {
use std::path::PathBuf;
use bytes::Bytes;
use flume::bounded;
use serde::{Deserialize, Serialize};
use serde_json::Value;
Expand Down
2 changes: 2 additions & 0 deletions uplink/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,4 +301,6 @@ pub struct Config {
#[cfg(target_os = "android")]
pub logging: Option<LogcatConfig>,
pub precondition_checks: Option<PreconditionCheckerConfig>,
#[serde(default)]
pub prioritize_live_data: bool,
}

0 comments on commit 52d0d9a

Please sign in to comment.