From 6bfee4df3776f87db3b0dbc569b17c42f2f9308b Mon Sep 17 00:00:00 2001 From: ihong4 <92641118+ihong4@users.noreply.github.com> Date: Tue, 24 Oct 2023 19:06:11 -0400 Subject: [PATCH 01/41] Add files via upload pub and sub mqtt client --- src/main.rs | 177 ++++++++++++++++++++++++++++------------------------ 1 file changed, 94 insertions(+), 83 deletions(-) diff --git a/src/main.rs b/src/main.rs index b3ca34b..5bef65d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,91 +1,102 @@ -extern crate systemstat; -use chrono::DateTime; -use chrono::TimeZone; -use chrono::Utc; -use socketcan::*; -use std::env; -use std::io::Write; -use std::os::unix::net::UnixStream; -use std::process::Command; -use std::sync::mpsc::channel; -use std::thread; -mod data; -mod decode_data; -mod master_mapping; -mod message; +use std::{ + env, + process, + thread, + time::Duration +}; + +extern crate paho_mqtt as mqtt; + +const DFLT_BROKER:&str = "tcp://localhost:1883"; +const DFLT_CLIENT:&str = "rust_subscribe"; +const DFLT_TOPICS:&[&str] = &["/mpu", "/tpu"]; +// The qos list that match topics above. +const DFLT_QOS:&[i32] = &[0, 1]; + +// Reconnect to the broker when connection is lost. +fn try_reconnect(cli: &mqtt::Client) -> bool +{ + println!("Connection lost. Waiting to retry connection"); + for _ in 0..12 { + thread::sleep(Duration::from_millis(5000)); + if cli.reconnect().is_ok() { + println!("Successfully reconnected"); + return true; + } + } + println!("Unable to reconnect after several attempts."); + false +} + +// Subscribes to multiple topics. +fn subscribe_topics(cli: &mqtt::Client) { + if let Err(e) = cli.subscribe_many(DFLT_TOPICS, DFLT_QOS) { + println!("Error subscribes topics: {:?}", e); + process::exit(1); + } +} fn main() { - let args: Vec = env::args().collect(); - let default = "tmp/ipc.sock".to_owned(); - let ipc_path = args.get(0).unwrap_or(&default); + let host = env::args().nth(1).unwrap_or_else(|| + DFLT_BROKER.to_string() + ); - let mut down_command = Command::new("sudo") - .arg("ifconfig") - .arg("can0") - .arg("down") - .spawn() - .expect("down command did not work"); - down_command - .wait() - .expect("Fail while waiting for down command"); - let mut bit_rate_commmand = Command::new("sudo") - .arg("ip") - .arg("link") - .arg("set") - .arg("can0") - .arg("type") - .arg("can") - .arg("bitrate") - .arg("1000000") - .spawn() - .expect("bit rate command did not work"); - bit_rate_commmand - .wait() - .expect("Fail while waiting for bit rate"); - let mut up_command = Command::new("sudo") - .arg("ifconfig") - .arg("can0") - .arg("up") - .spawn() - .expect("up command did nto work"); - up_command - .wait() - .expect("Fail while waiting for up command"); + // Define the set of options for the create. + // Use an ID for a persistent session. + let create_opts = mqtt::CreateOptionsBuilder::new() + .server_uri(host) + .client_id(DFLT_CLIENT.to_string()) + .finalize(); - let mut stream = UnixStream::connect(ipc_path).unwrap(); - let (tx, rx) = channel(); - //open can socket channel at name can0 - const CAN_CHANNEL: &str = "can0"; - let socket = CANSocket::open(&CAN_CHANNEL); - let socket = match socket { - Ok(socket) => socket, - Err(err) => { - println!("Failed to open CAN socket: {}", err); - return; + // Create a client. + let mut cli = mqtt::Client::new(create_opts).unwrap_or_else(|err| { + println!("Error creating the client: {:?}", err); + process::exit(1); + }); + + // Initialize the consumer before connecting. + let rx = cli.start_consuming(); + + // Define the set of options for the connection. + let lwt = mqtt::MessageBuilder::new() + .topic("test") + .payload("Consumer lost connection") + .finalize(); + let conn_opts = mqtt::ConnectOptionsBuilder::new() + .keep_alive_interval(Duration::from_secs(20)) + .clean_session(false) + .will_message(lwt) + .finalize(); + + // Connect and wait for it to complete or fail. + if let Err(e) = cli.connect(conn_opts) { + println!("Unable to connect:\n\t{:?}", e); + process::exit(1); + } + + // Subscribe topics. + subscribe_topics(&cli); + + println!("Processing requests..."); + for msg in rx.iter() { + if let Some(msg) = msg { + println!("{}", msg); } - }; - thread::spawn(move || loop { - let msg = socket.read_frame().unwrap(); - let date: DateTime = Utc.with_ymd_and_hms(2020, 1, 1, 0, 0, 0).unwrap(); - let data = msg.data(); - let message = message::Message::new(&date, &msg.id(), &data); - let decoded_data = message.decode(); - for (_i, data) in decoded_data.iter().enumerate() { - let message = format!( - "{{ - index:{}, - value:{} - }}", - data.id.to_string(), - data.value.to_string() - ); - println!("Sending message: {}", message); - tx.send(message).unwrap(); + else if !cli.is_connected() { + if try_reconnect(&cli) { + println!("Resubscribe topics..."); + subscribe_topics(&cli); + } else { + break; + } } - }); - loop { - let _ = rx - .try_recv() - .map(|reply| stream.write_all(reply.as_bytes())); } + + // If still connected, then disconnect now. + if cli.is_connected() { + println!("Disconnecting"); + cli.unsubscribe_many(DFLT_TOPICS).unwrap(); + cli.disconnect(None).unwrap(); + } + println!("Exiting"); } From 8a7877e1e0dd1e0078de35599b08ad11d4c92525 Mon Sep 17 00:00:00 2001 From: Peyton-McKee Date: Wed, 29 Nov 2023 18:16:31 -0500 Subject: [PATCH 02/41] #22 Refactoring of IPC and Mqtt --- .vscode/settings.json | 5 +- Cargo.lock | 252 ++++++++++++++++++++++++++++++++++++++--- Cargo.toml | 3 +- src/client.rs | 16 +++ src/decode_data.rs | 6 +- src/decode_statuses.rs | 2 + src/lib.rs | 7 ++ src/main.rs | 167 ++++++++++++++------------- src/master_mapping.rs | 1 - src/message.rs | 8 +- src/mqtt.rs | 138 ++++++++++++++++++++++ src/socket.rs | 63 +++++++++++ 12 files changed, 555 insertions(+), 113 deletions(-) create mode 100644 src/client.rs create mode 100644 src/lib.rs create mode 100644 src/mqtt.rs create mode 100644 src/socket.rs diff --git a/.vscode/settings.json b/.vscode/settings.json index 60bf230..e397228 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,6 @@ { - "editor.defaultFormatter": "rust-lang.rust-analyzer" + "editor.defaultFormatter": "rust-lang.rust-analyzer", + "rust-analyzer.linkedProjects": [ + "./Cargo.toml" + ] } diff --git a/Cargo.lock b/Cargo.lock index 19d32cf..82c9333 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -20,6 +20,17 @@ dependencies = [ "num-traits", ] +[[package]] +name = "async-channel" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35" +dependencies = [ + "concurrent-queue", + "event-listener", + "futures-core", +] + [[package]] name = "autocfg" version = "1.1.0" @@ -50,6 +61,20 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38fcc2979eff34a4b84e1cf9a1e3da42a7d44b3b690a40cdcb23e3d556cfb2e5" +[[package]] +name = "calypso" +version = "0.1.0" +dependencies = [ + "chrono", + "matrixmultiply", + "nalgebra", + "paho-mqtt", + "rayon", + "socketcan", + "systemstat", + "transpose", +] + [[package]] name = "cc" version = "1.0.79" @@ -77,6 +102,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "cmake" +version = "0.1.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31c789563b815f77f4250caee12365734369f942439b7defd71e18a48197130" +dependencies = [ + "cc", +] + [[package]] name = "codespan-reporting" version = "0.11.1" @@ -87,6 +121,15 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "concurrent-queue" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f057a694a54f12365049b0958a1685bb52d567f5593b355fbf685838e873d400" +dependencies = [ + "crossbeam-utils", +] + [[package]] name = "core-foundation-sys" version = "0.8.4" @@ -186,6 +229,107 @@ version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" +[[package]] +name = "event-listener" +version = "2.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" + +[[package]] +name = "futures" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da0290714b38af9b4a7b094b8a37086d1b4e61f2df9122c3cad2577669145335" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff4dd66668b557604244583e3e1e1eada8c5c2e96a6d0d6653ede395b78bbacb" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c" + +[[package]] +name = "futures-executor" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f4fb8693db0cf099eadcca0efe2a5a22e4550f98ed16aba6c48700da29597bc" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8bf34a163b5c4c52d0478a4d757da8fb65cabef42ba90515efee0f6f9fa45aaa" + +[[package]] +name = "futures-macro" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53b153fd91e4b0147f4aced87be237c98248656bb01050b96bf3ee89220a8ddb" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.15", +] + +[[package]] +name = "futures-sink" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e36d3378ee38c2a36ad710c5d30c2911d752cb941c00c72dbabfb786a7970817" + +[[package]] +name = "futures-task" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "efd193069b0ddadc69c46389b740bbccdd97203899b48d09c5f7969591d6bae2" + +[[package]] +name = "futures-timer" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" + +[[package]] +name = "futures-util" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + [[package]] name = "hermit-abi" version = "0.2.6" @@ -327,19 +471,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "ner_processing" -version = "0.1.0" -dependencies = [ - "chrono", - "matrixmultiply", - "nalgebra", - "rayon", - "socketcan", - "systemstat", - "transpose", -] - [[package]] name = "nix" version = "0.5.1" @@ -415,17 +546,73 @@ version = "1.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" +[[package]] +name = "openssl-sys" +version = "0.9.96" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3812c071ba60da8b5677cc12bcb1d42989a65553772897a7e0355545a819838f" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "paho-mqtt" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19e405de34b835fb6457d8b0169eda21949f855472b3e346556af9e29fac6eb2" +dependencies = [ + "async-channel", + "crossbeam-channel", + "futures", + "futures-timer", + "libc", + "log", + "paho-mqtt-sys", + "thiserror", +] + +[[package]] +name = "paho-mqtt-sys" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e482419d847af4ec43c07eed70f5f94f87dc712d267aecc91ab940944ab6bf4" +dependencies = [ + "cmake", + "openssl-sys", +] + [[package]] name = "paste" version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f746c4065a8fa3fe23974dd82f15431cc8d40779821001404d10d2e79ca7d79" +[[package]] +name = "pin-project-lite" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkg-config" +version = "0.3.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" + [[package]] name = "proc-macro2" -version = "1.0.56" +version = "1.0.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" +checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" dependencies = [ "unicode-ident", ] @@ -507,6 +694,15 @@ dependencies = [ "wide", ] +[[package]] +name = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +dependencies = [ + "autocfg", +] + [[package]] name = "socketcan" version = "1.7.0" @@ -571,6 +767,26 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "thiserror" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.15", +] + [[package]] name = "time" version = "0.1.45" @@ -632,6 +848,12 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + [[package]] name = "wasi" version = "0.10.0+wasi-snapshot-preview1" diff --git a/Cargo.toml b/Cargo.toml index 36b9d1b..84a4b36 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "ner_processing" +name = "calypso" version = "0.1.0" edition = "2021" @@ -14,3 +14,4 @@ socketcan = "1.7.0" transpose = "0.2.2" matrixmultiply = "0.3.3" nalgebra = "0.32.2" +paho-mqtt = "0.12.3" diff --git a/src/client.rs b/src/client.rs new file mode 100644 index 0000000..3cb8079 --- /dev/null +++ b/src/client.rs @@ -0,0 +1,16 @@ +use crate::data::Data; + +/** + * Cummulative trait for structs that are able to connect to a server and publish data to it. + */ +pub trait Client { + /** + * Connects to the server at the given path. + */ + fn connect(&mut self, path: &str) -> (); + + /** + * Publishes the given data to the server. + */ + fn publish(&mut self, data: &Data) -> (); +} diff --git a/src/decode_data.rs b/src/decode_data.rs index 998eb5e..5e83af5 100644 --- a/src/decode_data.rs +++ b/src/decode_data.rs @@ -1,13 +1,13 @@ // This file specifies methods to decode messages into the many pieces of data they contain. -use nalgebra::convert; +// use nalgebra::convert; use nalgebra::{Matrix3, Vector3}; use std::collections::HashMap; use super::data::FormatData as fd; use super::data::ProcessData as pd; -pub fn decode_mock(data: &[u8]) -> HashMap { +pub fn decode_mock(_data: &[u8]) -> HashMap { let mut result = HashMap::new(); result.insert(0, 0.0); result @@ -101,7 +101,7 @@ pub fn decode7(data: &[u8]) -> HashMap { } // TODO: Fill this method out (complicated with bit shifts) -pub fn decode8(data: &[u8]) -> HashMap { +pub fn decode8(_data: &[u8]) -> HashMap { let mut result = HashMap::new(); result.insert(30, 0.0); result.insert(31, 0.0); diff --git a/src/decode_statuses.rs b/src/decode_statuses.rs index de2a88f..3be9e0d 100644 --- a/src/decode_statuses.rs +++ b/src/decode_statuses.rs @@ -1,5 +1,7 @@ use std::collections::HashMap; +use crate::data::Data; + // Mapping from data IDs to the status bits they encode // Each data ID contains a hash map with keys that are bit names and values that are the indexes const STATUS_MAP: HashMap> = [(6, HashMap::new()), // Failsafe Statuses diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..252a266 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,7 @@ +pub mod client; +pub mod data; +pub mod decode_data; +pub mod master_mapping; +pub mod message; +pub mod mqtt; +pub mod socket; diff --git a/src/main.rs b/src/main.rs index 5bef65d..992876b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,102 +1,99 @@ use std::{ env, - process, + process::{self, Command}, thread, - time::Duration }; -extern crate paho_mqtt as mqtt; +use calypso::{client::Client, message::Message, mqtt::MqttClient, socket::IPCConnection}; +use chrono::{DateTime, TimeZone, Utc}; +use socketcan::CANSocket; -const DFLT_BROKER:&str = "tcp://localhost:1883"; -const DFLT_CLIENT:&str = "rust_subscribe"; -const DFLT_TOPICS:&[&str] = &["/mpu", "/tpu"]; -// The qos list that match topics above. -const DFLT_QOS:&[i32] = &[0, 1]; - -// Reconnect to the broker when connection is lost. -fn try_reconnect(cli: &mqtt::Client) -> bool -{ - println!("Connection lost. Waiting to retry connection"); - for _ in 0..12 { - thread::sleep(Duration::from_millis(5000)); - if cli.reconnect().is_ok() { - println!("Successfully reconnected"); - return true; - } - } - println!("Unable to reconnect after several attempts."); - false +fn configure_can() { + let mut down_command = Command::new("sudo") + .arg("ifconfig") + .arg("can0") + .arg("down") + .spawn() + .expect("down command did not work"); + down_command + .wait() + .expect("Fail while waiting for down command"); + let mut bit_rate_commmand = Command::new("sudo") + .arg("ip") + .arg("link") + .arg("set") + .arg("can0") + .arg("type") + .arg("can") + .arg("bitrate") + .arg("1000000") + .spawn() + .expect("bit rate command did not work"); + bit_rate_commmand + .wait() + .expect("Fail while waiting for bit rate"); + let mut up_command = Command::new("sudo") + .arg("ifconfig") + .arg("can0") + .arg("up") + .spawn() + .expect("up command did nto work"); + up_command + .wait() + .expect("Fail while waiting for up command"); } -// Subscribes to multiple topics. -fn subscribe_topics(cli: &mqtt::Client) { - if let Err(e) = cli.subscribe_many(DFLT_TOPICS, DFLT_QOS) { - println!("Error subscribes topics: {:?}", e); - process::exit(1); - } -} - -fn main() { - let host = env::args().nth(1).unwrap_or_else(|| - DFLT_BROKER.to_string() - ); - - // Define the set of options for the create. - // Use an ID for a persistent session. - let create_opts = mqtt::CreateOptionsBuilder::new() - .server_uri(host) - .client_id(DFLT_CLIENT.to_string()) - .finalize(); - - // Create a client. - let mut cli = mqtt::Client::new(create_opts).unwrap_or_else(|err| { - println!("Error creating the client: {:?}", err); - process::exit(1); +fn read_can(mut publisher: Box) -> () { + //open can socket channel at name can0 + const CAN_CHANNEL: &str = "can0"; + let socket = CANSocket::open(&CAN_CHANNEL); + let socket = match socket { + Ok(socket) => socket, + Err(err) => { + println!("Failed to open CAN socket: {}", err); + return; + } + }; + thread::spawn(move || loop { + let msg = socket.read_frame().unwrap(); + let date: DateTime = Utc.with_ymd_and_hms(2020, 1, 1, 0, 0, 0).unwrap(); + let data = msg.data(); + let message = Message::new(&date, &msg.id(), &data); + let decoded_data = message.decode(); + for (_i, data) in decoded_data.iter().enumerate() { + publisher.publish(data) + } }); +} - // Initialize the consumer before connecting. - let rx = cli.start_consuming(); - - // Define the set of options for the connection. - let lwt = mqtt::MessageBuilder::new() - .topic("test") - .payload("Consumer lost connection") - .finalize(); - let conn_opts = mqtt::ConnectOptionsBuilder::new() - .keep_alive_interval(Duration::from_secs(20)) - .clean_session(false) - .will_message(lwt) - .finalize(); - - // Connect and wait for it to complete or fail. - if let Err(e) = cli.connect(conn_opts) { - println!("Unable to connect:\n\t{:?}", e); +fn parse_args() -> (String, Box) { + let args: Vec = env::args().collect(); + if args.len() < 2 { + println!("Please provide a client type"); process::exit(1); } + let client_type = &args[1]; + let path = &args[2]; - // Subscribe topics. - subscribe_topics(&cli); - - println!("Processing requests..."); - for msg in rx.iter() { - if let Some(msg) = msg { - println!("{}", msg); - } - else if !cli.is_connected() { - if try_reconnect(&cli) { - println!("Resubscribe topics..."); - subscribe_topics(&cli); - } else { - break; - } + match client_type.as_str() { + "mqtt" => ( + String::from(path), + Box::new(MqttClient::new()) as Box, + ), + "ipc" => ( + String::from(path), + Box::new(IPCConnection::new()) as Box, + ), + _ => { + println!("Please provide a valid client type"); + process::exit(1); } } +} - // If still connected, then disconnect now. - if cli.is_connected() { - println!("Disconnecting"); - cli.unsubscribe_many(DFLT_TOPICS).unwrap(); - cli.disconnect(None).unwrap(); - } - println!("Exiting"); +fn main() { + configure_can(); + let (path, mut client) = parse_args(); + client.connect(&path); + read_can(client); } diff --git a/src/master_mapping.rs b/src/master_mapping.rs index 5441bbe..59a3fa6 100644 --- a/src/master_mapping.rs +++ b/src/master_mapping.rs @@ -242,6 +242,5 @@ pub fn get_data_info(id: u8) -> DataInfo { 145 => return DataInfo::new("Precharge State".to_string(), "".to_string()), 146 => return DataInfo::new("BMS Prefault Status".to_string(), "".to_string()), _ => return DataInfo::new("".to_string(), "".to_string()), - } } diff --git a/src/message.rs b/src/message.rs index ecbfdb4..f7229a9 100644 --- a/src/message.rs +++ b/src/message.rs @@ -1,4 +1,3 @@ - use chrono::prelude::*; use super::data::Data; @@ -23,12 +22,7 @@ impl<'a> Message<'a> { self.decode_message(&self.timestamp, &self.id, &self.data) } - fn decode_message( - &self, - timestamp: &DateTime, - id: &u32, - data: &[u8], - ) -> Vec { + fn decode_message(&self, timestamp: &DateTime, id: &u32, data: &[u8]) -> Vec { let decoder = get_message_info(id).decoder; println!("ATTEMPTING TO CUCK: {}", id); let mut decoded_data: Vec = Vec::new(); diff --git a/src/mqtt.rs b/src/mqtt.rs new file mode 100644 index 0000000..380f8da --- /dev/null +++ b/src/mqtt.rs @@ -0,0 +1,138 @@ +extern crate paho_mqtt as mqtt; +use mqtt::ServerResponse; +use std::process; +use std::time::Duration; + +use crate::client::Client; +use crate::data::Data; + +pub const DFLT_BROKER: &str = "mqtt://localhost:1883"; +const DFLT_CLIENT: &str = "rust_subscribe"; +// The qos list that match topics above. + +/** + * MqttClient is a wrapper around the paho_mqtt::Client. + */ +pub struct MqttClient { + client: Option, +} + +/** + * Implement the Publish trait for MqttClient. + */ +impl Client for MqttClient { + /** + * Publishes the given data to the broker. + * param data: The data object to format and send. + */ + fn publish(&mut self, data: &Data) { + let topic = format!("Calypso/{}", data.id); + let payload = data.value.to_string(); + + /* If the client is initialized, publish the data. */ + if let Some(client) = &self.client { + let msg = mqtt::MessageBuilder::new() + .topic(topic) + .payload(payload) + .finalize(); + client.publish(msg).unwrap(); + return; + } else { + println!("Client not initialized, please set host first and connect") + } + } + + /** + * Connects to the broker. + * Sets the host and then connects + */ + fn connect(&mut self, host: &str) { + self.set_host(&host.to_string()); + self.connect(); + } +} + +impl MqttClient { + /** + * Creates a new MqttClient. + */ + pub fn new() -> MqttClient { + MqttClient { client: None } + } + /** + * Creates a new MqttClient with the given host name. + * param host_name: The host name of the broker. + */ + pub fn set_host(&mut self, host_name: &String) { + let create_options = mqtt::CreateOptionsBuilder::new() + .server_uri(host_name) + .client_id(DFLT_CLIENT.to_string()) + .finalize(); + self.client = Some(mqtt::Client::new(create_options).unwrap_or_else(|err| { + println!("Error creating the client: {:?}", err); + process::exit(1); + })); + } + + /** + * Connects to the broker. + * Sets the last will and testament. + */ + pub fn connect(&mut self) { + if let Some(client) = &self.client { + let lastwilltestatment = mqtt::MessageBuilder::new() + .topic("Calypso/Status") + .payload("Calypso is offline") + .finalize(); + let conn_opts = mqtt::ConnectOptionsBuilder::new() + .keep_alive_interval(Duration::from_secs(20)) + .clean_session(false) + .will_message(lastwilltestatment) + .finalize(); + if let Err(e) = client.connect(conn_opts) { + println!("Unable to connect:\n\t{:?}", e); + process::exit(1); + } + } else { + println!("Client not initialized, please set host first"); + } + } + + /** + * Check if the client is connected to the broker. + */ + pub fn is_connected(&self) -> bool { + if let Some(client) = &self.client { + client.is_connected() + } else { + println!("Client not initialized, please set host first"); + false + } + } + + /** + * Reconnect to the broker. + */ + pub fn reconnect(&mut self) -> Result { + if let Some(client) = &self.client { + client.reconnect() + } else { + Err(mqtt::Error::from(mqtt::Error::General( + "Client not initialized, please set host first", + ))) + } + } + + /** + * Disconnect from the broker. + */ + pub fn disconnect(&mut self) -> Result<(), mqtt::Error> { + if let Some(client) = &self.client { + client.disconnect(None) + } else { + Err(mqtt::Error::from(mqtt::Error::General( + "Client not initialized, please set host first", + ))) + } + } +} diff --git a/src/socket.rs b/src/socket.rs new file mode 100644 index 0000000..24b84eb --- /dev/null +++ b/src/socket.rs @@ -0,0 +1,63 @@ +use std::{ + os::unix::net::UnixStream, + sync::mpsc::{channel, Sender}, +}; + +use crate::{client::Client, data::Data}; + +/** + * IPCConnection is a wrapper around the IPC server. + */ +pub struct IPCConnection { + sender: Option>, +} + +/** + * Implements the Client trait for IPCConnection. + */ +impl Client for IPCConnection { + /** + * Sends the data over the IPC connection. + */ + fn publish(&mut self, data: &Data) { + self.send(data); + } + + /** + * Attempts to connect to the IPC at the given path + * param path: The path to connect to + */ + fn connect(&mut self, path: &str) { + let _stream: UnixStream = UnixStream::connect(path).unwrap(); + let (tx, _rx) = channel(); + self.sender = Some(tx); + } +} + +impl IPCConnection { + /** + * Creates a new IPCConnection. + */ + pub fn new() -> IPCConnection { + IPCConnection { sender: None } + } + /** + * Sends the given data to the IPC server. + * param data: The data object to format and send. + */ + pub fn send(&mut self, data: &Data) { + if let Some(sender) = &self.sender { + let message = format!( + "{{ + index:{}, + value:{} + }}", + data.id.to_string(), + data.value.to_string() + ); + sender.send(message).unwrap(); + } else { + println!("Sender not initialized, please connect first") + } + } +} From bd0fef791d65d324c0c5c5435935f390e61b80c7 Mon Sep 17 00:00:00 2001 From: Peyton-McKee Date: Wed, 29 Nov 2023 18:37:19 -0500 Subject: [PATCH 03/41] #22 Privatize Functions --- src/mqtt.rs | 10 +++++----- src/socket.rs | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/mqtt.rs b/src/mqtt.rs index 380f8da..84f1151 100644 --- a/src/mqtt.rs +++ b/src/mqtt.rs @@ -63,7 +63,7 @@ impl MqttClient { * Creates a new MqttClient with the given host name. * param host_name: The host name of the broker. */ - pub fn set_host(&mut self, host_name: &String) { + fn set_host(&mut self, host_name: &String) { let create_options = mqtt::CreateOptionsBuilder::new() .server_uri(host_name) .client_id(DFLT_CLIENT.to_string()) @@ -78,7 +78,7 @@ impl MqttClient { * Connects to the broker. * Sets the last will and testament. */ - pub fn connect(&mut self) { + fn connect(&mut self) { if let Some(client) = &self.client { let lastwilltestatment = mqtt::MessageBuilder::new() .topic("Calypso/Status") @@ -101,7 +101,7 @@ impl MqttClient { /** * Check if the client is connected to the broker. */ - pub fn is_connected(&self) -> bool { + fn _is_connected(&self) -> bool { if let Some(client) = &self.client { client.is_connected() } else { @@ -113,7 +113,7 @@ impl MqttClient { /** * Reconnect to the broker. */ - pub fn reconnect(&mut self) -> Result { + fn _reconnect(&mut self) -> Result { if let Some(client) = &self.client { client.reconnect() } else { @@ -126,7 +126,7 @@ impl MqttClient { /** * Disconnect from the broker. */ - pub fn disconnect(&mut self) -> Result<(), mqtt::Error> { + fn _disconnect(&mut self) -> Result<(), mqtt::Error> { if let Some(client) = &self.client { client.disconnect(None) } else { diff --git a/src/socket.rs b/src/socket.rs index 24b84eb..61a9067 100644 --- a/src/socket.rs +++ b/src/socket.rs @@ -45,7 +45,7 @@ impl IPCConnection { * Sends the given data to the IPC server. * param data: The data object to format and send. */ - pub fn send(&mut self, data: &Data) { + fn send(&mut self, data: &Data) { if let Some(sender) = &self.sender { let message = format!( "{{ From 31bfa8ebe1f032ad484552dfce443204ff03643c Mon Sep 17 00:00:00 2001 From: Peyton-McKee Date: Wed, 29 Nov 2023 18:45:13 -0500 Subject: [PATCH 04/41] #22 More Documentation --- src/data.rs | 23 +++++++++++++++++++---- src/main.rs | 13 ++++++++++--- src/message.rs | 22 +++++++++++++++++++++- 3 files changed, 50 insertions(+), 8 deletions(-) diff --git a/src/data.rs b/src/data.rs index e1b83cc..01e7899 100644 --- a/src/data.rs +++ b/src/data.rs @@ -1,13 +1,18 @@ use chrono::prelude::*; use std::fmt; +/** + * Wrapper Class for Data coming off the car + */ pub struct Data { - // Wrapper class for an individual piece of data. pub(crate) timestamp: DateTime, pub id: u8, pub value: f32, } +/** + * Implementation for the format of the data for debugging purposes + */ impl fmt::Display for Data { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { // Overrides the string representation of the class. @@ -16,7 +21,16 @@ impl fmt::Display for Data { } } +/** + * Implementation fo the Data Structs' methods + */ impl Data { + /** + * Constructor + * param timestamp: The time the data is collected + * param id: the id of the data + * param value: the value of the data + */ pub fn new(timestamp: DateTime, id: u8, value: f32) -> Self { Self { timestamp, @@ -26,9 +40,10 @@ impl Data { } } -pub struct ProcessData { - // Utility functions to process message data. -} +/** + * Class to contain the data processing functions + */ +pub struct ProcessData {} impl ProcessData { pub fn group_bytes(data_bytes: &[u8], group_length: usize) -> Vec> { diff --git a/src/main.rs b/src/main.rs index 992876b..be6c116 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,7 +15,7 @@ fn configure_can() { .arg("down") .spawn() .expect("down command did not work"); - down_command + down_command // Takes down any current can networks .wait() .expect("Fail while waiting for down command"); let mut bit_rate_commmand = Command::new("sudo") @@ -29,7 +29,7 @@ fn configure_can() { .arg("1000000") .spawn() .expect("bit rate command did not work"); - bit_rate_commmand + bit_rate_commmand //sets the bit rate of the can network .wait() .expect("Fail while waiting for bit rate"); let mut up_command = Command::new("sudo") @@ -38,11 +38,14 @@ fn configure_can() { .arg("up") .spawn() .expect("up command did nto work"); - up_command + up_command // Brings up the new can network .wait() .expect("Fail while waiting for up command"); } +/** + * Reads the can socket and publishes the data to the given client. + */ fn read_can(mut publisher: Box) -> () { //open can socket channel at name can0 const CAN_CHANNEL: &str = "can0"; @@ -66,6 +69,10 @@ fn read_can(mut publisher: Box) -> () { }); } +/** + * Parses the command line arguments. + * Returns the client type and the path to connect to. + */ fn parse_args() -> (String, Box) { let args: Vec = env::args().collect(); if args.len() < 2 { diff --git a/src/message.rs b/src/message.rs index f7229a9..bd434d2 100644 --- a/src/message.rs +++ b/src/message.rs @@ -3,14 +3,22 @@ use chrono::prelude::*; use super::data::Data; use super::master_mapping::get_message_info; +/** + * Wrapper class for an individual message. + */ pub struct Message<'a> { - // Wrapper class for an individual message. timestamp: DateTime, id: u32, data: &'a [u8], } +/** + * Implementation of Message. Static memory allocation. + */ impl<'a> Message<'a> { + /** + * Creates a new message with the given timestamp, id, and data. + */ pub fn new(timestamp: &DateTime, id: &u32, data: &'a [u8]) -> Self { Self { timestamp: *timestamp, @@ -18,10 +26,22 @@ impl<'a> Message<'a> { data, } } + + /** + * Decodes the message and returns a vector of Data objects. + */ pub fn decode(&self) -> Vec { self.decode_message(&self.timestamp, &self.id, &self.data) } + /** + * Decodes the message and returns a vector of Data objects. + * Achieves this by calling the decoder function associated with the message id. + * param timestamp: The timestamp of the message. + * param id: The id of the message. + * param data: The data of the message. + * return: A vector of Data objects. + */ fn decode_message(&self, timestamp: &DateTime, id: &u32, data: &[u8]) -> Vec { let decoder = get_message_info(id).decoder; println!("ATTEMPTING TO CUCK: {}", id); From 9d5702e0db15839c08dee5e9fe3786e8f6b14fec Mon Sep 17 00:00:00 2001 From: Peyton-McKee Date: Wed, 29 Nov 2023 18:53:07 -0500 Subject: [PATCH 05/41] #22 Even more documentation --- src/data.rs | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/src/data.rs b/src/data.rs index 01e7899..fbdd4ab 100644 --- a/src/data.rs +++ b/src/data.rs @@ -46,16 +46,20 @@ impl Data { pub struct ProcessData {} impl ProcessData { + /** + * Groups the given data bytes into lists of specified length. + */ pub fn group_bytes(data_bytes: &[u8], group_length: usize) -> Vec> { - // Splits the given data bytes into lists of specified length. data_bytes .chunks(group_length) .map(|chunk| chunk.to_vec()) .collect() } + /** + * Computes the twos complement of the given value. + */ pub fn twos_comp(val: u32, bits: usize) -> i64 { - // Computes the twos complement of the given value. if (val & (1 << (bits - 1))) != 0 { (val as i64) - (1 << bits) } else { @@ -63,52 +67,52 @@ impl ProcessData { } } + /** + * Transforms the given data bytes into a value in little endian. + * Little Endian byte order stores low order bytes first. + */ pub fn little_endian(data_bytes: &[u8], bits: usize) -> u32 { - // Transforms the given data bytes into a value in little endian. - // Little Endian byte order stores low order bytes first. let mut result: u32 = 0; for (i, byte) in data_bytes.iter().enumerate() { - // println!("Little End Byte: {}", byte); result |= (*byte as u32) << (bits * i); - // println!("Little End Result: {}", result) } result } + /** + * Transforms the given data bytes into a value in big endian. + * Big Endian byte order stores low order bytes last. + */ pub fn big_endian(bytes: &[u8], bits: usize) -> u32 { - // Transforms the given data bytes into a value in big endian. - // Big Endian byte order stores low order bytes last. let mut result: u32 = 0; for (i, byte) in bytes.iter().enumerate() { - // println!("Big End Byte: {}", byte); result |= (*byte as u32) << (bits * (bytes.len() - i - 1)); - // println!("Big End Result: {}", result); } result } + /** + * Decodes the given data bytes by grouping them into 2 byte chunks, + * transforming them into little endian, and then computing the twos complement. + */ pub fn default_decode(byte_vals: &[u8]) -> Vec { - // Default decode structure seen by a majority of the messages. - let grouped_vals = ProcessData::group_bytes(byte_vals, 2); - println!("CUCKED GROUP BYTES"); let parsed_vals: Vec = grouped_vals .iter() .map(|val| ProcessData::little_endian(val, 8)) .collect(); - println!("CUCKED LITTLE ENDIAN"); let decoded_vals: Vec = parsed_vals .iter() .map(|val| ProcessData::twos_comp(*val, 16)) .collect(); - println!("CUCKED TWOS COMP"); decoded_vals } } -pub struct FormatData { - // Utility functions to scale data values of a specific type. -} +/** + * Class to contain the data formatting functions + */ +pub struct FormatData {} impl FormatData { pub fn temperature(value: i64) -> f32 { From 66522b8c2b1393e860eb8662d31c071230bef475 Mon Sep 17 00:00:00 2001 From: Peyton-McKee Date: Wed, 29 Nov 2023 20:47:38 -0500 Subject: [PATCH 06/41] #22 And the debugging begins --- src/main.rs | 5 +++++ src/mqtt.rs | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index be6c116..236d1c6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -64,6 +64,7 @@ fn read_can(mut publisher: Box) -> () { let message = Message::new(&date, &msg.id(), &data); let decoded_data = message.decode(); for (_i, data) in decoded_data.iter().enumerate() { + println!("{} {} {}", data.timestamp, data.id, data.value); publisher.publish(data) } }); @@ -75,6 +76,7 @@ fn read_can(mut publisher: Box) -> () { */ fn parse_args() -> (String, Box) { let args: Vec = env::args().collect(); + println!("{:?}", args); if args.len() < 2 { println!("Please provide a client type"); process::exit(1); @@ -82,6 +84,9 @@ fn parse_args() -> (String, Box) { let client_type = &args[1]; let path = &args[2]; + println!("Client type: {}", client_type); + println!("Path: {}", path); + match client_type.as_str() { "mqtt" => ( String::from(path), diff --git a/src/mqtt.rs b/src/mqtt.rs index 84f1151..e23a323 100644 --- a/src/mqtt.rs +++ b/src/mqtt.rs @@ -8,7 +8,6 @@ use crate::data::Data; pub const DFLT_BROKER: &str = "mqtt://localhost:1883"; const DFLT_CLIENT: &str = "rust_subscribe"; -// The qos list that match topics above. /** * MqttClient is a wrapper around the paho_mqtt::Client. From 2c693e4cd504aadf9800ed71352d15b5f31e376e Mon Sep 17 00:00:00 2001 From: Peyton-McKee Date: Wed, 29 Nov 2023 20:48:45 -0500 Subject: [PATCH 07/41] #22 Debug Update --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 236d1c6..0ebb004 100644 --- a/src/main.rs +++ b/src/main.rs @@ -64,7 +64,7 @@ fn read_can(mut publisher: Box) -> () { let message = Message::new(&date, &msg.id(), &data); let decoded_data = message.decode(); for (_i, data) in decoded_data.iter().enumerate() { - println!("{} {} {}", data.timestamp, data.id, data.value); + println!("{}", data); publisher.publish(data) } }); From 1df62ce6a3f2ba3a1cd1cc33260bbab784cd347e Mon Sep 17 00:00:00 2001 From: Peyton-McKee Date: Wed, 29 Nov 2023 20:52:53 -0500 Subject: [PATCH 08/41] #22 Added Debug Statement --- src/main.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main.rs b/src/main.rs index 0ebb004..4c2a8b7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -57,6 +57,7 @@ fn read_can(mut publisher: Box) -> () { return; } }; + println!("Opened CAN socket"); thread::spawn(move || loop { let msg = socket.read_frame().unwrap(); let date: DateTime = Utc.with_ymd_and_hms(2020, 1, 1, 0, 0, 0).unwrap(); From 0165ef6af308553c04d8aaa56f16ad0ed3a393b5 Mon Sep 17 00:00:00 2001 From: Peyton-McKee Date: Wed, 29 Nov 2023 20:54:31 -0500 Subject: [PATCH 09/41] #22 Remove Thread --- src/main.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 4c2a8b7..4efc2d3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,6 @@ use std::{ env, process::{self, Command}, - thread, }; use calypso::{client::Client, message::Message, mqtt::MqttClient, socket::IPCConnection}; @@ -58,7 +57,8 @@ fn read_can(mut publisher: Box) -> () { } }; println!("Opened CAN socket"); - thread::spawn(move || loop { + loop { + println!("Reading frame"); let msg = socket.read_frame().unwrap(); let date: DateTime = Utc.with_ymd_and_hms(2020, 1, 1, 0, 0, 0).unwrap(); let data = msg.data(); @@ -68,7 +68,7 @@ fn read_can(mut publisher: Box) -> () { println!("{}", data); publisher.publish(data) } - }); + } } /** From dae9ef11057282891216bb9c34c3a9b88f101f7d Mon Sep 17 00:00:00 2001 From: Peyton-McKee Date: Wed, 29 Nov 2023 20:57:29 -0500 Subject: [PATCH 10/41] #22 Unwrap or Debug --- src/socket.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/socket.rs b/src/socket.rs index 61a9067..3b9a850 100644 --- a/src/socket.rs +++ b/src/socket.rs @@ -55,7 +55,9 @@ impl IPCConnection { data.id.to_string(), data.value.to_string() ); - sender.send(message).unwrap(); + sender + .send(message) + .unwrap_or(println!("Failed to send data")); } else { println!("Sender not initialized, please connect first") } From cf57bcd1ee9da35e27e7cfe4f055743ac8b396b9 Mon Sep 17 00:00:00 2001 From: Peyton-McKee Date: Wed, 29 Nov 2023 21:05:29 -0500 Subject: [PATCH 11/41] #22 Edit Error Message --- src/socket.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/socket.rs b/src/socket.rs index 3b9a850..7400a88 100644 --- a/src/socket.rs +++ b/src/socket.rs @@ -57,7 +57,7 @@ impl IPCConnection { ); sender .send(message) - .unwrap_or(println!("Failed to send data")); + .unwrap_or(println!("Failed to send message, is NERO running?")); } else { println!("Sender not initialized, please connect first") } From 04a500462352c0541cf52376b8ac24ef44bec572 Mon Sep 17 00:00:00 2001 From: Peyton-McKee Date: Wed, 29 Nov 2023 21:29:59 -0500 Subject: [PATCH 12/41] #22 Use Stream Instead of Channel --- src/socket.rs | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/src/socket.rs b/src/socket.rs index 7400a88..c62f5d2 100644 --- a/src/socket.rs +++ b/src/socket.rs @@ -1,7 +1,4 @@ -use std::{ - os::unix::net::UnixStream, - sync::mpsc::{channel, Sender}, -}; +use std::{io::Write, os::unix::net::UnixStream}; use crate::{client::Client, data::Data}; @@ -9,7 +6,7 @@ use crate::{client::Client, data::Data}; * IPCConnection is a wrapper around the IPC server. */ pub struct IPCConnection { - sender: Option>, + stream: Option, } /** @@ -28,9 +25,14 @@ impl Client for IPCConnection { * param path: The path to connect to */ fn connect(&mut self, path: &str) { - let _stream: UnixStream = UnixStream::connect(path).unwrap(); - let (tx, _rx) = channel(); - self.sender = Some(tx); + let stream: UnixStream = match UnixStream::connect(path) { + Ok(stream) => stream, + Err(_) => { + println!("Failed to connect to IPC server, is NERO running?"); + return; + } + }; + self.stream = Some(stream); } } @@ -39,27 +41,28 @@ impl IPCConnection { * Creates a new IPCConnection. */ pub fn new() -> IPCConnection { - IPCConnection { sender: None } + IPCConnection { stream: None } } /** * Sends the given data to the IPC server. * param data: The data object to format and send. */ fn send(&mut self, data: &Data) { - if let Some(sender) = &self.sender { + if let Some(stream) = &mut self.stream { + let cloned_data = data.clone(); // Clone the data let message = format!( "{{ - index:{}, - value:{} - }}", - data.id.to_string(), - data.value.to_string() + index:{}, + value:{} + }}", + cloned_data.id.to_string(), + cloned_data.value.to_string() ); - sender - .send(message) - .unwrap_or(println!("Failed to send message, is NERO running?")); + stream + .write_all(message.as_bytes()) + .unwrap_or_else(|_| println!("Failed to send message, is NERO running?")); } else { - println!("Sender not initialized, please connect first") + println!("Sender not initialized, please connect first"); } } } From 13446716bb5700392d02e94e0ad3beed2c3d7e39 Mon Sep 17 00:00:00 2001 From: Peyton-McKee Date: Wed, 29 Nov 2023 21:46:58 -0500 Subject: [PATCH 13/41] #22 Format Without New Lines --- src/socket.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/socket.rs b/src/socket.rs index c62f5d2..e8ce150 100644 --- a/src/socket.rs +++ b/src/socket.rs @@ -51,10 +51,7 @@ impl IPCConnection { if let Some(stream) = &mut self.stream { let cloned_data = data.clone(); // Clone the data let message = format!( - "{{ - index:{}, - value:{} - }}", + "{{index:{},value:{}}}", cloned_data.id.to_string(), cloned_data.value.to_string() ); From eee350e2a4745c833cedf70631f1222a6da2f6f8 Mon Sep 17 00:00:00 2001 From: Peyton-McKee Date: Wed, 29 Nov 2023 21:56:55 -0500 Subject: [PATCH 14/41] #22 Remove Debug Statements --- src/main.rs | 3 --- src/message.rs | 1 - 2 files changed, 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 4efc2d3..74aa340 100644 --- a/src/main.rs +++ b/src/main.rs @@ -56,16 +56,13 @@ fn read_can(mut publisher: Box) -> () { return; } }; - println!("Opened CAN socket"); loop { - println!("Reading frame"); let msg = socket.read_frame().unwrap(); let date: DateTime = Utc.with_ymd_and_hms(2020, 1, 1, 0, 0, 0).unwrap(); let data = msg.data(); let message = Message::new(&date, &msg.id(), &data); let decoded_data = message.decode(); for (_i, data) in decoded_data.iter().enumerate() { - println!("{}", data); publisher.publish(data) } } diff --git a/src/message.rs b/src/message.rs index bd434d2..35aacec 100644 --- a/src/message.rs +++ b/src/message.rs @@ -44,7 +44,6 @@ impl<'a> Message<'a> { */ fn decode_message(&self, timestamp: &DateTime, id: &u32, data: &[u8]) -> Vec { let decoder = get_message_info(id).decoder; - println!("ATTEMPTING TO CUCK: {}", id); let mut decoded_data: Vec = Vec::new(); let result = decoder(data); for (data_id, value) in result { From 44d91544c9276d86f14340e35233b4cbffb2e1f7 Mon Sep 17 00:00:00 2001 From: Peyton-McKee Date: Thu, 30 Nov 2023 12:02:58 -0500 Subject: [PATCH 15/41] #22 Date.now --- src/main.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 74aa340..9796bf0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,7 +4,7 @@ use std::{ }; use calypso::{client::Client, message::Message, mqtt::MqttClient, socket::IPCConnection}; -use chrono::{DateTime, TimeZone, Utc}; +use chrono::{DateTime, Utc}; use socketcan::CANSocket; fn configure_can() { @@ -58,7 +58,7 @@ fn read_can(mut publisher: Box) -> () { }; loop { let msg = socket.read_frame().unwrap(); - let date: DateTime = Utc.with_ymd_and_hms(2020, 1, 1, 0, 0, 0).unwrap(); + let date: DateTime = Utc::now(); let data = msg.data(); let message = Message::new(&date, &msg.id(), &data); let decoded_data = message.decode(); @@ -101,6 +101,10 @@ fn parse_args() -> (String, Box) { } } +/** + * Main Function + * Configures the can network, retrieves the client based on the command line arguments, connects the client and then reads the can socket. + */ fn main() { configure_can(); let (path, mut client) = parse_args(); From 3822aac543a7bb365cafb52e64f02c302020a083 Mon Sep 17 00:00:00 2001 From: Peyton-McKee Date: Thu, 30 Nov 2023 12:53:28 -0500 Subject: [PATCH 16/41] #22 Mqtt Debug Statement --- src/main.rs | 2 ++ src/mqtt.rs | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 9796bf0..97f2121 100644 --- a/src/main.rs +++ b/src/main.rs @@ -104,6 +104,8 @@ fn parse_args() -> (String, Box) { /** * Main Function * Configures the can network, retrieves the client based on the command line arguments, connects the client and then reads the can socket. + * Sample Calls for IPC "/home/ner/Desktop/Calypso/target/release/calypso ipc /tmp/ipc.sock &" + * Sample Call for Mqtt "/home/ner/Desktop/Calypso/target/release/calypso mqtt localhost:1883 &" */ fn main() { configure_can(); diff --git a/src/mqtt.rs b/src/mqtt.rs index e23a323..57d4d38 100644 --- a/src/mqtt.rs +++ b/src/mqtt.rs @@ -7,7 +7,7 @@ use crate::client::Client; use crate::data::Data; pub const DFLT_BROKER: &str = "mqtt://localhost:1883"; -const DFLT_CLIENT: &str = "rust_subscribe"; +const DFLT_CLIENT: &str = "calypso"; /** * MqttClient is a wrapper around the paho_mqtt::Client. @@ -34,6 +34,7 @@ impl Client for MqttClient { .topic(topic) .payload(payload) .finalize(); + println!("Publishing message: {:?}", msg); client.publish(msg).unwrap(); return; } else { From 52b4846bb143ce27924ec8f0d994326b9592235f Mon Sep 17 00:00:00 2001 From: Peyton-McKee Date: Thu, 30 Nov 2023 12:57:47 -0500 Subject: [PATCH 17/41] #22 Change publishing topic --- src/mqtt.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mqtt.rs b/src/mqtt.rs index 57d4d38..12ad5f6 100644 --- a/src/mqtt.rs +++ b/src/mqtt.rs @@ -25,7 +25,7 @@ impl Client for MqttClient { * param data: The data object to format and send. */ fn publish(&mut self, data: &Data) { - let topic = format!("Calypso/{}", data.id); + let topic = format!("/"); let payload = data.value.to_string(); /* If the client is initialized, publish the data. */ From d3381ea17ed14770e4174ea28ad932767e62db3a Mon Sep 17 00:00:00 2001 From: Peyton-McKee Date: Thu, 30 Nov 2023 13:12:55 -0500 Subject: [PATCH 18/41] #22 Change Topic --- src/mqtt.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/mqtt.rs b/src/mqtt.rs index 12ad5f6..edd7e21 100644 --- a/src/mqtt.rs +++ b/src/mqtt.rs @@ -25,7 +25,7 @@ impl Client for MqttClient { * param data: The data object to format and send. */ fn publish(&mut self, data: &Data) { - let topic = format!("/"); + let topic = format!("Calypso"); let payload = data.value.to_string(); /* If the client is initialized, publish the data. */ @@ -34,7 +34,6 @@ impl Client for MqttClient { .topic(topic) .payload(payload) .finalize(); - println!("Publishing message: {:?}", msg); client.publish(msg).unwrap(); return; } else { From 5b37c48fc4e5af60609de0860105e6890cb925ff Mon Sep 17 00:00:00 2001 From: Peyton-McKee Date: Thu, 30 Nov 2023 14:15:49 -0500 Subject: [PATCH 19/41] #22 Add / --- src/mqtt.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mqtt.rs b/src/mqtt.rs index edd7e21..4689df6 100644 --- a/src/mqtt.rs +++ b/src/mqtt.rs @@ -25,7 +25,7 @@ impl Client for MqttClient { * param data: The data object to format and send. */ fn publish(&mut self, data: &Data) { - let topic = format!("Calypso"); + let topic = format!("/Calypso"); let payload = data.value.to_string(); /* If the client is initialized, publish the data. */ From 3d45af887f5bf54475a1920b6ad3c40b9ed5fffa Mon Sep 17 00:00:00 2001 From: Peyton-McKee Date: Thu, 30 Nov 2023 14:43:05 -0500 Subject: [PATCH 20/41] #22 Add 50ms throttle after publish --- src/mqtt.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mqtt.rs b/src/mqtt.rs index 4689df6..0c510b8 100644 --- a/src/mqtt.rs +++ b/src/mqtt.rs @@ -1,7 +1,7 @@ extern crate paho_mqtt as mqtt; use mqtt::ServerResponse; -use std::process; use std::time::Duration; +use std::{process, thread}; use crate::client::Client; use crate::data::Data; @@ -35,6 +35,7 @@ impl Client for MqttClient { .payload(payload) .finalize(); client.publish(msg).unwrap(); + thread::sleep(Duration::from_millis(50)); return; } else { println!("Client not initialized, please set host first and connect") From bd87a2e6dcc6a486b8698facbf911581d74cdf8c Mon Sep 17 00:00:00 2001 From: Peyton-McKee Date: Thu, 30 Nov 2023 14:48:59 -0500 Subject: [PATCH 21/41] #22 10ms buffer --- src/mqtt.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mqtt.rs b/src/mqtt.rs index 0c510b8..6aea418 100644 --- a/src/mqtt.rs +++ b/src/mqtt.rs @@ -35,7 +35,7 @@ impl Client for MqttClient { .payload(payload) .finalize(); client.publish(msg).unwrap(); - thread::sleep(Duration::from_millis(50)); + thread::sleep(Duration::from_millis(10)); return; } else { println!("Client not initialized, please set host first and connect") From ff2eb79419242e16df230b97b67e4091ea821f77 Mon Sep 17 00:00:00 2001 From: Peyton-McKee Date: Thu, 30 Nov 2023 14:51:38 -0500 Subject: [PATCH 22/41] #22 1ms throttle --- src/mqtt.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mqtt.rs b/src/mqtt.rs index 6aea418..5404201 100644 --- a/src/mqtt.rs +++ b/src/mqtt.rs @@ -35,7 +35,7 @@ impl Client for MqttClient { .payload(payload) .finalize(); client.publish(msg).unwrap(); - thread::sleep(Duration::from_millis(10)); + thread::sleep(Duration::from_millis(1)); return; } else { println!("Client not initialized, please set host first and connect") From ce931f20762affb9d46f7146d93ba48a16122c11 Mon Sep 17 00:00:00 2001 From: Peyton-McKee Date: Thu, 30 Nov 2023 14:54:29 -0500 Subject: [PATCH 23/41] #22 Remove Throttle --- src/mqtt.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mqtt.rs b/src/mqtt.rs index 5404201..294aa58 100644 --- a/src/mqtt.rs +++ b/src/mqtt.rs @@ -35,7 +35,7 @@ impl Client for MqttClient { .payload(payload) .finalize(); client.publish(msg).unwrap(); - thread::sleep(Duration::from_millis(1)); + // thread::sleep(Duration::from_millis(1)); return; } else { println!("Client not initialized, please set host first and connect") From 70aba7d12bb64379cd38f9c13c0bfffb6971aab7 Mon Sep 17 00:00:00 2001 From: Peyton-McKee Date: Thu, 30 Nov 2023 15:00:14 -0500 Subject: [PATCH 24/41] #22 Add 1ms throttle back --- src/mqtt.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mqtt.rs b/src/mqtt.rs index 294aa58..5404201 100644 --- a/src/mqtt.rs +++ b/src/mqtt.rs @@ -35,7 +35,7 @@ impl Client for MqttClient { .payload(payload) .finalize(); client.publish(msg).unwrap(); - // thread::sleep(Duration::from_millis(1)); + thread::sleep(Duration::from_millis(1)); return; } else { println!("Client not initialized, please set host first and connect") From 3fb705bee85bb2b8fd36ce2e97b68153eb91b6df Mon Sep 17 00:00:00 2001 From: Peyton-McKee Date: Thu, 30 Nov 2023 23:56:16 -0500 Subject: [PATCH 25/41] #22 Lots of General Code Cleanliness And Refactoring --- .github/workflows/rust-ci.yml | 27 + Cargo.lock | 2093 +++++++++++++++++++++++++++++++-- Cargo.toml | 1 + README.md | 34 + src/client.rs | 4 +- src/decode_data.rs | 22 +- src/decode_files.rs | 20 +- src/decode_statuses.rs | 314 ++--- src/main.rs | 14 +- src/master_mapping.rs | 403 ++++--- src/message.rs | 16 +- src/mqtt.rs | 41 +- src/socket.rs | 16 +- 13 files changed, 2494 insertions(+), 511 deletions(-) create mode 100644 .github/workflows/rust-ci.yml create mode 100644 README.md diff --git a/.github/workflows/rust-ci.yml b/.github/workflows/rust-ci.yml new file mode 100644 index 0000000..c1f2f67 --- /dev/null +++ b/.github/workflows/rust-ci.yml @@ -0,0 +1,27 @@ +name: Rust CI + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Setup Rust + uses: actions/checkout@v2 + - name: Install cargo-audit + run: cargo install cargo-audit + - name: Build + run: cargo build --verbose + - name: Test + run: cargo test --verbose + - name: Clippy + run: cargo clippy --verbose -- -D warnings + - name: Audit + run: cargo audit diff --git a/Cargo.lock b/Cargo.lock index 82c9333..7f3edce 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,24 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "aho-corasick" +version = "0.7.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" +dependencies = [ + "memchr", +] + +[[package]] +name = "aho-corasick" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +dependencies = [ + "memchr", +] + [[package]] name = "android_system_properties" version = "0.1.5" @@ -11,6 +29,15 @@ dependencies = [ "libc", ] +[[package]] +name = "ansi_term" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" +dependencies = [ + "winapi 0.3.9", +] + [[package]] name = "approx" version = "0.5.1" @@ -20,6 +47,16 @@ dependencies = [ "num-traits", ] +[[package]] +name = "async-broadcast" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c48ccdbf6ca6b121e0f586cbc0e73ae440e56c67c30fa0873b4e110d9c26d2b" +dependencies = [ + "event-listener 2.5.3", + "futures-core", +] + [[package]] name = "async-channel" version = "1.9.0" @@ -27,10 +64,188 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35" dependencies = [ "concurrent-queue", - "event-listener", + "event-listener 2.5.3", "futures-core", ] +[[package]] +name = "async-channel" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ca33f4bc4ed1babef42cad36cc1f51fa88be00420404e5b1e80ab1b18f7678c" +dependencies = [ + "concurrent-queue", + "event-listener 4.0.0", + "event-listener-strategy", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-executor" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17ae5ebefcc48e7452b4987947920dac9450be1110cadf34d1b8c116bdbaf97c" +dependencies = [ + "async-lock 3.1.2", + "async-task", + "concurrent-queue", + "fastrand 2.0.1", + "futures-lite 2.0.1", + "slab", +] + +[[package]] +name = "async-fs" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "279cf904654eeebfa37ac9bb1598880884924aab82e290aa65c9e77a0e142e06" +dependencies = [ + "async-lock 2.8.0", + "autocfg", + "blocking", + "futures-lite 1.13.0", +] + +[[package]] +name = "async-io" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fc5b45d93ef0529756f812ca52e44c221b35341892d3dcc34132ac02f3dd2af" +dependencies = [ + "async-lock 2.8.0", + "autocfg", + "cfg-if 1.0.0", + "concurrent-queue", + "futures-lite 1.13.0", + "log", + "parking", + "polling 2.8.0", + "rustix 0.37.27", + "slab", + "socket2", + "waker-fn", +] + +[[package]] +name = "async-io" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6d3b15875ba253d1110c740755e246537483f152fa334f91abd7fe84c88b3ff" +dependencies = [ + "async-lock 3.1.2", + "cfg-if 1.0.0", + "concurrent-queue", + "futures-io", + "futures-lite 2.0.1", + "parking", + "polling 3.3.1", + "rustix 0.38.26", + "slab", + "tracing", + "windows-sys 0.52.0", +] + +[[package]] +name = "async-lock" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "287272293e9d8c41773cec55e365490fe034813a2f172f502d6ddcf75b2f582b" +dependencies = [ + "event-listener 2.5.3", +] + +[[package]] +name = "async-lock" +version = "3.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dea8b3453dd7cc96711834b75400d671b73e3656975fa68d9f277163b7f7e316" +dependencies = [ + "event-listener 4.0.0", + "event-listener-strategy", + "pin-project-lite", +] + +[[package]] +name = "async-process" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea6438ba0a08d81529c69b36700fa2f95837bfe3e776ab39cde9c14d9149da88" +dependencies = [ + "async-io 1.13.0", + "async-lock 2.8.0", + "async-signal", + "blocking", + "cfg-if 1.0.0", + "event-listener 3.1.0", + "futures-lite 1.13.0", + "rustix 0.38.26", + "windows-sys 0.48.0", +] + +[[package]] +name = "async-recursion" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fd55a5ba1179988837d24ab4c7cc8ed6efdeff578ede0416b4225a5fca35bd0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "async-signal" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e47d90f65a225c4527103a8d747001fc56e375203592b25ad103e1ca13124c5" +dependencies = [ + "async-io 2.2.1", + "async-lock 2.8.0", + "atomic-waker", + "cfg-if 1.0.0", + "futures-core", + "futures-io", + "rustix 0.38.26", + "signal-hook-registry", + "slab", + "windows-sys 0.48.0", +] + +[[package]] +name = "async-task" +version = "4.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4eb2cdb97421e01129ccb49169d8279ed21e829929144f4a22a6e54ac549ca1" + +[[package]] +name = "async-trait" +version = "0.1.74" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a66537f1bb974b254c98ed142ff995236e81b9d0fe4db0575f46612cb15eb0f9" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi 0.1.19", + "libc", + "winapi 0.3.9", +] + [[package]] name = "autocfg" version = "1.1.0" @@ -43,6 +258,58 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8dead7461c1127cf637931a1e50934eb6eee8bff2f74433ac7909e9afcee04a3" +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" + +[[package]] +name = "block" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "blocking" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a37913e8dc4ddcc604f0c6d3bf2887c995153af3611de9e23c352b44c1b9118" +dependencies = [ + "async-channel 2.1.1", + "async-lock 3.1.2", + "async-task", + "fastrand 2.0.1", + "futures-io", + "futures-lite 2.0.1", + "piper", + "tracing", +] + +[[package]] +name = "bstr" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223" +dependencies = [ + "memchr", +] + [[package]] name = "bumpalo" version = "3.12.1" @@ -55,6 +322,12 @@ version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "17febce684fd15d89027105661fec94afb475cb995fbc59d2865198446ba2eea" +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + [[package]] name = "bytesize" version = "1.2.0" @@ -65,6 +338,7 @@ checksum = "38fcc2979eff34a4b84e1cf9a1e3da42a7d44b3b690a40cdcb23e3d556cfb2e5" name = "calypso" version = "0.1.0" dependencies = [ + "cargo-watch", "chrono", "matrixmultiply", "nalgebra", @@ -75,12 +349,67 @@ dependencies = [ "transpose", ] +[[package]] +name = "camino" +version = "1.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c59e92b5a388f549b863a7bea62612c09f24c8393560709a54558a9abdfb3b9c" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo-platform" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e34637b3140142bdf929fb439e8aa4ebad7651ebf7b1080b3930aa16ac1459ff" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo-watch" +version = "8.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "554cae2dad0147ef6cb36eb8b3347648a00762dc110af8d76d5c793fe9378f11" +dependencies = [ + "camino", + "cargo_metadata", + "clap", + "dotenvy", + "log", + "notify-rust", + "shell-escape", + "stderrlog", + "watchexec", +] + +[[package]] +name = "cargo_metadata" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7daec1a2a2129eeba1644b220b4647ec537b0b5d4bfd6876fcc5a540056b592" +dependencies = [ + "camino", + "cargo-platform", + "semver", + "serde", + "serde_json", + "thiserror", +] + [[package]] name = "cc" version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" +[[package]] +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" + [[package]] name = "cfg-if" version = "1.0.0" @@ -99,7 +428,35 @@ dependencies = [ "num-traits", "time 0.1.45", "wasm-bindgen", - "winapi", + "winapi 0.3.9", +] + +[[package]] +name = "clap" +version = "2.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" +dependencies = [ + "ansi_term", + "atty", + "bitflags 1.3.2", + "strsim 0.8.0", + "textwrap", + "unicode-width", + "vec_map", +] + +[[package]] +name = "clearscreen" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e55dadbdd203f69c0a107bc78fca6e47d605345610ee77dcf24203fdf510b317" +dependencies = [ + "nix 0.24.3", + "terminfo", + "thiserror", + "which", + "winapi 0.3.9", ] [[package]] @@ -122,118 +479,418 @@ dependencies = [ ] [[package]] -name = "concurrent-queue" -version = "2.3.0" +name = "command-group" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7a8a86f409b4a59df3a3e4bee2de0b83f1755fdd2a25e3a9684c396fc4bed2c" +dependencies = [ + "nix 0.22.3", + "winapi 0.3.9", +] + +[[package]] +name = "concurrent-queue" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f057a694a54f12365049b0958a1685bb52d567f5593b355fbf685838e873d400" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" + +[[package]] +name = "cpufeatures" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce420fe07aecd3e67c5f910618fe65e94158f6dcc0adf44e00d69ce2bdfe0fd0" +dependencies = [ + "libc", +] + +[[package]] +name = "crossbeam-channel" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" +dependencies = [ + "cfg-if 1.0.0", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" +dependencies = [ + "cfg-if 1.0.0", + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46bd5f3f85273295a9d14aedfb86f6aadbff6d8f5295c4a9edb08e819dcf5695" +dependencies = [ + "autocfg", + "cfg-if 1.0.0", + "crossbeam-utils", + "memoffset 0.8.0", + "scopeguard", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c063cd8cc95f5c377ed0d4b49a4b21f632396ff690e8470c29b3359b346984b" +dependencies = [ + "cfg-if 1.0.0", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "cxx" +version = "1.0.94" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f61f1b6389c3fe1c316bf8a4dccc90a38208354b330925bce1f74a6c4756eb93" +dependencies = [ + "cc", + "cxxbridge-flags", + "cxxbridge-macro", + "link-cplusplus", +] + +[[package]] +name = "cxx-build" +version = "1.0.94" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12cee708e8962df2aeb38f594aae5d827c022b6460ac71a7a3e2c3c2aae5a07b" +dependencies = [ + "cc", + "codespan-reporting", + "once_cell", + "proc-macro2", + "quote", + "scratch", + "syn 2.0.39", +] + +[[package]] +name = "cxxbridge-flags" +version = "1.0.94" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7944172ae7e4068c533afbb984114a56c46e9ccddda550499caa222902c7f7bb" + +[[package]] +name = "cxxbridge-macro" +version = "1.0.94" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2345488264226bf682893e25de0769f3360aac9957980ec49361b083ddaa5bc5" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "darling" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f2c43f534ea4b0b049015d00269734195e6d3f0f6635cb692251aca6f9f8b3c" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e91455b86830a1c21799d94524df0845183fa55bafd9aa137b01c7d1065fa36" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim 0.10.0", + "syn 1.0.109", +] + +[[package]] +name = "darling_macro" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29b5acf0dea37a7f66f7b25d2c5e93fd46f8f6968b1a5d7a3e02e97768afc95a" +dependencies = [ + "darling_core", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "derivative" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "derive_builder" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d13202debe11181040ae9063d739fa32cfcaaebe2275fe387703460ae2365b30" +dependencies = [ + "derive_builder_macro", +] + +[[package]] +name = "derive_builder_core" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66e616858f6187ed828df7c64a6d71720d83767a7f19740b2d1b6fe6327b36e5" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "derive_builder_macro" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58a94ace95092c5acb1e97a7e846b310cfbd499652f72297da7493f618a98d73" +dependencies = [ + "derive_builder_core", + "syn 1.0.109", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", +] + +[[package]] +name = "dirs" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-next" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" +dependencies = [ + "cfg-if 1.0.0", + "dirs-sys-next", +] + +[[package]] +name = "dirs-sys" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" +dependencies = [ + "libc", + "redox_users", + "winapi 0.3.9", +] + +[[package]] +name = "dirs-sys-next" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" +dependencies = [ + "libc", + "redox_users", + "winapi 0.3.9", +] + +[[package]] +name = "dotenvy" +version = "0.15.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" + +[[package]] +name = "either" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" + +[[package]] +name = "enumflags2" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5998b4f30320c9d93aed72f63af821bfdac50465b75428fce77b48ec482c3939" +dependencies = [ + "enumflags2_derive", + "serde", +] + +[[package]] +name = "enumflags2_derive" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f95e2801cd355d4a1a3e3953ce6ee5ae9603a5c833455343a8bfe3f44d418246" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "errno" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f057a694a54f12365049b0958a1685bb52d567f5593b355fbf685838e873d400" +checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" dependencies = [ - "crossbeam-utils", + "libc", + "windows-sys 0.52.0", ] [[package]] -name = "core-foundation-sys" -version = "0.8.4" +name = "event-listener" +version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" +checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" [[package]] -name = "crossbeam-channel" -version = "0.5.8" +name = "event-listener" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" +checksum = "d93877bcde0eb80ca09131a08d23f0a5c18a620b01db137dba666d18cd9b30c2" dependencies = [ - "cfg-if", - "crossbeam-utils", + "concurrent-queue", + "parking", + "pin-project-lite", ] [[package]] -name = "crossbeam-deque" -version = "0.8.3" +name = "event-listener" +version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" +checksum = "770d968249b5d99410d61f5bf89057f3199a077a04d087092f58e7d10692baae" dependencies = [ - "cfg-if", - "crossbeam-epoch", - "crossbeam-utils", + "concurrent-queue", + "parking", + "pin-project-lite", ] [[package]] -name = "crossbeam-epoch" -version = "0.9.14" +name = "event-listener-strategy" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46bd5f3f85273295a9d14aedfb86f6aadbff6d8f5295c4a9edb08e819dcf5695" +checksum = "958e4d70b6d5e81971bebec42271ec641e7ff4e170a6fa605f2b8a8b65cb97d3" dependencies = [ - "autocfg", - "cfg-if", - "crossbeam-utils", - "memoffset", - "scopeguard", + "event-listener 4.0.0", + "pin-project-lite", ] [[package]] -name = "crossbeam-utils" -version = "0.8.15" +name = "fastrand" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c063cd8cc95f5c377ed0d4b49a4b21f632396ff690e8470c29b3359b346984b" +checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" dependencies = [ - "cfg-if", + "instant", ] [[package]] -name = "cxx" -version = "1.0.94" +name = "fastrand" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f61f1b6389c3fe1c316bf8a4dccc90a38208354b330925bce1f74a6c4756eb93" -dependencies = [ - "cc", - "cxxbridge-flags", - "cxxbridge-macro", - "link-cplusplus", -] +checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" [[package]] -name = "cxx-build" -version = "1.0.94" +name = "filetime" +version = "0.2.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12cee708e8962df2aeb38f594aae5d827c022b6460ac71a7a3e2c3c2aae5a07b" +checksum = "d4029edd3e734da6fe05b6cd7bd2960760a616bd2ddd0d59a0124746d6272af0" dependencies = [ - "cc", - "codespan-reporting", - "once_cell", - "proc-macro2", - "quote", - "scratch", - "syn 2.0.15", + "cfg-if 1.0.0", + "libc", + "redox_syscall 0.3.5", + "windows-sys 0.48.0", ] [[package]] -name = "cxxbridge-flags" -version = "1.0.94" +name = "fnv" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7944172ae7e4068c533afbb984114a56c46e9ccddda550499caa222902c7f7bb" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] -name = "cxxbridge-macro" -version = "1.0.94" +name = "fsevent" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2345488264226bf682893e25de0769f3360aac9957980ec49361b083ddaa5bc5" +checksum = "5ab7d1bd1bd33cc98b0889831b72da23c0aa4df9cec7e0702f46ecea04b35db6" dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.15", + "bitflags 1.3.2", + "fsevent-sys", ] [[package]] -name = "either" -version = "1.8.1" +name = "fsevent-sys" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" +checksum = "f41b048a94555da0f42f1d632e2e19510084fb8e303b0daa2816e733fb3644a0" +dependencies = [ + "libc", +] [[package]] -name = "event-listener" -version = "2.5.3" +name = "fuchsia-zircon" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" +checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" +dependencies = [ + "bitflags 1.3.2", + "fuchsia-zircon-sys", +] + +[[package]] +name = "fuchsia-zircon-sys" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" [[package]] name = "futures" @@ -283,6 +940,35 @@ version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8bf34a163b5c4c52d0478a4d757da8fb65cabef42ba90515efee0f6f9fa45aaa" +[[package]] +name = "futures-lite" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49a9d51ce47660b1e808d3c990b4709f2f415d928835a17dfd16991515c46bce" +dependencies = [ + "fastrand 1.9.0", + "futures-core", + "futures-io", + "memchr", + "parking", + "pin-project-lite", + "waker-fn", +] + +[[package]] +name = "futures-lite" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3831c2651acb5177cbd83943f3d9c8912c5ad03c76afcc0e9511ba568ec5ebb" +dependencies = [ + "fastrand 2.0.1", + "futures-core", + "futures-io", + "memchr", + "parking", + "pin-project-lite", +] + [[package]] name = "futures-macro" version = "0.3.29" @@ -291,7 +977,7 @@ checksum = "53b153fd91e4b0147f4aced87be237c98248656bb01050b96bf3ee89220a8ddb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.39", ] [[package]] @@ -330,6 +1016,61 @@ dependencies = [ "slab", ] +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "wasi 0.11.0+wasi-snapshot-preview1", +] + +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + +[[package]] +name = "globset" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c152169ef1e421390738366d2f796655fec62621dabbd0fd476f905934061e4a" +dependencies = [ + "aho-corasick 0.7.20", + "bstr", + "fnv", + "log", + "regex", +] + +[[package]] +name = "hashbrown" +version = "0.14.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" + +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + [[package]] name = "hermit-abi" version = "0.2.6" @@ -339,12 +1080,33 @@ dependencies = [ "libc", ] +[[package]] +name = "hermit-abi" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" + [[package]] name = "hex" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6a22814455d41612f41161581c2883c0c6a1c41852729b17d5ed88f01e153aa" +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "home" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb" +dependencies = [ + "windows-sys 0.48.0", +] + [[package]] name = "iana-time-zone" version = "0.1.56" @@ -356,7 +1118,7 @@ dependencies = [ "iana-time-zone-haiku", "js-sys", "wasm-bindgen", - "windows", + "windows 0.48.0", ] [[package]] @@ -369,12 +1131,83 @@ dependencies = [ "cxx-build", ] +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "indexmap" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" +dependencies = [ + "equivalent", + "hashbrown", +] + +[[package]] +name = "inotify" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4816c66d2c8ae673df83366c18341538f234a26d65a9ecea5c348b453ac1d02f" +dependencies = [ + "bitflags 1.3.2", + "inotify-sys", + "libc", +] + +[[package]] +name = "inotify-sys" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e05c02b5e89bff3b946cedeca278abc628fe811e604f027c45a8aa3cf793d0eb" +dependencies = [ + "libc", +] + +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if 1.0.0", +] + +[[package]] +name = "io-lifetimes" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" +dependencies = [ + "hermit-abi 0.3.3", + "libc", + "windows-sys 0.48.0", +] + +[[package]] +name = "iovec" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" +dependencies = [ + "libc", +] + [[package]] name = "itertools" version = "0.4.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4a9b56eb56058f43dc66e58f40a214b2ccbc9f3df51861b63d51dec7b65bc3f" +[[package]] +name = "itoa" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" + [[package]] name = "js-sys" version = "0.3.61" @@ -384,17 +1217,44 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "kernel32-sys" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" +dependencies = [ + "winapi 0.2.8", + "winapi-build", +] + [[package]] name = "lazy_static" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +[[package]] +name = "lazycell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" + [[package]] name = "libc" -version = "0.2.142" +version = "0.2.150" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" + +[[package]] +name = "libredox" +version = "0.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a987beff54b60ffa6d51982e1aa1146bc42f19bd26be28b0586f252fccf5317" +checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" +dependencies = [ + "bitflags 2.4.1", + "libc", + "redox_syscall 0.4.1", +] [[package]] name = "link-cplusplus" @@ -405,13 +1265,47 @@ dependencies = [ "cc", ] +[[package]] +name = "linux-raw-sys" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" + +[[package]] +name = "linux-raw-sys" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" + [[package]] name = "log" version = "0.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", +] + +[[package]] +name = "mac-notification-sys" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51fca4d74ff9dbaac16a01b924bc3693fa2bba0862c2c633abc73f9a8ea21f64" +dependencies = [ + "cc", + "dirs-next", + "objc-foundation", + "objc_id", + "time 0.3.20", +] + +[[package]] +name = "malloc_buf" +version = "0.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb" +dependencies = [ + "libc", ] [[package]] @@ -429,6 +1323,24 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +[[package]] +name = "memoffset" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +dependencies = [ + "autocfg", +] + +[[package]] +name = "memoffset" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" +dependencies = [ + "autocfg", +] + [[package]] name = "memoffset" version = "0.8.0" @@ -439,10 +1351,53 @@ dependencies = [ ] [[package]] -name = "minimal-lexical" -version = "0.2.1" +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "mio" +version = "0.6.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4afd66f5b91bf2a3bc13fad0e21caedac168ca4c707504e75585648ae80e4cc4" +dependencies = [ + "cfg-if 0.1.10", + "fuchsia-zircon", + "fuchsia-zircon-sys", + "iovec", + "kernel32-sys", + "libc", + "log", + "miow", + "net2", + "slab", + "winapi 0.2.8", +] + +[[package]] +name = "mio-extras" +version = "2.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52403fe290012ce777c4626790c8951324a2b9e3316b3143779c72b029742f19" +dependencies = [ + "lazycell", + "log", + "mio", + "slab", +] + +[[package]] +name = "miow" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" +checksum = "ebd808424166322d4a38da87083bfddd3ac4c131334ed55856112eb06d46944d" +dependencies = [ + "kernel32-sys", + "net2", + "winapi 0.2.8", + "ws2_32-sys", +] [[package]] name = "nalgebra" @@ -471,14 +1426,71 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "net2" +version = "0.2.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b13b648036a2339d06de780866fbdfda0dde886de7b3af2ddeba8b14f4ee34ac" +dependencies = [ + "cfg-if 0.1.10", + "libc", + "winapi 0.3.9", +] + [[package]] name = "nix" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfb3ddedaa14746434a02041940495bf11325c22f6d36125d3bdd56090d50a79" dependencies = [ - "bitflags", + "bitflags 0.4.0", + "libc", +] + +[[package]] +name = "nix" +version = "0.22.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4916f159ed8e5de0082076562152a76b7a1f64a01fd9d1e0fea002c37624faf" +dependencies = [ + "bitflags 1.3.2", + "cc", + "cfg-if 1.0.0", + "libc", + "memoffset 0.6.5", +] + +[[package]] +name = "nix" +version = "0.24.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069" +dependencies = [ + "bitflags 1.3.2", + "cfg-if 1.0.0", + "libc", +] + +[[package]] +name = "nix" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b" +dependencies = [ + "bitflags 1.3.2", + "cfg-if 1.0.0", "libc", + "memoffset 0.7.1", +] + +[[package]] +name = "nom" +version = "5.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08959a387a676302eebf4ddbcbc611da04285579f76f88ee0506c63b1a61dd4b" +dependencies = [ + "memchr", + "version_check", ] [[package]] @@ -491,6 +1503,37 @@ dependencies = [ "minimal-lexical", ] +[[package]] +name = "notify" +version = "4.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae03c8c853dba7bfd23e571ff0cff7bc9dceb40a4cd684cd1681824183f45257" +dependencies = [ + "bitflags 1.3.2", + "filetime", + "fsevent", + "fsevent-sys", + "inotify", + "libc", + "mio", + "mio-extras", + "walkdir", + "winapi 0.3.9", +] + +[[package]] +name = "notify-rust" +version = "4.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "827c5edfa80235ded4ab3fe8e9dc619b4f866ef16fe9b1c6b8a7f8692c0f2226" +dependencies = [ + "log", + "mac-notification-sys", + "serde", + "tauri-winrt-notification", + "zbus", +] + [[package]] name = "num-complex" version = "0.4.3" @@ -536,10 +1579,39 @@ version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" dependencies = [ - "hermit-abi", + "hermit-abi 0.2.6", "libc", ] +[[package]] +name = "objc" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1" +dependencies = [ + "malloc_buf", +] + +[[package]] +name = "objc-foundation" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1add1b659e36c9607c7aab864a76c7a4c2760cd0cd2e120f3fb8b952c7e22bf9" +dependencies = [ + "block", + "objc", + "objc_id", +] + +[[package]] +name = "objc_id" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c92d4ddb4bd7b50d730c215ff871754d0da6b2178849f8a2a2ab69712d0c073b" +dependencies = [ + "objc", +] + [[package]] name = "once_cell" version = "1.17.1" @@ -558,13 +1630,23 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "ordered-stream" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aa2b01e1d916879f73a53d01d1d6cee68adbb31d6d9177a8cfce093cced1d50" +dependencies = [ + "futures-core", + "pin-project-lite", +] + [[package]] name = "paho-mqtt" version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19e405de34b835fb6457d8b0169eda21949f855472b3e346556af9e29fac6eb2" dependencies = [ - "async-channel", + "async-channel 1.9.0", "crossbeam-channel", "futures", "futures-timer", @@ -584,12 +1666,56 @@ dependencies = [ "openssl-sys", ] +[[package]] +name = "parking" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb813b8af86854136c6922af0598d719255ecb2179515e6e7730d468f05c9cae" + [[package]] name = "paste" version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f746c4065a8fa3fe23974dd82f15431cc8d40779821001404d10d2e79ca7d79" +[[package]] +name = "phf" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ade2d8b8f33c7333b51bcf0428d37e217e9f32192ae4772156f65063b8ce03dc" +dependencies = [ + "phf_shared", +] + +[[package]] +name = "phf_codegen" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8d39688d359e6b34654d328e262234662d16cc0f60ec8dcbe5e718709342a5a" +dependencies = [ + "phf_generator", + "phf_shared", +] + +[[package]] +name = "phf_generator" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48e4cc64c2ad9ebe670cb8fd69dd50ae301650392e81c05f9bfcb2d5bdbc24b0" +dependencies = [ + "phf_shared", + "rand", +] + +[[package]] +name = "phf_shared" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90fcb95eef784c2ac79119d1dd819e162b5da872ce6f3c3abe1e8ca1c082f72b" +dependencies = [ + "siphasher", +] + [[package]] name = "pin-project-lite" version = "0.2.13" @@ -602,12 +1728,69 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "piper" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "668d31b1c4eba19242f2088b2bf3316b82ca31082a8335764db4e083db7485d4" +dependencies = [ + "atomic-waker", + "fastrand 2.0.1", + "futures-io", +] + [[package]] name = "pkg-config" version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" +[[package]] +name = "polling" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b2d323e8ca7996b3e23126511a523f7e62924d93ecd5ae73b333815b0eb3dce" +dependencies = [ + "autocfg", + "bitflags 1.3.2", + "cfg-if 1.0.0", + "concurrent-queue", + "libc", + "log", + "pin-project-lite", + "windows-sys 0.48.0", +] + +[[package]] +name = "polling" +version = "3.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf63fa624ab313c11656b4cda960bfc46c410187ad493c41f6ba2d8c1e991c9e" +dependencies = [ + "cfg-if 1.0.0", + "concurrent-queue", + "pin-project-lite", + "rustix 0.38.26", + "tracing", + "windows-sys 0.52.0", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "proc-macro-crate" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" +dependencies = [ + "once_cell", + "toml_edit", +] + [[package]] name = "proc-macro2" version = "1.0.70" @@ -617,15 +1800,54 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "quick-xml" +version = "0.30.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eff6510e86862b57b210fd8cbe8ed3f0d7d600b9c2863cd4549a2e033c66e956" +dependencies = [ + "memchr", +] + [[package]] name = "quote" -version = "1.0.26" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + [[package]] name = "rawpointer" version = "0.2.1" @@ -654,6 +1876,97 @@ dependencies = [ "num_cpus", ] +[[package]] +name = "redox_syscall" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +dependencies = [ + "bitflags 1.3.2", +] + +[[package]] +name = "redox_syscall" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" +dependencies = [ + "bitflags 1.3.2", +] + +[[package]] +name = "redox_users" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a18479200779601e498ada4e8c1e1f50e3ee19deb0259c25825a98b5603b2cb4" +dependencies = [ + "getrandom", + "libredox", + "thiserror", +] + +[[package]] +name = "regex" +version = "1.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12de2eff854e5fa4b1295edd650e227e9d8fb0c9e90b12e7f36d6a6811791a29" +dependencies = [ + "aho-corasick 1.1.2", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49530408a136e16e5b486e883fbb6ba058e8e4e8ae6621a77b048b314336e629" +dependencies = [ + "aho-corasick 1.1.2", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" + +[[package]] +name = "rustix" +version = "0.37.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fea8ca367a3a01fe35e6943c400addf443c0f57670e6ec51196f71a4b8762dd2" +dependencies = [ + "bitflags 1.3.2", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys 0.3.8", + "windows-sys 0.48.0", +] + +[[package]] +name = "rustix" +version = "0.38.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9470c4bf8246c8daf25f9598dca807fb6510347b1e1cfa55749113850c79d88a" +dependencies = [ + "bitflags 2.4.1", + "errno", + "libc", + "linux-raw-sys 0.4.12", + "windows-sys 0.52.0", +] + +[[package]] +name = "ryu" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" + [[package]] name = "safe_arch" version = "0.6.0" @@ -663,6 +1976,15 @@ dependencies = [ "bytemuck", ] +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + [[package]] name = "scopeguard" version = "1.1.0" @@ -675,11 +1997,82 @@ version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1792db035ce95be60c3f8853017b3999209281c24e2ba5bc8e59bf97a0c590c1" +[[package]] +name = "semver" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" +dependencies = [ + "serde", +] + [[package]] name = "serde" -version = "1.0.160" +version = "1.0.193" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.193" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "serde_json" +version = "1.0.108" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_repr" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3081f5ffbb02284dda55132aa26daecedd7372a42417bbbab6f14ab7d6bb9145" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "sha1" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" +dependencies = [ + "cfg-if 1.0.0", + "cpufeatures", + "digest", +] + +[[package]] +name = "shell-escape" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb2f3770c8bce3bcda7e149193a069a0f4365bda1fa5cd88e03bca26afc1216c" +checksum = "45bb67a18fa91266cc7807181f62f9178a6873bfad7dc788c42e6430db40184f" + +[[package]] +name = "signal-hook-registry" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" +dependencies = [ + "libc", +] [[package]] name = "simba" @@ -694,6 +2087,12 @@ dependencies = [ "wide", ] +[[package]] +name = "siphasher" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" + [[package]] name = "slab" version = "0.4.9" @@ -703,25 +2102,66 @@ dependencies = [ "autocfg", ] +[[package]] +name = "socket2" +version = "0.4.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7916fc008ca5542385b89a3d3ce689953c143e9304a9bf8beec1de48994c0d" +dependencies = [ + "libc", + "winapi 0.3.9", +] + [[package]] name = "socketcan" version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3101efc6ef5af6f1c1a488241b469757b7a183baca63af958cd90e4696446c80" dependencies = [ - "hex", + "hex 0.2.0", "itertools", "libc", - "nix", + "nix 0.5.1", "try_from", ] +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "stderrlog" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69a26bbf6de627d389164afa9783739b56746c6c72c4ed16539f4ff54170327b" +dependencies = [ + "atty", + "chrono", + "log", + "termcolor", + "thread_local", +] + [[package]] name = "strength_reduce" version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe895eb47f22e2ddd4dabc02bce419d2e643c8e3b585c78158b349195bc24d82" +[[package]] +name = "strsim" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" + +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + [[package]] name = "syn" version = "1.0.109" @@ -735,9 +2175,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.15" +version = "2.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a34fcf3e8b60f57e6a14301a2e916d323af98b0ea63c599441eec8558660c822" +checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" dependencies = [ "proc-macro2", "quote", @@ -753,20 +2193,65 @@ dependencies = [ "bytesize", "lazy_static", "libc", - "nom", + "nom 7.1.3", "time 0.3.20", - "winapi", + "winapi 0.3.9", +] + +[[package]] +name = "tauri-winrt-notification" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "006851c9ccefa3c38a7646b8cec804bb429def3da10497bfa977179869c3e8e2" +dependencies = [ + "quick-xml", + "windows 0.51.1", +] + +[[package]] +name = "tempfile" +version = "3.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ef1adac450ad7f4b3c28589471ade84f25f731a7a0fe30d71dfa9f60fd808e5" +dependencies = [ + "cfg-if 1.0.0", + "fastrand 2.0.1", + "redox_syscall 0.4.1", + "rustix 0.38.26", + "windows-sys 0.48.0", ] [[package]] name = "termcolor" -version = "1.2.0" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" +checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" dependencies = [ "winapi-util", ] +[[package]] +name = "terminfo" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da31aef70da0f6352dbcb462683eb4dd2bfad01cf3fc96cf204547b9a839a585" +dependencies = [ + "dirs", + "fnv", + "nom 5.1.3", + "phf", + "phf_codegen", +] + +[[package]] +name = "textwrap" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" +dependencies = [ + "unicode-width", +] + [[package]] name = "thiserror" version = "1.0.40" @@ -784,7 +2269,17 @@ checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.39", +] + +[[package]] +name = "thread_local" +version = "1.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" +dependencies = [ + "cfg-if 1.0.0", + "once_cell", ] [[package]] @@ -794,8 +2289,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" dependencies = [ "libc", - "wasi", - "winapi", + "wasi 0.10.0+wasi-snapshot-preview1", + "winapi 0.3.9", ] [[package]] @@ -814,6 +2309,54 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd" +[[package]] +name = "toml_datetime" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" + +[[package]] +name = "toml_edit" +version = "0.19.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" +dependencies = [ + "indexmap", + "toml_datetime", + "winnow", +] + +[[package]] +name = "tracing" +version = "0.1.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +dependencies = [ + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "tracing-core" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +dependencies = [ + "once_cell", +] + [[package]] name = "transpose" version = "0.2.2" @@ -836,6 +2379,16 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" +[[package]] +name = "uds_windows" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce65604324d3cce9b966701489fbd0cf318cb1f7bd9dd07ac9a4ee6fb791930d" +dependencies = [ + "tempfile", + "winapi 0.3.9", +] + [[package]] name = "unicode-ident" version = "1.0.8" @@ -854,19 +2407,53 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" +[[package]] +name = "vec_map" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "waker-fn" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3c4517f54858c779bbcbf228f4fca63d121bf85fbecb2dc578cdf4a39395690" + +[[package]] +name = "walkdir" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" +dependencies = [ + "same-file", + "winapi-util", +] + [[package]] name = "wasi" version = "0.10.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + [[package]] name = "wasm-bindgen" version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "wasm-bindgen-macro", ] @@ -914,6 +2501,37 @@ version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d" +[[package]] +name = "watchexec" +version = "1.17.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38928d7ff5274e31594da2d46453a2c741fa340d1bf0ef6f2cb3e43537361265" +dependencies = [ + "clearscreen", + "command-group", + "derive_builder", + "glob", + "globset", + "lazy_static", + "log", + "nix 0.22.3", + "notify", + "walkdir", + "winapi 0.3.9", +] + +[[package]] +name = "which" +version = "4.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" +dependencies = [ + "either", + "home", + "once_cell", + "rustix 0.38.26", +] + [[package]] name = "wide" version = "0.7.8" @@ -924,6 +2542,12 @@ dependencies = [ "safe_arch", ] +[[package]] +name = "winapi" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" + [[package]] name = "winapi" version = "0.3.9" @@ -934,6 +2558,12 @@ dependencies = [ "winapi-x86_64-pc-windows-gnu", ] +[[package]] +name = "winapi-build" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" + [[package]] name = "winapi-i686-pc-windows-gnu" version = "0.4.0" @@ -946,7 +2576,7 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" dependencies = [ - "winapi", + "winapi 0.3.9", ] [[package]] @@ -961,62 +2591,289 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" dependencies = [ - "windows-targets", + "windows-targets 0.48.5", ] [[package]] -name = "windows-targets" +name = "windows" +version = "0.51.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca229916c5ee38c2f2bc1e9d8f04df975b4bd93f9955dc69fabb5d91270045c9" +dependencies = [ + "windows-core", + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-core" +version = "0.51.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" +dependencies = [ + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows-targets 0.52.0", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +dependencies = [ + "windows_aarch64_gnullvm 0.52.0", + "windows_aarch64_msvc 0.52.0", + "windows_i686_gnu 0.52.0", + "windows_i686_msvc 0.52.0", + "windows_x86_64_gnu 0.52.0", + "windows_x86_64_gnullvm 0.52.0", + "windows_x86_64_msvc 0.52.0", ] [[package]] name = "windows_aarch64_gnullvm" -version = "0.48.0" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" +checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" [[package]] name = "windows_aarch64_msvc" -version = "0.48.0" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" +checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" [[package]] name = "windows_i686_gnu" -version = "0.48.0" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" +checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" [[package]] name = "windows_i686_msvc" -version = "0.48.0" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" +checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" [[package]] name = "windows_x86_64_gnu" -version = "0.48.0" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" +checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" [[package]] name = "windows_x86_64_gnullvm" -version = "0.48.0" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" +checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" [[package]] name = "windows_x86_64_msvc" -version = "0.48.0" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" + +[[package]] +name = "winnow" +version = "0.5.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "829846f3e3db426d4cee4510841b71a8e58aa2a76b1132579487ae430ccd9c7b" +dependencies = [ + "memchr", +] + +[[package]] +name = "ws2_32-sys" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" +dependencies = [ + "winapi 0.2.8", + "winapi-build", +] + +[[package]] +name = "xdg-home" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2769203cd13a0c6015d515be729c526d041e9cf2c0cc478d57faee85f40c6dcd" +dependencies = [ + "nix 0.26.4", + "winapi 0.3.9", +] + +[[package]] +name = "zbus" +version = "3.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31de390a2d872e4cd04edd71b425e29853f786dc99317ed72d73d6fcf5ebb948" +dependencies = [ + "async-broadcast", + "async-executor", + "async-fs", + "async-io 1.13.0", + "async-lock 2.8.0", + "async-process", + "async-recursion", + "async-task", + "async-trait", + "blocking", + "byteorder", + "derivative", + "enumflags2", + "event-listener 2.5.3", + "futures-core", + "futures-sink", + "futures-util", + "hex 0.4.3", + "nix 0.26.4", + "once_cell", + "ordered-stream", + "rand", + "serde", + "serde_repr", + "sha1", + "static_assertions", + "tracing", + "uds_windows", + "winapi 0.3.9", + "xdg-home", + "zbus_macros", + "zbus_names", + "zvariant", +] + +[[package]] +name = "zbus_macros" +version = "3.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d1794a946878c0e807f55a397187c11fc7a038ba5d868e7db4f3bd7760bc9d" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "regex", + "syn 1.0.109", + "zvariant_utils", +] + +[[package]] +name = "zbus_names" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb80bb776dbda6e23d705cf0123c3b95df99c4ebeaec6c2599d4a5419902b4a9" +dependencies = [ + "serde", + "static_assertions", + "zvariant", +] + +[[package]] +name = "zvariant" +version = "3.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44b291bee0d960c53170780af148dca5fa260a63cdd24f1962fa82e03e53338c" +dependencies = [ + "byteorder", + "enumflags2", + "libc", + "serde", + "static_assertions", + "zvariant_derive", +] + +[[package]] +name = "zvariant_derive" +version = "3.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "934d7a7dfc310d6ee06c87ffe88ef4eca7d3e37bb251dece2ef93da8f17d8ecd" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 1.0.109", + "zvariant_utils", +] + +[[package]] +name = "zvariant_utils" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" +checksum = "7234f0d811589db492d16893e3f21e8e2fd282e6d01b0cddee310322062cc200" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] diff --git a/Cargo.toml b/Cargo.toml index 84a4b36..e758873 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,3 +15,4 @@ transpose = "0.2.2" matrixmultiply = "0.3.3" nalgebra = "0.32.2" paho-mqtt = "0.12.3" +cargo-watch = "8.4.1" diff --git a/README.md b/README.md new file mode 100644 index 0000000..17995cc --- /dev/null +++ b/README.md @@ -0,0 +1,34 @@ +# Calypso +Custom CAN Decoder for all the data being streamed around the car + +### Recommended Extensions +View https://www.youtube.com/watch?v=BU1LYFkpJuk for more information + +- rust-analyzer +- CodeLLDB +- Even Better TOML +- Error Lens +- Todo Tree +- crates + +#### Go to Settings in VSCode +search Rust-analyzer check and set the command from check -> clippy + +#### Open Settings.json +add following information: +``` +"[rust]": { + "editor.defaultFormatter": "rust-lang.rust-analyzer", + "editor.formatOnSave": true +} +``` + +### NERO 1.0 Config +Utilizes a linux IPC to stream data to the NERO frontend + +run ```/home/ner/Desktop/Calypso/target/release/calypso ipc /tmp/ipc.sock``` + +### SIREN and NERO 2.0 Config +Utilizes MQTT Web Socket to offload data from the car for our telemetry system +run ```/home/ner/Desktop/Calypso/target/release/calypso mqtt localhost:1883``` + diff --git a/src/client.rs b/src/client.rs index 3cb8079..41a4c85 100644 --- a/src/client.rs +++ b/src/client.rs @@ -7,10 +7,10 @@ pub trait Client { /** * Connects to the server at the given path. */ - fn connect(&mut self, path: &str) -> (); + fn connect(&mut self, path: &str); /** * Publishes the given data to the server. */ - fn publish(&mut self, data: &Data) -> (); + fn publish(&mut self, data: &Data); } diff --git a/src/decode_data.rs b/src/decode_data.rs index 5e83af5..c98a3f1 100644 --- a/src/decode_data.rs +++ b/src/decode_data.rs @@ -18,7 +18,7 @@ pub fn decode_accumulator_status(data: &[u8]) -> HashMap { result.insert(1, (pd::big_endian(&data[0..2], 8) as f32) / 10.0); result.insert( 2, - pd::twos_comp(pd::big_endian(&data[2..4], 8) as u32, 16) as f32 / 10.0, + pd::twos_comp(pd::big_endian(&data[2..4], 8), 16) as f32 / 10.0, ); result.insert(3, pd::big_endian(&data[4..6], 8) as f32); result.insert(4, data[6] as f32); @@ -44,9 +44,9 @@ pub fn decode3(data: &[u8]) -> HashMap { pub fn decode_cell_voltages(data: &[u8]) -> HashMap { let high_cell_volt_chip_number = (data[2] >> 4) & 15; - let high_cell_volt_cell_number = (data[2] >> 0) & 15; + let high_cell_volt_cell_number = data[2] & 15; let low_cell_volt_chip_number = (data[5] >> 4) & 15; - let low_cell_volt_cell_number = (data[5] >> 0) & 15; + let low_cell_volt_cell_number = data[5] & 15; let mut result = HashMap::new(); result.insert(13, (pd::little_endian(&data[0..2], 8) as f32) / 10000.0); result.insert(121, high_cell_volt_chip_number as f32); @@ -153,7 +153,7 @@ pub fn decode11(data: &[u8]) -> HashMap { } pub fn decode12(data: &[u8]) -> HashMap { - let decoded_data = pd::default_decode(&data); + let decoded_data = pd::default_decode(data); let final_data: Vec = decoded_data.iter().map(|d| fd::high_voltage(*d)).collect(); let mut result = HashMap::new(); result.insert(52, final_data[0]); @@ -164,7 +164,7 @@ pub fn decode12(data: &[u8]) -> HashMap { } pub fn decode13(data: &[u8]) -> HashMap { - let decoded_data = pd::default_decode(&data); + let decoded_data = pd::default_decode(data); let mut result = HashMap::new(); result.insert(56, fd::flux(decoded_data[0])); result.insert(57, fd::flux(decoded_data[1])); @@ -174,7 +174,7 @@ pub fn decode13(data: &[u8]) -> HashMap { } pub fn decode14(data: &[u8]) -> HashMap { - let decoded_data = pd::default_decode(&data); + let decoded_data = pd::default_decode(data); let final_data: Vec = decoded_data.iter().map(|d| fd::low_voltage(*d)).collect(); let mut result = HashMap::new(); result.insert(60, final_data[0]); @@ -201,7 +201,7 @@ pub fn decode15(data: &[u8]) -> HashMap { } pub fn decode16(data: &[u8]) -> HashMap { - let binding = pd::group_bytes(&data, 2); + let binding = pd::group_bytes(data, 2); let data = binding.iter().map(|d| pd::little_endian(d, 8) as f32); let grouped_data = data.collect::>(); let mut result = HashMap::new(); @@ -223,7 +223,7 @@ pub fn decode17(data: &[u8]) -> HashMap { } pub fn decode18(data: &[u8]) -> HashMap { - let decoded_data = pd::default_decode(&data); + let decoded_data = pd::default_decode(data); let mut result = HashMap::new(); result.insert(82, fd::torque(decoded_data[0])); result.insert(83, fd::angular_velocity(decoded_data[1]) as f32); @@ -243,7 +243,7 @@ pub fn decode19(data: &[u8]) -> HashMap { } pub fn decode_accelerometer_data(data: &[u8]) -> HashMap { - let decoded_data = pd::default_decode(&data); + let decoded_data = pd::default_decode(data); let converted_data = decoded_data .iter() .map(|val| *val as f32 * 0.0029) @@ -374,9 +374,9 @@ pub fn decode_gps_3(data: &[u8]) -> HashMap { pub fn decode_cell_temps(data: &[u8]) -> HashMap { let high_cell_temp_chip_number = (data[2] >> 4) & 15; - let high_cell_temp_cell_number = (data[2] >> 0) & 15; + let high_cell_temp_cell_number = data[2] & 15; let low_cell_temp_chip_number = (data[5] >> 4) & 15; - let low_cell_temp_cell_number = (data[5] >> 0) & 15; + let low_cell_temp_cell_number = data[5] & 15; let mut result = HashMap::new(); result.insert( diff --git a/src/decode_files.rs b/src/decode_files.rs index a25629b..8b1f0d0 100644 --- a/src/decode_files.rs +++ b/src/decode_files.rs @@ -1,7 +1,5 @@ - -// This file specifies methods to decode message fields (timestamp, id, data bytes) from -// a line in a log file. - +// This file specifies methods to decode message fields (timestamp, id, data bytes) from +// a line in a log file. use chrono::prelude::*; use std::convert::TryInto; @@ -18,9 +16,8 @@ enum LogFormat { } fn process_line(line: &str, format: LogFormat) -> Message { - // Processes a line of textual data according to a given format. - + match format { LogFormat::Textual1 => _process_textual1(line), LogFormat::Textual1Legacy => _process_textual1_legacy(line), @@ -30,10 +27,9 @@ fn process_line(line: &str, format: LogFormat) -> Message { } fn _process_textual1(line: &str) -> Message { - // Processes a line of data in the format "Timestamp id length [data1,data2,...]" // Example line format: 1679511802367 514 8 [54,0,10,0,0,0,0,0] - + let fields: Vec<&str> = line.trim().split(' ').collect(); let timestamp = NaiveDateTime::from_timestamp(fields[0].parse::().unwrap() / 1000, 0); let id = fields[1].parse::().unwrap(); @@ -51,10 +47,9 @@ fn _process_textual1(line: &str) -> Message { } fn _process_textual1_legacy(line: &str) -> Message { - // Processes a line of data in the format: Timestamp id length [data1,data2,...] // Example line format: 2021-01-01T00:00:00.003Z 514 8 [54,0,10,0,0,0,0,0] - + let fields: Vec<&str> = line.trim().split(' ').collect(); let timestamp = NaiveDateTime::parse_from_str(fields[0], "%Y-%m-%dT%H:%M:%S.%fZ") .unwrap() @@ -73,10 +68,9 @@ fn _process_textual1_legacy(line: &str) -> Message { } fn _process_textual2(line: &str) -> Message { - // Processes a line of data in the format "Timestamp id length data1 data2 ..." // Example line format: 1659901910.121 514 8 54 0 10 0 0 0 0 0 - + let fields: Vec<&str> = line.trim().split(' ').collect(); let timestamp = NaiveDateTime::from_timestamp(fields[0].parse::().unwrap(), 0); let id = fields[1].parse::().unwrap(); @@ -90,4 +84,4 @@ fn _process_textual2(line: &str) -> Message { fn _process_binary(line: &str) -> Message { panic!("Binary files not currently supported.") -} \ No newline at end of file +} diff --git a/src/decode_statuses.rs b/src/decode_statuses.rs index 3be9e0d..9deb5da 100644 --- a/src/decode_statuses.rs +++ b/src/decode_statuses.rs @@ -4,140 +4,182 @@ use crate::data::Data; // Mapping from data IDs to the status bits they encode // Each data ID contains a hash map with keys that are bit names and values that are the indexes -const STATUS_MAP: HashMap> = [(6, HashMap::new()), // Failsafe Statuses -(7, HashMap::new()), // DTC Status 1 -(8, HashMap::new()), // DTC Status 2 -(9, HashMap::new()), // Current Limits Status -(12, HashMap::new()), // MPE State -( // VSM State - 64, - hashmap![ - "VSM Start State" => 0, - "Pre-charge Init State" => 1, - "Pre-charge Active State" => 2, - "Pre-charge Complete State" => 3, - "VSM Wait State" => 4, - "VSM Ready State" => 5, - "Motor Running State" => 6, - "Blink Fault Code State" => 7 - ] +const STATUS_MAP: HashMap> = [ + (6, HashMap::new()), // Failsafe Statuses + (7, HashMap::new()), // DTC Status 1 + (8, HashMap::new()), // DTC Status 2 + (9, HashMap::new()), // Current Limits Status + (12, HashMap::new()), // MPE State + ( + // VSM State + 64, + hashmap![ + "VSM Start State" => 0, + "Pre-charge Init State" => 1, + "Pre-charge Active State" => 2, + "Pre-charge Complete State" => 3, + "VSM Wait State" => 4, + "VSM Ready State" => 5, + "Motor Running State" => 6, + "Blink Fault Code State" => 7 + ], + ), + ( + // Inverter State + 65, + hashmap![ + "Power on State" => 0, + "Stop State" => 1, + "Open Loop State" => 2, + "Closed Loop State" => 3, + "Wait State" => 4, + "Idle Run State" => 8, + "Idle Stop State" => 9 + ], + ), + ( + // Relay State + 66, + hashmap![ + "Relay 1 Status" => 0, + "Relay 2 Status" => 1, + "Relay 3 Status" => 2, + "Relay 4 Status" => 3, + "Relay 5 Status" => 4, + "Relay 6 Status" => 5, + ], + ), + ( + // Inverter Run Mode + 67, + hashmap!["Inverter Run Mode" => 0], + ), + ( + // Inverter Command Mode + 69, + hashmap!["Inverter Command Mode" => 0], + ), + ( + // Inverter Enable State + 70, + hashmap!["Inverter Enable State" => 0], + ), + ( + // Inverter Enable Lockout + 71, + hashmap!["Inverter Enable Lockout" => 0], + ), + ( + // Direction Command + 72, + hashmap!["Direction Command" => 0], + ), + ( + // BMS Active + 73, + hashmap!["BMS Active" => 0], + ), + ( + // BMS Limiting Torque + 74, + hashmap!["BMS Limiting Torque" => 0], + ), + ( + // POST Fault Lo + 75, + hashmap![ + "Hardware Gate/Desaturation Fault" => 0, + "HW Over-current Fault" => 1, + "Accelerator Shorted" => 2, + "Accelerator Open" => 3, + "Current Sensor Low" => 4, + "Current Sensor High" => 5, + "Module Temperature Low" => 6, + "Module Temperature High" => 7, + "Control PCB Temperature Low" => 8, + "Control PCB Temperature High" => 9, + "Gate Drive PCB Temperature Low" => 10, + "Gate Drive PCB Temperature High" => 11, + "5V Sense Voltage Low" => 12, + "5V Sense Voltage High" => 13, + "12V Sense Voltage Low" => 14, + "12V Sense Voltage High" => 15 + ], + ), + ( + 76, + hashmap![ // POST Fault Hi + "2.5V Sense Voltage Low" => 0, + "2.5V Sense Voltage High" => 1, + "1.5V Sense Voltage Low" => 2, + "1.5V Sense Voltage High" => 3, + "DC Bus Voltage High" => 4, + "DC Bus Voltage Low" => 5, + "Pre-charge Timeout" => 6, + "Pre-charge Voltage Failure" => 7, + "Brake Shorted" => 14, + "Brake Open" => 15 + ], + ), + ( + 77, + hashmap![ // Run Fault Lo + "Motor Over-speed Fault" => 0, + "Over-current Fault" => 1, + "Over-voltage Fault" => 2, + "Inverter Over-temperature Fault" => 3, + "Accelerator Input Shorted Fault" => 4, + "Accelerator Input Open Fault" => 5, + "Direction Command Fault" => 6, + "Inverter Response Time-out Fault" => 7, + "Hardware Gate/Desaturation Fault" => 8, + "Hardware Over-current Fault" => 9, + "Under-voltage Fault" => 10, + "CAN Command Message Lost Fault" => 11, + "Motor Over-temperature Fault" => 12 + ], + ), + ( + 78, + hashmap![ // Run Fault Hi + "Brake Input Shorted Fault" => 0, + "Brake Input Open Fault" => 1, + "Module A Over-temperature Fault" => 2, + "Module B Over temperature Fault" => 3, + "Module C Over-temperature Fault" => 4, + "PCB Over-temperature Fault" => 5, + "Gate Drive Board 1 Over-temperature Fault" => 6, + "Gate Drive Board 2 Over-temperature Fault" => 7, + "Gate Drive Board 3 Over-temperature Fault" => 8, + "Current Sensor Fault" => 9, + "Hardware Over-Voltage Fault" => 11, + "Resolver Not Connected" => 14, + "Inverter Discharge Active" => 15 + ], + ), + ( + // Direction Command + 84, + hashmap!["Direction Command" => 0], + ), + ( + // Inverter Enable + 85, + hashmap!["Inverter Enable" => 0], + ), + ( + // Inverter Discharge + 86, + hashmap!["Inverter Discharge" => 0], + ), + ( + // Speed Mode Enable + 87, + hashmap!["Speed Mode Enable" => 0], + ), + (// Cell Voltage Info ), -( // Inverter State - 65, - hashmap![ - "Power on State" => 0, - "Stop State" => 1, - "Open Loop State" => 2, - "Closed Loop State" => 3, - "Wait State" => 4, - "Idle Run State" => 8, - "Idle Stop State" => 9 - ] -), -( // Relay State - 66, - hashmap![ - "Relay 1 Status" => 0, - "Relay 2 Status" => 1, - "Relay 3 Status" => 2, - "Relay 4 Status" => 3, - "Relay 5 Status" => 4, - "Relay 6 Status" => 5, - ] -), -(// Inverter Run Mode - 67, hashmap!["Inverter Run Mode" => 0]), -(// Inverter Command Mode - 69, hashmap!["Inverter Command Mode" => 0]), -(// Inverter Enable State - 70, hashmap!["Inverter Enable State" => 0]), -(// Inverter Enable Lockout - 71, hashmap!["Inverter Enable Lockout" => 0]), -(// Direction Command - 72, hashmap!["Direction Command" => 0]), -(// BMS Active - 73, hashmap!["BMS Active" => 0]), -(// BMS Limiting Torque - 74, hashmap!["BMS Limiting Torque" => 0]), -(// POST Fault Lo - 75, - hashmap![ - "Hardware Gate/Desaturation Fault" => 0, - "HW Over-current Fault" => 1, - "Accelerator Shorted" => 2, - "Accelerator Open" => 3, - "Current Sensor Low" => 4, - "Current Sensor High" => 5, - "Module Temperature Low" => 6, - "Module Temperature High" => 7, - "Control PCB Temperature Low" => 8, - "Control PCB Temperature High" => 9, - "Gate Drive PCB Temperature Low" => 10, - "Gate Drive PCB Temperature High" => 11, - "5V Sense Voltage Low" => 12, - "5V Sense Voltage High" => 13, - "12V Sense Voltage Low" => 14, - "12V Sense Voltage High" => 15 - ]), -( - 76, - hashmap![ // POST Fault Hi - "2.5V Sense Voltage Low" => 0, - "2.5V Sense Voltage High" => 1, - "1.5V Sense Voltage Low" => 2, - "1.5V Sense Voltage High" => 3, - "DC Bus Voltage High" => 4, - "DC Bus Voltage Low" => 5, - "Pre-charge Timeout" => 6, - "Pre-charge Voltage Failure" => 7, - "Brake Shorted" => 14, - "Brake Open" => 15 - ]), -( - 77, - hashmap![ // Run Fault Lo - "Motor Over-speed Fault" => 0, - "Over-current Fault" => 1, - "Over-voltage Fault" => 2, - "Inverter Over-temperature Fault" => 3, - "Accelerator Input Shorted Fault" => 4, - "Accelerator Input Open Fault" => 5, - "Direction Command Fault" => 6, - "Inverter Response Time-out Fault" => 7, - "Hardware Gate/Desaturation Fault" => 8, - "Hardware Over-current Fault" => 9, - "Under-voltage Fault" => 10, - "CAN Command Message Lost Fault" => 11, - "Motor Over-temperature Fault" => 12 - ]), -( - 78, - hashmap![ // Run Fault Hi - "Brake Input Shorted Fault" => 0, - "Brake Input Open Fault" => 1, - "Module A Over-temperature Fault" => 2, - "Module B Over temperature Fault" => 3, - "Module C Over-temperature Fault" => 4, - "PCB Over-temperature Fault" => 5, - "Gate Drive Board 1 Over-temperature Fault" => 6, - "Gate Drive Board 2 Over-temperature Fault" => 7, - "Gate Drive Board 3 Over-temperature Fault" => 8, - "Current Sensor Fault" => 9, - "Hardware Over-Voltage Fault" => 11, - "Resolver Not Connected" => 14, - "Inverter Discharge Active" => 15 - ]), -(// Direction Command - 84, hashmap!["Direction Command" => 0]), -(// Inverter Enable - 85, hashmap!["Inverter Enable" => 0]), -(// Inverter Discharge - 86, hashmap!["Inverter Discharge" => 0]), -(// Speed Mode Enable - 87, hashmap!["Speed Mode Enable" => 0]), -(// Cell Voltage Info -)]; - +]; fn get_status(data: &Data, name: &str) -> i32 { if !STATUS_MAP.contains_key(&data.id) { @@ -160,6 +202,8 @@ fn get_statuses(data: &Data) -> HashMap<&str, i32> { let bitmap = &STATUS_MAP[&data.id]; // Convert each dict value to the bit value at the index - return bitmap.iter().map(|(name, index)| (*name, (data.value >> index) & 1)).collect(); + return bitmap + .iter() + .map(|(name, index)| (*name, (data.value >> index) & 1)) + .collect(); } - diff --git a/src/main.rs b/src/main.rs index 97f2121..9e1bc40 100644 --- a/src/main.rs +++ b/src/main.rs @@ -45,10 +45,10 @@ fn configure_can() { /** * Reads the can socket and publishes the data to the given client. */ -fn read_can(mut publisher: Box) -> () { +fn read_can(mut publisher: Box) { //open can socket channel at name can0 const CAN_CHANNEL: &str = "can0"; - let socket = CANSocket::open(&CAN_CHANNEL); + let socket = CANSocket::open(CAN_CHANNEL); let socket = match socket { Ok(socket) => socket, Err(err) => { @@ -57,10 +57,16 @@ fn read_can(mut publisher: Box) -> () { } }; loop { - let msg = socket.read_frame().unwrap(); + let msg = match { socket.read_frame() } { + Ok(msg) => msg, + Err(err) => { + println!("Failed to read CAN frame: {}", err); + continue; + } + }; let date: DateTime = Utc::now(); let data = msg.data(); - let message = Message::new(&date, &msg.id(), &data); + let message = Message::new(date, msg.id(), data.to_vec()); let decoded_data = message.decode(); for (_i, data) in decoded_data.iter().enumerate() { publisher.publish(data) diff --git a/src/master_mapping.rs b/src/master_mapping.rs index 59a3fa6..b96ee5c 100644 --- a/src/master_mapping.rs +++ b/src/master_mapping.rs @@ -1,7 +1,6 @@ use super::decode_data::*; use std::collections::HashMap; -#[derive(Clone)] pub struct MessageInfo { pub description: String, pub decoder: fn(data: &[u8]) -> HashMap, @@ -19,64 +18,61 @@ impl MessageInfo { // Mapping from external message ID to decoding information pub fn get_message_info(id: &u32) -> MessageInfo { match id { - 1 => return MessageInfo::new("accumulator status".to_string(), decode_accumulator_status), - 2 => return MessageInfo::new("BMS status".to_string(), decode_bms_status), - 3 => return MessageInfo::new("shutdown control".to_string(), decode3), - 4 => return MessageInfo::new("cell data".to_string(), decode_cell_voltages), - 160 => { - return MessageInfo::new( - "temperatures (igbt modules, gate driver board)".to_string(), - decode5, - ) - } - 161 => return MessageInfo::new("temperatures (control board)".to_string(), decode6), - 162 => return MessageInfo::new("temperatures (motor)".to_string(), decode7), - 163 => return MessageInfo::new("analog input voltages".to_string(), decode8), - 164 => return MessageInfo::new("digital input status".to_string(), decode9), - 165 => return MessageInfo::new("motor position information".to_string(), decode10), - 166 => return MessageInfo::new("Current information".to_string(), decode11), - 167 => return MessageInfo::new("Voltage Information".to_string(), decode12), - 168 => return MessageInfo::new("Flux Information".to_string(), decode13), - 169 => return MessageInfo::new("Internal Voltages".to_string(), decode14), - 170 => return MessageInfo::new("Internal States".to_string(), decode15), - 171 => return MessageInfo::new("Fault Codes".to_string(), decode16), - 172 => return MessageInfo::new("Torque and Timer Decoder".to_string(), decode17), - 192 => return MessageInfo::new("Command Data".to_string(), decode18), - 514 => return MessageInfo::new("Current Limits".to_string(), decode19), - 768 => { - return MessageInfo::new( - "NERduino Accelerometer".to_string(), - decode_accelerometer_data, - ) - } - 769 => return MessageInfo::new("NERduino Humidity".to_string(), decode21), - 7 => return MessageInfo::new("Cell Voltages".to_string(), decode_mock), - 193 => return MessageInfo::new("Unknown 1".to_string(), decode_mock), - 6 => return MessageInfo::new("Unknown 2".to_string(), decode_mock), - 194 => return MessageInfo::new("Unknown 3".to_string(), decode_mock), - 1744 => return MessageInfo::new("Unknown 4".to_string(), decode_mock), - 1745 => return MessageInfo::new("Unknown 5".to_string(), decode_mock), - 175 => return MessageInfo::new("Unknown 6".to_string(), decode_mock), - 770 => return MessageInfo::new("GLV Current".to_string(), decode29), - 2015 => return MessageInfo::new("Unknown 2015".to_string(), decode_mock), - 2027 => return MessageInfo::new("Unknown 2027".to_string(), decode_mock), - 2019 => return MessageInfo::new("Unknown 2019".to_string(), decode_mock), - 771 => return MessageInfo::new("Strain Gauge".to_string(), decode34), - 1024 => return MessageInfo::new("Wheel State".to_string(), decode35), - 10 => return MessageInfo::new("MPU States".to_string(), decode_mpu_dashboard_info), - 772 => return MessageInfo::new("GPS Data 1".to_string(), decode_gps_1), - 773 => return MessageInfo::new("GPS Data 2".to_string(), decode_gps_2), - 774 => return MessageInfo::new("GPS Data 3".to_string(), decode_gps_3), - 8 => return MessageInfo::new("Cell Temperatures".to_string(), decode_cell_temps), - 9 => return MessageInfo::new("Segment Temperatures".to_string(), decode_segment_temps), - 775 => return MessageInfo::new("Logging Status".to_string(), decode_logging_status), - 1025 => return MessageInfo::new("LV Battery 1".to_string(), decode_lv_battery_1), - 1026 => return MessageInfo::new("LV Battery 2".to_string(), decode_lv_battery_2), - _ => return MessageInfo::new("Unknown".to_string(), decode_mock), + 1 => MessageInfo::new("accumulator status".to_string(), decode_accumulator_status), + 2 => MessageInfo::new("BMS status".to_string(), decode_bms_status), + 3 => MessageInfo::new("shutdown control".to_string(), decode3), + 4 => MessageInfo::new("cell data".to_string(), decode_cell_voltages), + 160 => MessageInfo::new( + "temperatures (igbt modules, gate driver board)".to_string(), + decode5, + ), + 161 => MessageInfo::new("temperatures (control board)".to_string(), decode6), + 162 => MessageInfo::new("temperatures (motor)".to_string(), decode7), + 163 => MessageInfo::new("analog input voltages".to_string(), decode8), + 164 => MessageInfo::new("digital input status".to_string(), decode9), + 165 => MessageInfo::new("motor position information".to_string(), decode10), + 166 => MessageInfo::new("Current information".to_string(), decode11), + 167 => MessageInfo::new("Voltage Information".to_string(), decode12), + 168 => MessageInfo::new("Flux Information".to_string(), decode13), + 169 => MessageInfo::new("Internal Voltages".to_string(), decode14), + 170 => MessageInfo::new("Internal States".to_string(), decode15), + 171 => MessageInfo::new("Fault Codes".to_string(), decode16), + 172 => MessageInfo::new("Torque and Timer Decoder".to_string(), decode17), + 192 => MessageInfo::new("Command Data".to_string(), decode18), + 514 => MessageInfo::new("Current Limits".to_string(), decode19), + 768 => MessageInfo::new( + "NERduino Accelerometer".to_string(), + decode_accelerometer_data, + ), + 769 => MessageInfo::new("NERduino Humidity".to_string(), decode21), + 7 => MessageInfo::new("Cell Voltages".to_string(), decode_mock), + 193 => MessageInfo::new("Unknown 1".to_string(), decode_mock), + 6 => MessageInfo::new("Unknown 2".to_string(), decode_mock), + 194 => MessageInfo::new("Unknown 3".to_string(), decode_mock), + 1744 => MessageInfo::new("Unknown 4".to_string(), decode_mock), + 1745 => MessageInfo::new("Unknown 5".to_string(), decode_mock), + 175 => MessageInfo::new("Unknown 6".to_string(), decode_mock), + 770 => MessageInfo::new("GLV Current".to_string(), decode29), + 2015 => MessageInfo::new("Unknown 2015".to_string(), decode_mock), + 2027 => MessageInfo::new("Unknown 2027".to_string(), decode_mock), + 2019 => MessageInfo::new("Unknown 2019".to_string(), decode_mock), + 771 => MessageInfo::new("Strain Gauge".to_string(), decode34), + 1024 => MessageInfo::new("Wheel State".to_string(), decode35), + 10 => MessageInfo::new("MPU States".to_string(), decode_mpu_dashboard_info), + 772 => MessageInfo::new("GPS Data 1".to_string(), decode_gps_1), + 773 => MessageInfo::new("GPS Data 2".to_string(), decode_gps_2), + 774 => MessageInfo::new("GPS Data 3".to_string(), decode_gps_3), + 8 => MessageInfo::new("Cell Temperatures".to_string(), decode_cell_temps), + 9 => MessageInfo::new("Segment Temperatures".to_string(), decode_segment_temps), + 775 => MessageInfo::new("Logging Status".to_string(), decode_logging_status), + 1025 => MessageInfo::new("LV Battery 1".to_string(), decode_lv_battery_1), + 1026 => MessageInfo::new("LV Battery 2".to_string(), decode_lv_battery_2), + _ => MessageInfo::new("Unknown".to_string(), decode_mock), } } -#[derive(Clone)] +//Unused Data Ids Implementation in rust +/* pub struct DataInfo { name: String, units: String, @@ -90,157 +86,158 @@ impl DataInfo { pub fn get_data_info(id: u8) -> DataInfo { match id { - 0 => return DataInfo::new("Mock Data".to_string(), "".to_string()), - 1 => return DataInfo::new("Pack Inst Voltage".to_string(), "V".to_string()), - 2 => return DataInfo::new("Pack Current".to_string(), "A".to_string()), - 3 => return DataInfo::new("Pack Amphours".to_string(), "Ah".to_string()), - 4 => return DataInfo::new("Pack SOC".to_string(), "%".to_string()), - 5 => return DataInfo::new("Pack Health".to_string(), "%".to_string()), - 6 => return DataInfo::new("Failsafe Statuses".to_string(), "HEX".to_string()), - 7 => return DataInfo::new("DTC Status 1".to_string(), "HEX".to_string()), - 8 => return DataInfo::new("DTC Status 2".to_string(), "HEX".to_string()), - 9 => return DataInfo::new("Current Limits Status".to_string(), "".to_string()), - 10 => return DataInfo::new("Average Temp".to_string(), "C".to_string()), - 11 => return DataInfo::new("Internal Temp".to_string(), "C".to_string()), - 12 => return DataInfo::new("MPE State".to_string(), "BIN".to_string()), - 13 => return DataInfo::new("High Cell Voltage".to_string(), "V".to_string()), - 14 => return DataInfo::new("High Cell Voltage ID".to_string(), "".to_string()), - 15 => return DataInfo::new("Low Cell Voltage".to_string(), "V".to_string()), - 16 => return DataInfo::new("Low Cell Voltage ID".to_string(), "".to_string()), - 17 => return DataInfo::new("Average Cell Voltage".to_string(), "V".to_string()), - 18 => return DataInfo::new("Module A Temperature".to_string(), "C".to_string()), - 19 => return DataInfo::new("Module B Temperature".to_string(), "C".to_string()), - 20 => return DataInfo::new("Module C Temperature".to_string(), "C".to_string()), - 21 => return DataInfo::new("Gate Driver Board Temperature".to_string(), "C".to_string()), - 22 => return DataInfo::new("Control Board Temperature".to_string(), "C".to_string()), - 23 => return DataInfo::new("RTD #1 Temperature".to_string(), "C".to_string()), - 24 => return DataInfo::new("RTD #2 Temperature".to_string(), "C".to_string()), - 25 => return DataInfo::new("RTD #3 Temperature".to_string(), "C".to_string()), - 26 => return DataInfo::new("RTD #4 Temperature".to_string(), "C".to_string()), - 27 => return DataInfo::new("RTD #5 Temperature".to_string(), "C".to_string()), - 28 => return DataInfo::new("Motor Temperature".to_string(), "C".to_string()), - 29 => return DataInfo::new("Torque Shudder".to_string(), "N-m".to_string()), - 30 => return DataInfo::new("Analog Input 1".to_string(), "V".to_string()), - 31 => return DataInfo::new("Analog Input 2".to_string(), "V".to_string()), - 32 => return DataInfo::new("Analog Input 3".to_string(), "V".to_string()), - 33 => return DataInfo::new("Analog Input 4".to_string(), "V".to_string()), - 34 => return DataInfo::new("Analog Input 5".to_string(), "V".to_string()), - 35 => return DataInfo::new("Analog Input 6".to_string(), "V".to_string()), - 36 => return DataInfo::new("Digital Input 1".to_string(), "BIN".to_string()), - 37 => return DataInfo::new("Digital Input 2".to_string(), "BIN".to_string()), - 38 => return DataInfo::new("Digital Input 3".to_string(), "BIN".to_string()), - 39 => return DataInfo::new("Digital Input 4".to_string(), "BIN".to_string()), - 40 => return DataInfo::new("Digital Input 5".to_string(), "BIN".to_string()), - 41 => return DataInfo::new("Digital Input 6".to_string(), "BIN".to_string()), - 42 => return DataInfo::new("Digital Input 7".to_string(), "BIN".to_string()), - 43 => return DataInfo::new("Digital Input 8".to_string(), "BIN".to_string()), - 44 => return DataInfo::new("Motor Angle Electrical".to_string(), "Deg".to_string()), - 45 => return DataInfo::new("Motor Speed".to_string(), "RPM".to_string()), - 46 => return DataInfo::new("Electrical Output Frequency".to_string(), "Hz".to_string()), - 48 => return DataInfo::new("Phase A Current".to_string(), "A".to_string()), - 49 => return DataInfo::new("Phase B Current".to_string(), "A".to_string()), - 50 => return DataInfo::new("Phase C Current".to_string(), "A".to_string()), - 51 => return DataInfo::new("DC Bus Current".to_string(), "A".to_string()), - 52 => return DataInfo::new("DC Bus Voltage".to_string(), "V".to_string()), - 53 => return DataInfo::new("Output Voltage".to_string(), "V".to_string()), - 54 => return DataInfo::new("VAB_Vd Voltage".to_string(), "V".to_string()), - 55 => return DataInfo::new("VBC_Vq Voltage".to_string(), "V".to_string()), - 56 => return DataInfo::new("Flux Command".to_string(), "Wb".to_string()), - 57 => return DataInfo::new("Flux Feedback".to_string(), "wb".to_string()), - 58 => return DataInfo::new("Id Feedback".to_string(), "A".to_string()), - 59 => return DataInfo::new("Iq Feedback".to_string(), "A".to_string()), - 60 => return DataInfo::new("1.5V Reference Voltage".to_string(), "V".to_string()), - 61 => return DataInfo::new("2.5V Reference Voltage".to_string(), "V".to_string()), - 62 => return DataInfo::new("5.0V Reference Voltage".to_string(), "V".to_string()), - 63 => return DataInfo::new("12V System Voltage".to_string(), "V".to_string()), - 64 => return DataInfo::new("VSM State".to_string(), "".to_string()), - 65 => return DataInfo::new("Inverter State".to_string(), "".to_string()), - 66 => return DataInfo::new("Relay State".to_string(), "BIN".to_string()), - 67 => return DataInfo::new("Inverter Run Mode".to_string(), "BIN".to_string()), + 0 => DataInfo::new("Mock Data".to_string(), "".to_string()), + 1 => DataInfo::new("Pack Inst Voltage".to_string(), "V".to_string()), + 2 => DataInfo::new("Pack Current".to_string(), "A".to_string()), + 3 => DataInfo::new("Pack Amphours".to_string(), "Ah".to_string()), + 4 => DataInfo::new("Pack SOC".to_string(), "%".to_string()), + 5 => DataInfo::new("Pack Health".to_string(), "%".to_string()), + 6 => DataInfo::new("Failsafe Statuses".to_string(), "HEX".to_string()), + 7 => DataInfo::new("DTC Status 1".to_string(), "HEX".to_string()), + 8 => DataInfo::new("DTC Status 2".to_string(), "HEX".to_string()), + 9 => DataInfo::new("Current Limits Status".to_string(), "".to_string()), + 10 => DataInfo::new("Average Temp".to_string(), "C".to_string()), + 11 => DataInfo::new("Internal Temp".to_string(), "C".to_string()), + 12 => DataInfo::new("MPE State".to_string(), "BIN".to_string()), + 13 => DataInfo::new("High Cell Voltage".to_string(), "V".to_string()), + 14 => DataInfo::new("High Cell Voltage ID".to_string(), "".to_string()), + 15 => DataInfo::new("Low Cell Voltage".to_string(), "V".to_string()), + 16 => DataInfo::new("Low Cell Voltage ID".to_string(), "".to_string()), + 17 => DataInfo::new("Average Cell Voltage".to_string(), "V".to_string()), + 18 => DataInfo::new("Module A Temperature".to_string(), "C".to_string()), + 19 => DataInfo::new("Module B Temperature".to_string(), "C".to_string()), + 20 => DataInfo::new("Module C Temperature".to_string(), "C".to_string()), + 21 => DataInfo::new("Gate Driver Board Temperature".to_string(), "C".to_string()), + 22 => DataInfo::new("Control Board Temperature".to_string(), "C".to_string()), + 23 => DataInfo::new("RTD #1 Temperature".to_string(), "C".to_string()), + 24 => DataInfo::new("RTD #2 Temperature".to_string(), "C".to_string()), + 25 => DataInfo::new("RTD #3 Temperature".to_string(), "C".to_string()), + 26 => DataInfo::new("RTD #4 Temperature".to_string(), "C".to_string()), + 27 => DataInfo::new("RTD #5 Temperature".to_string(), "C".to_string()), + 28 => DataInfo::new("Motor Temperature".to_string(), "C".to_string()), + 29 => DataInfo::new("Torque Shudder".to_string(), "N-m".to_string()), + 30 => DataInfo::new("Analog Input 1".to_string(), "V".to_string()), + 31 => DataInfo::new("Analog Input 2".to_string(), "V".to_string()), + 32 => DataInfo::new("Analog Input 3".to_string(), "V".to_string()), + 33 => DataInfo::new("Analog Input 4".to_string(), "V".to_string()), + 34 => DataInfo::new("Analog Input 5".to_string(), "V".to_string()), + 35 => DataInfo::new("Analog Input 6".to_string(), "V".to_string()), + 36 => DataInfo::new("Digital Input 1".to_string(), "BIN".to_string()), + 37 => DataInfo::new("Digital Input 2".to_string(), "BIN".to_string()), + 38 => DataInfo::new("Digital Input 3".to_string(), "BIN".to_string()), + 39 => DataInfo::new("Digital Input 4".to_string(), "BIN".to_string()), + 40 => DataInfo::new("Digital Input 5".to_string(), "BIN".to_string()), + 41 => DataInfo::new("Digital Input 6".to_string(), "BIN".to_string()), + 42 => DataInfo::new("Digital Input 7".to_string(), "BIN".to_string()), + 43 => DataInfo::new("Digital Input 8".to_string(), "BIN".to_string()), + 44 => DataInfo::new("Motor Angle Electrical".to_string(), "Deg".to_string()), + 45 => DataInfo::new("Motor Speed".to_string(), "RPM".to_string()), + 46 => DataInfo::new("Electrical Output Frequency".to_string(), "Hz".to_string()), + 48 => DataInfo::new("Phase A Current".to_string(), "A".to_string()), + 49 => DataInfo::new("Phase B Current".to_string(), "A".to_string()), + 50 => DataInfo::new("Phase C Current".to_string(), "A".to_string()), + 51 => DataInfo::new("DC Bus Current".to_string(), "A".to_string()), + 52 => DataInfo::new("DC Bus Voltage".to_string(), "V".to_string()), + 53 => DataInfo::new("Output Voltage".to_string(), "V".to_string()), + 54 => DataInfo::new("VAB_Vd Voltage".to_string(), "V".to_string()), + 55 => DataInfo::new("VBC_Vq Voltage".to_string(), "V".to_string()), + 56 => DataInfo::new("Flux Command".to_string(), "Wb".to_string()), + 57 => DataInfo::new("Flux Feedback".to_string(), "wb".to_string()), + 58 => DataInfo::new("Id Feedback".to_string(), "A".to_string()), + 59 => DataInfo::new("Iq Feedback".to_string(), "A".to_string()), + 60 => DataInfo::new("1.5V Reference Voltage".to_string(), "V".to_string()), + 61 => DataInfo::new("2.5V Reference Voltage".to_string(), "V".to_string()), + 62 => DataInfo::new("5.0V Reference Voltage".to_string(), "V".to_string()), + 63 => DataInfo::new("12V System Voltage".to_string(), "V".to_string()), + 64 => DataInfo::new("VSM State".to_string(), "".to_string()), + 65 => DataInfo::new("Inverter State".to_string(), "".to_string()), + 66 => DataInfo::new("Relay State".to_string(), "BIN".to_string()), + 67 => DataInfo::new("Inverter Run Mode".to_string(), "BIN".to_string()), 68 => { - return DataInfo::new( + DataInfo::new( "Inverter Active Discharge State".to_string(), "BIN".to_string(), ) } - 69 => return DataInfo::new("Inverter Command Mode".to_string(), "BIN".to_string()), - 70 => return DataInfo::new("Inverter Enable State".to_string(), "BIN".to_string()), - 71 => return DataInfo::new("Inverter Enable Lockout".to_string(), "BIN".to_string()), - 72 => return DataInfo::new("Direction Command".to_string(), "BIN".to_string()), - 73 => return DataInfo::new("BMS Active".to_string(), "BIN".to_string()), - 74 => return DataInfo::new("BMS Limiting Torque".to_string(), "BIN".to_string()), - 75 => return DataInfo::new("POST Fault Lo".to_string(), "BIN".to_string()), - 76 => return DataInfo::new("POST Fault Hi".to_string(), "BIN".to_string()), - 77 => return DataInfo::new("Run Fault Lo".to_string(), "BIN".to_string()), - 78 => return DataInfo::new("Run Fault Hi".to_string(), "BIN".to_string()), - 79 => return DataInfo::new("Commanded Torque".to_string(), "N-m".to_string()), - 80 => return DataInfo::new("Torque Feedback".to_string(), "N-m".to_string()), - 81 => return DataInfo::new("Power on Timer".to_string(), "s".to_string()), - 82 => return DataInfo::new("Torque Command".to_string(), "N-m".to_string()), - 83 => return DataInfo::new("Speed Command".to_string(), "RPM".to_string()), - 84 => return DataInfo::new("Direction Command".to_string(), "BIN".to_string()), - 85 => return DataInfo::new("Inverter Enable".to_string(), "BIN".to_string()), - 86 => return DataInfo::new("Inverter Discharge".to_string(), "BIN".to_string()), - 87 => return DataInfo::new("Speed Mode Enable".to_string(), "BIN".to_string()), - 88 => return DataInfo::new("Commanded Torque Limit".to_string(), "N-m".to_string()), - 89 => return DataInfo::new("Pack DCL".to_string(), "A".to_string()), - 90 => return DataInfo::new("Pack CCL".to_string(), "A".to_string()), - 91 => return DataInfo::new("TCU X-Axis Acceleration".to_string(), "g".to_string()), - 92 => return DataInfo::new("TCU Y-Axis Acceleration".to_string(), "g".to_string()), - 93 => return DataInfo::new("TCU Z-Axis Acceleration".to_string(), "g".to_string()), - 94 => return DataInfo::new("TCU Temperature C".to_string(), "C".to_string()), - 95 => return DataInfo::new("TCU Temperature F".to_string(), "F".to_string()), - 96 => return DataInfo::new("Relative Humidity".to_string(), "%".to_string()), - 97 => return DataInfo::new("Cell Voltage Info".to_string(), "".to_string()), - 98 => return DataInfo::new("GLV Current".to_string(), "A".to_string()), - 99 => return DataInfo::new("Strain Gauge Voltage 1".to_string(), "V".to_string()), - 100 => return DataInfo::new("Strain Gauge Voltage 2".to_string(), "V".to_string()), - 101 => return DataInfo::new("Vehicle Speed".to_string(), "MPH".to_string()), - 102 => return DataInfo::new("Wheel Knob 1".to_string(), "".to_string()), - 103 => return DataInfo::new("Wheel Knob 2".to_string(), "".to_string()), - 104 => return DataInfo::new("Wheel Buttons".to_string(), "".to_string()), - 105 => return DataInfo::new("MPU Mode State".to_string(), "".to_string()), - 106 => return DataInfo::new("BMS State".to_string(), "".to_string()), - 107 => return DataInfo::new("BMS Faults".to_string(), "HEX".to_string()), - 108 => return DataInfo::new("Latitude".to_string(), "Deg".to_string()), - 109 => return DataInfo::new("Longitude".to_string(), "Deg".to_string()), - 110 => return DataInfo::new("GPS Fix Status".to_string(), "".to_string()), - 111 => return DataInfo::new("Altitude".to_string(), "m".to_string()), - 112 => return DataInfo::new("Ground Speed".to_string(), "m/s".to_string()), - 113 => return DataInfo::new("Heading Direction".to_string(), "Deg".to_string()), - 114 => return DataInfo::new("High Cell Temp".to_string(), "C".to_string()), - 115 => return DataInfo::new("High Cell Temp Chip Number".to_string(), "".to_string()), - 116 => return DataInfo::new("High Cell Temp Cell Number".to_string(), "".to_string()), - 117 => return DataInfo::new("Low Cell Temp".to_string(), "C".to_string()), - 118 => return DataInfo::new("Low Cell Temp Chip Number".to_string(), "".to_string()), - 119 => return DataInfo::new("Low Cell temp Cell Number".to_string(), "".to_string()), - 120 => return DataInfo::new("Average Cell Temp".to_string(), "C".to_string()), - 121 => return DataInfo::new("High Cell Voltage Chip Number".to_string(), "".to_string()), - 122 => return DataInfo::new("High Cell Voltage Cell Number".to_string(), "".to_string()), - 123 => return DataInfo::new("Low Cell Voltage Chip Number".to_string(), "".to_string()), - 124 => return DataInfo::new("Low Cell Voltage Cell Number".to_string(), "".to_string()), - 125 => return DataInfo::new("Segment 1 Average Temperature".to_string(), "C".to_string()), - 126 => return DataInfo::new("Segment 2 Average Temperature".to_string(), "C".to_string()), - 127 => return DataInfo::new("Segment 3 Average Temperature".to_string(), "C".to_string()), - 128 => return DataInfo::new("Segment 4 Average Temperature".to_string(), "C".to_string()), - 129 => return DataInfo::new("Logging Status".to_string(), "".to_string()), - 130 => return DataInfo::new("Accumulator Fan Percentage".to_string(), "%".to_string()), - 131 => return DataInfo::new("Motor Fan Percentage".to_string(), "%".to_string()), - 132 => return DataInfo::new("Torque Limit Percentage".to_string(), "%".to_string()), - 133 => return DataInfo::new("Regen Strength value".to_string(), "".to_string()), - 134 => return DataInfo::new("Carger State".to_string(), "".to_string()), - 135 => return DataInfo::new("Measurement System Valid".to_string(), "".to_string()), - 136 => return DataInfo::new("System Status".to_string(), "".to_string()), - 137 => return DataInfo::new("Charge Status".to_string(), "".to_string()), - 138 => return DataInfo::new("ibat".to_string(), "A".to_string()), - 139 => return DataInfo::new("vbat".to_string(), "V".to_string()), - 140 => return DataInfo::new("vin".to_string(), "V".to_string()), - 141 => return DataInfo::new("vsys".to_string(), "V".to_string()), - 142 => return DataInfo::new("iin".to_string(), "A".to_string()), - 143 => return DataInfo::new("Cell Burning Status".to_string(), "".to_string()), - 144 => return DataInfo::new("Traction Control On".to_string(), "".to_string()), - 145 => return DataInfo::new("Precharge State".to_string(), "".to_string()), - 146 => return DataInfo::new("BMS Prefault Status".to_string(), "".to_string()), - _ => return DataInfo::new("".to_string(), "".to_string()), + 69 => DataInfo::new("Inverter Command Mode".to_string(), "BIN".to_string()), + 70 => DataInfo::new("Inverter Enable State".to_string(), "BIN".to_string()), + 71 => DataInfo::new("Inverter Enable Lockout".to_string(), "BIN".to_string()), + 72 => DataInfo::new("Direction Command".to_string(), "BIN".to_string()), + 73 => DataInfo::new("BMS Active".to_string(), "BIN".to_string()), + 74 => DataInfo::new("BMS Limiting Torque".to_string(), "BIN".to_string()), + 75 => DataInfo::new("POST Fault Lo".to_string(), "BIN".to_string()), + 76 => DataInfo::new("POST Fault Hi".to_string(), "BIN".to_string()), + 77 => DataInfo::new("Run Fault Lo".to_string(), "BIN".to_string()), + 78 => DataInfo::new("Run Fault Hi".to_string(), "BIN".to_string()), + 79 => DataInfo::new("Commanded Torque".to_string(), "N-m".to_string()), + 80 => DataInfo::new("Torque Feedback".to_string(), "N-m".to_string()), + 81 => DataInfo::new("Power on Timer".to_string(), "s".to_string()), + 82 => DataInfo::new("Torque Command".to_string(), "N-m".to_string()), + 83 => DataInfo::new("Speed Command".to_string(), "RPM".to_string()), + 84 => DataInfo::new("Direction Command".to_string(), "BIN".to_string()), + 85 => DataInfo::new("Inverter Enable".to_string(), "BIN".to_string()), + 86 => DataInfo::new("Inverter Discharge".to_string(), "BIN".to_string()), + 87 => DataInfo::new("Speed Mode Enable".to_string(), "BIN".to_string()), + 88 => DataInfo::new("Commanded Torque Limit".to_string(), "N-m".to_string()), + 89 => DataInfo::new("Pack DCL".to_string(), "A".to_string()), + 90 => DataInfo::new("Pack CCL".to_string(), "A".to_string()), + 91 => DataInfo::new("TCU X-Axis Acceleration".to_string(), "g".to_string()), + 92 => DataInfo::new("TCU Y-Axis Acceleration".to_string(), "g".to_string()), + 93 => DataInfo::new("TCU Z-Axis Acceleration".to_string(), "g".to_string()), + 94 => DataInfo::new("TCU Temperature C".to_string(), "C".to_string()), + 95 => DataInfo::new("TCU Temperature F".to_string(), "F".to_string()), + 96 => DataInfo::new("Relative Humidity".to_string(), "%".to_string()), + 97 => DataInfo::new("Cell Voltage Info".to_string(), "".to_string()), + 98 => DataInfo::new("GLV Current".to_string(), "A".to_string()), + 99 => DataInfo::new("Strain Gauge Voltage 1".to_string(), "V".to_string()), + 100 => DataInfo::new("Strain Gauge Voltage 2".to_string(), "V".to_string()), + 101 => DataInfo::new("Vehicle Speed".to_string(), "MPH".to_string()), + 102 => DataInfo::new("Wheel Knob 1".to_string(), "".to_string()), + 103 => DataInfo::new("Wheel Knob 2".to_string(), "".to_string()), + 104 => DataInfo::new("Wheel Buttons".to_string(), "".to_string()), + 105 => DataInfo::new("MPU Mode State".to_string(), "".to_string()), + 106 => DataInfo::new("BMS State".to_string(), "".to_string()), + 107 => DataInfo::new("BMS Faults".to_string(), "HEX".to_string()), + 108 => DataInfo::new("Latitude".to_string(), "Deg".to_string()), + 109 => DataInfo::new("Longitude".to_string(), "Deg".to_string()), + 110 => DataInfo::new("GPS Fix Status".to_string(), "".to_string()), + 111 => DataInfo::new("Altitude".to_string(), "m".to_string()), + 112 => DataInfo::new("Ground Speed".to_string(), "m/s".to_string()), + 113 => DataInfo::new("Heading Direction".to_string(), "Deg".to_string()), + 114 => DataInfo::new("High Cell Temp".to_string(), "C".to_string()), + 115 => DataInfo::new("High Cell Temp Chip Number".to_string(), "".to_string()), + 116 => DataInfo::new("High Cell Temp Cell Number".to_string(), "".to_string()), + 117 => DataInfo::new("Low Cell Temp".to_string(), "C".to_string()), + 118 => DataInfo::new("Low Cell Temp Chip Number".to_string(), "".to_string()), + 119 => DataInfo::new("Low Cell temp Cell Number".to_string(), "".to_string()), + 120 => DataInfo::new("Average Cell Temp".to_string(), "C".to_string()), + 121 => DataInfo::new("High Cell Voltage Chip Number".to_string(), "".to_string()), + 122 => DataInfo::new("High Cell Voltage Cell Number".to_string(), "".to_string()), + 123 => DataInfo::new("Low Cell Voltage Chip Number".to_string(), "".to_string()), + 124 => DataInfo::new("Low Cell Voltage Cell Number".to_string(), "".to_string()), + 125 => DataInfo::new("Segment 1 Average Temperature".to_string(), "C".to_string()), + 126 => DataInfo::new("Segment 2 Average Temperature".to_string(), "C".to_string()), + 127 => DataInfo::new("Segment 3 Average Temperature".to_string(), "C".to_string()), + 128 => DataInfo::new("Segment 4 Average Temperature".to_string(), "C".to_string()), + 129 => DataInfo::new("Logging Status".to_string(), "".to_string()), + 130 => DataInfo::new("Accumulator Fan Percentage".to_string(), "%".to_string()), + 131 => DataInfo::new("Motor Fan Percentage".to_string(), "%".to_string()), + 132 => DataInfo::new("Torque Limit Percentage".to_string(), "%".to_string()), + 133 => DataInfo::new("Regen Strength value".to_string(), "".to_string()), + 134 => DataInfo::new("Carger State".to_string(), "".to_string()), + 135 => DataInfo::new("Measurement System Valid".to_string(), "".to_string()), + 136 => DataInfo::new("System Status".to_string(), "".to_string()), + 137 => DataInfo::new("Charge Status".to_string(), "".to_string()), + 138 => DataInfo::new("ibat".to_string(), "A".to_string()), + 139 => DataInfo::new("vbat".to_string(), "V".to_string()), + 140 => DataInfo::new("vin".to_string(), "V".to_string()), + 141 => DataInfo::new("vsys".to_string(), "V".to_string()), + 142 => DataInfo::new("iin".to_string(), "A".to_string()), + 143 => DataInfo::new("Cell Burning Status".to_string(), "".to_string()), + 144 => DataInfo::new("Traction Control On".to_string(), "".to_string()), + 145 => DataInfo::new("Precharge State".to_string(), "".to_string()), + 146 => DataInfo::new("BMS Prefault Status".to_string(), "".to_string()), + _ => DataInfo::new("".to_string(), "".to_string()), } } +*/ diff --git a/src/message.rs b/src/message.rs index 35aacec..f75cfa9 100644 --- a/src/message.rs +++ b/src/message.rs @@ -6,23 +6,23 @@ use super::master_mapping::get_message_info; /** * Wrapper class for an individual message. */ -pub struct Message<'a> { +pub struct Message { timestamp: DateTime, id: u32, - data: &'a [u8], + data: Vec, } /** - * Implementation of Message. Static memory allocation. + * Implementation of Message. */ -impl<'a> Message<'a> { +impl Message { /** * Creates a new message with the given timestamp, id, and data. */ - pub fn new(timestamp: &DateTime, id: &u32, data: &'a [u8]) -> Self { + pub fn new(timestamp: DateTime, id: u32, data: Vec) -> Self { Self { - timestamp: *timestamp, - id: *id, + timestamp, + id, data, } } @@ -49,6 +49,6 @@ impl<'a> Message<'a> { for (data_id, value) in result { decoded_data.push(Data::new(*timestamp, data_id, value)); } - return decoded_data; + decoded_data } } diff --git a/src/mqtt.rs b/src/mqtt.rs index 5404201..84f0377 100644 --- a/src/mqtt.rs +++ b/src/mqtt.rs @@ -25,7 +25,7 @@ impl Client for MqttClient { * param data: The data object to format and send. */ fn publish(&mut self, data: &Data) { - let topic = format!("/Calypso"); + let topic = "/Calypso".to_string(); let payload = data.value.to_string(); /* If the client is initialized, publish the data. */ @@ -34,9 +34,12 @@ impl Client for MqttClient { .topic(topic) .payload(payload) .finalize(); - client.publish(msg).unwrap(); + + match { client.publish(msg) } { + Ok(_) => (), + Err(e) => println!("Error sending message: {:?}", e), + } thread::sleep(Duration::from_millis(1)); - return; } else { println!("Client not initialized, please set host first and connect") } @@ -52,6 +55,18 @@ impl Client for MqttClient { } } +impl Default for MqttClient { + /** + * Creates a new MqttClient. + */ + fn default() -> Self { + Self::new() + } +} + +/** + * Implementation of the MqttClient struct. + */ impl MqttClient { /** * Creates a new MqttClient. @@ -59,6 +74,7 @@ impl MqttClient { pub fn new() -> MqttClient { MqttClient { client: None } } + /** * Creates a new MqttClient with the given host name. * param host_name: The host name of the broker. @@ -68,10 +84,13 @@ impl MqttClient { .server_uri(host_name) .client_id(DFLT_CLIENT.to_string()) .finalize(); - self.client = Some(mqtt::Client::new(create_options).unwrap_or_else(|err| { - println!("Error creating the client: {:?}", err); - process::exit(1); - })); + self.client = Some(match { mqtt::Client::new(create_options) } { + Ok(client) => client, + Err(e) => { + println!("Error creating the client: {:?}", e); + process::exit(1); + } + }); } /** @@ -117,9 +136,9 @@ impl MqttClient { if let Some(client) = &self.client { client.reconnect() } else { - Err(mqtt::Error::from(mqtt::Error::General( + Err(mqtt::Error::General( "Client not initialized, please set host first", - ))) + )) } } @@ -130,9 +149,9 @@ impl MqttClient { if let Some(client) = &self.client { client.disconnect(None) } else { - Err(mqtt::Error::from(mqtt::Error::General( + Err(mqtt::Error::General( "Client not initialized, please set host first", - ))) + )) } } } diff --git a/src/socket.rs b/src/socket.rs index e8ce150..81090cf 100644 --- a/src/socket.rs +++ b/src/socket.rs @@ -36,6 +36,15 @@ impl Client for IPCConnection { } } +impl Default for IPCConnection { + /** + * Creates a new IPCConnection. + */ + fn default() -> Self { + Self::new() + } +} + impl IPCConnection { /** * Creates a new IPCConnection. @@ -49,12 +58,7 @@ impl IPCConnection { */ fn send(&mut self, data: &Data) { if let Some(stream) = &mut self.stream { - let cloned_data = data.clone(); // Clone the data - let message = format!( - "{{index:{},value:{}}}", - cloned_data.id.to_string(), - cloned_data.value.to_string() - ); + let message = format!("{{index:{},value:{}}}", data.id, data.value); stream .write_all(message.as_bytes()) .unwrap_or_else(|_| println!("Failed to send message, is NERO running?")); From e95f5bb49d2c4f3840606a85a5b10cb6deb184ef Mon Sep 17 00:00:00 2001 From: Peyton-McKee Date: Fri, 1 Dec 2023 00:48:16 -0500 Subject: [PATCH 26/41] #22 Remove Unused Dependencies --- Cargo.lock | 2893 ++++++---------------------------------------------- Cargo.toml | 11 +- 2 files changed, 318 insertions(+), 2586 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7f3edce..6471bd0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,42 +2,6 @@ # It is not intended for manual editing. version = 3 -[[package]] -name = "aho-corasick" -version = "0.7.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" -dependencies = [ - "memchr", -] - -[[package]] -name = "aho-corasick" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" -dependencies = [ - "memchr", -] - -[[package]] -name = "android_system_properties" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" -dependencies = [ - "libc", -] - -[[package]] -name = "ansi_term" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" -dependencies = [ - "winapi 0.3.9", -] - [[package]] name = "approx" version = "0.5.1" @@ -47,16 +11,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "async-broadcast" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c48ccdbf6ca6b121e0f586cbc0e73ae440e56c67c30fa0873b4e110d9c26d2b" -dependencies = [ - "event-listener 2.5.3", - "futures-core", -] - [[package]] name = "async-channel" version = "1.9.0" @@ -64,186 +18,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35" dependencies = [ "concurrent-queue", - "event-listener 2.5.3", - "futures-core", -] - -[[package]] -name = "async-channel" -version = "2.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ca33f4bc4ed1babef42cad36cc1f51fa88be00420404e5b1e80ab1b18f7678c" -dependencies = [ - "concurrent-queue", - "event-listener 4.0.0", - "event-listener-strategy", - "futures-core", - "pin-project-lite", -] - -[[package]] -name = "async-executor" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17ae5ebefcc48e7452b4987947920dac9450be1110cadf34d1b8c116bdbaf97c" -dependencies = [ - "async-lock 3.1.2", - "async-task", - "concurrent-queue", - "fastrand 2.0.1", - "futures-lite 2.0.1", - "slab", -] - -[[package]] -name = "async-fs" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "279cf904654eeebfa37ac9bb1598880884924aab82e290aa65c9e77a0e142e06" -dependencies = [ - "async-lock 2.8.0", - "autocfg", - "blocking", - "futures-lite 1.13.0", -] - -[[package]] -name = "async-io" -version = "1.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fc5b45d93ef0529756f812ca52e44c221b35341892d3dcc34132ac02f3dd2af" -dependencies = [ - "async-lock 2.8.0", - "autocfg", - "cfg-if 1.0.0", - "concurrent-queue", - "futures-lite 1.13.0", - "log", - "parking", - "polling 2.8.0", - "rustix 0.37.27", - "slab", - "socket2", - "waker-fn", -] - -[[package]] -name = "async-io" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6d3b15875ba253d1110c740755e246537483f152fa334f91abd7fe84c88b3ff" -dependencies = [ - "async-lock 3.1.2", - "cfg-if 1.0.0", - "concurrent-queue", - "futures-io", - "futures-lite 2.0.1", - "parking", - "polling 3.3.1", - "rustix 0.38.26", - "slab", - "tracing", - "windows-sys 0.52.0", -] - -[[package]] -name = "async-lock" -version = "2.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "287272293e9d8c41773cec55e365490fe034813a2f172f502d6ddcf75b2f582b" -dependencies = [ - "event-listener 2.5.3", -] - -[[package]] -name = "async-lock" -version = "3.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dea8b3453dd7cc96711834b75400d671b73e3656975fa68d9f277163b7f7e316" -dependencies = [ - "event-listener 4.0.0", - "event-listener-strategy", - "pin-project-lite", -] - -[[package]] -name = "async-process" -version = "1.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea6438ba0a08d81529c69b36700fa2f95837bfe3e776ab39cde9c14d9149da88" -dependencies = [ - "async-io 1.13.0", - "async-lock 2.8.0", - "async-signal", - "blocking", - "cfg-if 1.0.0", - "event-listener 3.1.0", - "futures-lite 1.13.0", - "rustix 0.38.26", - "windows-sys 0.48.0", -] - -[[package]] -name = "async-recursion" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fd55a5ba1179988837d24ab4c7cc8ed6efdeff578ede0416b4225a5fca35bd0" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.39", -] - -[[package]] -name = "async-signal" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e47d90f65a225c4527103a8d747001fc56e375203592b25ad103e1ca13124c5" -dependencies = [ - "async-io 2.2.1", - "async-lock 2.8.0", - "atomic-waker", - "cfg-if 1.0.0", + "event-listener", "futures-core", - "futures-io", - "rustix 0.38.26", - "signal-hook-registry", - "slab", - "windows-sys 0.48.0", -] - -[[package]] -name = "async-task" -version = "4.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4eb2cdb97421e01129ccb49169d8279ed21e829929144f4a22a6e54ac549ca1" - -[[package]] -name = "async-trait" -version = "0.1.74" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a66537f1bb974b254c98ed142ff995236e81b9d0fe4db0575f46612cb15eb0f9" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.39", -] - -[[package]] -name = "atomic-waker" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" - -[[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi 0.1.19", - "libc", - "winapi 0.3.9", ] [[package]] @@ -252,12 +28,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" -[[package]] -name = "bitflags" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8dead7461c1127cf637931a1e50934eb6eee8bff2f74433ac7909e9afcee04a3" - [[package]] name = "bitflags" version = "1.3.2" @@ -265,62 +35,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] -name = "bitflags" -version = "2.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" - -[[package]] -name = "block" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" - -[[package]] -name = "block-buffer" -version = "0.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" -dependencies = [ - "generic-array", -] - -[[package]] -name = "blocking" -version = "1.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a37913e8dc4ddcc604f0c6d3bf2887c995153af3611de9e23c352b44c1b9118" -dependencies = [ - "async-channel 2.1.1", - "async-lock 3.1.2", - "async-task", - "fastrand 2.0.1", - "futures-io", - "futures-lite 2.0.1", - "piper", - "tracing", -] - -[[package]] -name = "bstr" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223" -dependencies = [ - "memchr", -] - -[[package]] -name = "bumpalo" -version = "3.12.1" +name = "byte_conv" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b1ce199063694f33ffb7dd4e0ee620741495c32833cde5aa08f02a0bf96f0c8" +checksum = "649972315d4931137a26fc2bf3ca95ee257ad796a5b57bdeb04205c91a4b5780" [[package]] name = "bytemuck" -version = "1.13.1" +version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17febce684fd15d89027105661fec94afb475cb995fbc59d2865198446ba2eea" +checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6" [[package]] name = "byteorder" @@ -328,2552 +52,567 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" -[[package]] -name = "bytesize" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38fcc2979eff34a4b84e1cf9a1e3da42a7d44b3b690a40cdcb23e3d556cfb2e5" - [[package]] name = "calypso" version = "0.1.0" dependencies = [ - "cargo-watch", - "chrono", - "matrixmultiply", "nalgebra", "paho-mqtt", - "rayon", "socketcan", - "systemstat", - "transpose", ] [[package]] -name = "camino" -version = "1.1.6" +name = "cc" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c59e92b5a388f549b863a7bea62612c09f24c8393560709a54558a9abdfb3b9c" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" dependencies = [ - "serde", + "libc", ] [[package]] -name = "cargo-platform" -version = "0.1.5" +name = "cfg-if" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e34637b3140142bdf929fb439e8aa4ebad7651ebf7b1080b3930aa16ac1459ff" -dependencies = [ - "serde", -] +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] -name = "cargo-watch" -version = "8.4.1" +name = "cmake" +version = "0.1.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "554cae2dad0147ef6cb36eb8b3347648a00762dc110af8d76d5c793fe9378f11" +checksum = "a31c789563b815f77f4250caee12365734369f942439b7defd71e18a48197130" dependencies = [ - "camino", - "cargo_metadata", - "clap", - "dotenvy", - "log", - "notify-rust", - "shell-escape", - "stderrlog", - "watchexec", + "cc", ] [[package]] -name = "cargo_metadata" -version = "0.17.0" +name = "concurrent-queue" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7daec1a2a2129eeba1644b220b4647ec537b0b5d4bfd6876fcc5a540056b592" +checksum = "f057a694a54f12365049b0958a1685bb52d567f5593b355fbf685838e873d400" dependencies = [ - "camino", - "cargo-platform", - "semver", - "serde", - "serde_json", - "thiserror", + "crossbeam-utils", ] [[package]] -name = "cc" -version = "1.0.79" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" - -[[package]] -name = "cfg-if" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "chrono" -version = "0.4.24" +name = "crossbeam-channel" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e3c5919066adf22df73762e50cffcde3a758f2a848b113b586d1f86728b673b" +checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" dependencies = [ - "iana-time-zone", - "js-sys", - "num-integer", - "num-traits", - "time 0.1.45", - "wasm-bindgen", - "winapi 0.3.9", + "cfg-if", + "crossbeam-utils", ] [[package]] -name = "clap" -version = "2.34.0" +name = "crossbeam-utils" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" +checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" dependencies = [ - "ansi_term", - "atty", - "bitflags 1.3.2", - "strsim 0.8.0", - "textwrap", - "unicode-width", - "vec_map", + "cfg-if", ] [[package]] -name = "clearscreen" -version = "1.0.11" +name = "either" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e55dadbdd203f69c0a107bc78fca6e47d605345610ee77dcf24203fdf510b317" -dependencies = [ - "nix 0.24.3", - "terminfo", - "thiserror", - "which", - "winapi 0.3.9", -] +checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" [[package]] -name = "cmake" -version = "0.1.50" +name = "embedded-can" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a31c789563b815f77f4250caee12365734369f942439b7defd71e18a48197130" +checksum = "e9d2e857f87ac832df68fa498d18ddc679175cf3d2e4aa893988e5601baf9438" dependencies = [ - "cc", + "nb", ] [[package]] -name = "codespan-reporting" -version = "0.11.1" +name = "event-listener" +version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" -dependencies = [ - "termcolor", - "unicode-width", -] +checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" [[package]] -name = "command-group" -version = "1.0.8" +name = "futures" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7a8a86f409b4a59df3a3e4bee2de0b83f1755fdd2a25e3a9684c396fc4bed2c" +checksum = "da0290714b38af9b4a7b094b8a37086d1b4e61f2df9122c3cad2577669145335" dependencies = [ - "nix 0.22.3", - "winapi 0.3.9", + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", ] [[package]] -name = "concurrent-queue" -version = "2.3.0" +name = "futures-channel" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f057a694a54f12365049b0958a1685bb52d567f5593b355fbf685838e873d400" +checksum = "ff4dd66668b557604244583e3e1e1eada8c5c2e96a6d0d6653ede395b78bbacb" dependencies = [ - "crossbeam-utils", + "futures-core", + "futures-sink", ] [[package]] -name = "core-foundation-sys" -version = "0.8.4" +name = "futures-core" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" +checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c" [[package]] -name = "cpufeatures" -version = "0.2.11" +name = "futures-executor" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce420fe07aecd3e67c5f910618fe65e94158f6dcc0adf44e00d69ce2bdfe0fd0" +checksum = "0f4fb8693db0cf099eadcca0efe2a5a22e4550f98ed16aba6c48700da29597bc" dependencies = [ - "libc", + "futures-core", + "futures-task", + "futures-util", ] [[package]] -name = "crossbeam-channel" -version = "0.5.8" +name = "futures-io" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" -dependencies = [ - "cfg-if 1.0.0", - "crossbeam-utils", -] +checksum = "8bf34a163b5c4c52d0478a4d757da8fb65cabef42ba90515efee0f6f9fa45aaa" [[package]] -name = "crossbeam-deque" -version = "0.8.3" +name = "futures-macro" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" +checksum = "53b153fd91e4b0147f4aced87be237c98248656bb01050b96bf3ee89220a8ddb" dependencies = [ - "cfg-if 1.0.0", - "crossbeam-epoch", - "crossbeam-utils", + "proc-macro2", + "quote", + "syn 2.0.39", ] [[package]] -name = "crossbeam-epoch" -version = "0.9.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46bd5f3f85273295a9d14aedfb86f6aadbff6d8f5295c4a9edb08e819dcf5695" -dependencies = [ - "autocfg", - "cfg-if 1.0.0", - "crossbeam-utils", - "memoffset 0.8.0", - "scopeguard", -] - -[[package]] -name = "crossbeam-utils" -version = "0.8.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c063cd8cc95f5c377ed0d4b49a4b21f632396ff690e8470c29b3359b346984b" -dependencies = [ - "cfg-if 1.0.0", -] - -[[package]] -name = "crypto-common" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" -dependencies = [ - "generic-array", - "typenum", -] - -[[package]] -name = "cxx" -version = "1.0.94" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f61f1b6389c3fe1c316bf8a4dccc90a38208354b330925bce1f74a6c4756eb93" -dependencies = [ - "cc", - "cxxbridge-flags", - "cxxbridge-macro", - "link-cplusplus", -] - -[[package]] -name = "cxx-build" -version = "1.0.94" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12cee708e8962df2aeb38f594aae5d827c022b6460ac71a7a3e2c3c2aae5a07b" -dependencies = [ - "cc", - "codespan-reporting", - "once_cell", - "proc-macro2", - "quote", - "scratch", - "syn 2.0.39", -] - -[[package]] -name = "cxxbridge-flags" -version = "1.0.94" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7944172ae7e4068c533afbb984114a56c46e9ccddda550499caa222902c7f7bb" - -[[package]] -name = "cxxbridge-macro" -version = "1.0.94" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2345488264226bf682893e25de0769f3360aac9957980ec49361b083ddaa5bc5" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.39", -] - -[[package]] -name = "darling" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f2c43f534ea4b0b049015d00269734195e6d3f0f6635cb692251aca6f9f8b3c" -dependencies = [ - "darling_core", - "darling_macro", -] - -[[package]] -name = "darling_core" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e91455b86830a1c21799d94524df0845183fa55bafd9aa137b01c7d1065fa36" -dependencies = [ - "fnv", - "ident_case", - "proc-macro2", - "quote", - "strsim 0.10.0", - "syn 1.0.109", -] - -[[package]] -name = "darling_macro" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29b5acf0dea37a7f66f7b25d2c5e93fd46f8f6968b1a5d7a3e02e97768afc95a" -dependencies = [ - "darling_core", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "derivative" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "derive_builder" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d13202debe11181040ae9063d739fa32cfcaaebe2275fe387703460ae2365b30" -dependencies = [ - "derive_builder_macro", -] - -[[package]] -name = "derive_builder_core" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66e616858f6187ed828df7c64a6d71720d83767a7f19740b2d1b6fe6327b36e5" -dependencies = [ - "darling", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "derive_builder_macro" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58a94ace95092c5acb1e97a7e846b310cfbd499652f72297da7493f618a98d73" -dependencies = [ - "derive_builder_core", - "syn 1.0.109", -] - -[[package]] -name = "digest" -version = "0.10.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" -dependencies = [ - "block-buffer", - "crypto-common", -] - -[[package]] -name = "dirs" -version = "4.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" -dependencies = [ - "dirs-sys", -] - -[[package]] -name = "dirs-next" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" -dependencies = [ - "cfg-if 1.0.0", - "dirs-sys-next", -] - -[[package]] -name = "dirs-sys" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" -dependencies = [ - "libc", - "redox_users", - "winapi 0.3.9", -] - -[[package]] -name = "dirs-sys-next" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" -dependencies = [ - "libc", - "redox_users", - "winapi 0.3.9", -] - -[[package]] -name = "dotenvy" -version = "0.15.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" - -[[package]] -name = "either" -version = "1.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" - -[[package]] -name = "enumflags2" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5998b4f30320c9d93aed72f63af821bfdac50465b75428fce77b48ec482c3939" -dependencies = [ - "enumflags2_derive", - "serde", -] - -[[package]] -name = "enumflags2_derive" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f95e2801cd355d4a1a3e3953ce6ee5ae9603a5c833455343a8bfe3f44d418246" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.39", -] - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "errno" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" -dependencies = [ - "libc", - "windows-sys 0.52.0", -] - -[[package]] -name = "event-listener" -version = "2.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" - -[[package]] -name = "event-listener" -version = "3.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d93877bcde0eb80ca09131a08d23f0a5c18a620b01db137dba666d18cd9b30c2" -dependencies = [ - "concurrent-queue", - "parking", - "pin-project-lite", -] - -[[package]] -name = "event-listener" -version = "4.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "770d968249b5d99410d61f5bf89057f3199a077a04d087092f58e7d10692baae" -dependencies = [ - "concurrent-queue", - "parking", - "pin-project-lite", -] - -[[package]] -name = "event-listener-strategy" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "958e4d70b6d5e81971bebec42271ec641e7ff4e170a6fa605f2b8a8b65cb97d3" -dependencies = [ - "event-listener 4.0.0", - "pin-project-lite", -] - -[[package]] -name = "fastrand" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" -dependencies = [ - "instant", -] - -[[package]] -name = "fastrand" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" - -[[package]] -name = "filetime" -version = "0.2.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4029edd3e734da6fe05b6cd7bd2960760a616bd2ddd0d59a0124746d6272af0" -dependencies = [ - "cfg-if 1.0.0", - "libc", - "redox_syscall 0.3.5", - "windows-sys 0.48.0", -] - -[[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - -[[package]] -name = "fsevent" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ab7d1bd1bd33cc98b0889831b72da23c0aa4df9cec7e0702f46ecea04b35db6" -dependencies = [ - "bitflags 1.3.2", - "fsevent-sys", -] - -[[package]] -name = "fsevent-sys" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f41b048a94555da0f42f1d632e2e19510084fb8e303b0daa2816e733fb3644a0" -dependencies = [ - "libc", -] - -[[package]] -name = "fuchsia-zircon" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" -dependencies = [ - "bitflags 1.3.2", - "fuchsia-zircon-sys", -] - -[[package]] -name = "fuchsia-zircon-sys" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" - -[[package]] -name = "futures" -version = "0.3.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da0290714b38af9b4a7b094b8a37086d1b4e61f2df9122c3cad2577669145335" -dependencies = [ - "futures-channel", - "futures-core", - "futures-executor", - "futures-io", - "futures-sink", - "futures-task", - "futures-util", -] - -[[package]] -name = "futures-channel" -version = "0.3.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff4dd66668b557604244583e3e1e1eada8c5c2e96a6d0d6653ede395b78bbacb" -dependencies = [ - "futures-core", - "futures-sink", -] - -[[package]] -name = "futures-core" -version = "0.3.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c" - -[[package]] -name = "futures-executor" -version = "0.3.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f4fb8693db0cf099eadcca0efe2a5a22e4550f98ed16aba6c48700da29597bc" -dependencies = [ - "futures-core", - "futures-task", - "futures-util", -] - -[[package]] -name = "futures-io" -version = "0.3.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bf34a163b5c4c52d0478a4d757da8fb65cabef42ba90515efee0f6f9fa45aaa" - -[[package]] -name = "futures-lite" -version = "1.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49a9d51ce47660b1e808d3c990b4709f2f415d928835a17dfd16991515c46bce" -dependencies = [ - "fastrand 1.9.0", - "futures-core", - "futures-io", - "memchr", - "parking", - "pin-project-lite", - "waker-fn", -] - -[[package]] -name = "futures-lite" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3831c2651acb5177cbd83943f3d9c8912c5ad03c76afcc0e9511ba568ec5ebb" -dependencies = [ - "fastrand 2.0.1", - "futures-core", - "futures-io", - "memchr", - "parking", - "pin-project-lite", -] - -[[package]] -name = "futures-macro" -version = "0.3.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53b153fd91e4b0147f4aced87be237c98248656bb01050b96bf3ee89220a8ddb" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.39", -] - -[[package]] -name = "futures-sink" +name = "futures-sink" version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e36d3378ee38c2a36ad710c5d30c2911d752cb941c00c72dbabfb786a7970817" [[package]] -name = "futures-task" -version = "0.3.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efd193069b0ddadc69c46389b740bbccdd97203899b48d09c5f7969591d6bae2" - -[[package]] -name = "futures-timer" -version = "3.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" - -[[package]] -name = "futures-util" -version = "0.3.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104" -dependencies = [ - "futures-channel", - "futures-core", - "futures-io", - "futures-macro", - "futures-sink", - "futures-task", - "memchr", - "pin-project-lite", - "pin-utils", - "slab", -] - -[[package]] -name = "generic-array" -version = "0.14.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" -dependencies = [ - "typenum", - "version_check", -] - -[[package]] -name = "getrandom" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" -dependencies = [ - "cfg-if 1.0.0", - "libc", - "wasi 0.11.0+wasi-snapshot-preview1", -] - -[[package]] -name = "glob" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" - -[[package]] -name = "globset" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c152169ef1e421390738366d2f796655fec62621dabbd0fd476f905934061e4a" -dependencies = [ - "aho-corasick 0.7.20", - "bstr", - "fnv", - "log", - "regex", -] - -[[package]] -name = "hashbrown" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" - -[[package]] -name = "hermit-abi" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] - -[[package]] -name = "hermit-abi" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" -dependencies = [ - "libc", -] - -[[package]] -name = "hermit-abi" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" - -[[package]] -name = "hex" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6a22814455d41612f41161581c2883c0c6a1c41852729b17d5ed88f01e153aa" - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - -[[package]] -name = "home" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb" -dependencies = [ - "windows-sys 0.48.0", -] - -[[package]] -name = "iana-time-zone" -version = "0.1.56" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0722cd7114b7de04316e7ea5456a0bbb20e4adb46fd27a3697adb812cff0f37c" -dependencies = [ - "android_system_properties", - "core-foundation-sys", - "iana-time-zone-haiku", - "js-sys", - "wasm-bindgen", - "windows 0.48.0", -] - -[[package]] -name = "iana-time-zone-haiku" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca" -dependencies = [ - "cxx", - "cxx-build", -] - -[[package]] -name = "ident_case" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" - -[[package]] -name = "indexmap" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" -dependencies = [ - "equivalent", - "hashbrown", -] - -[[package]] -name = "inotify" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4816c66d2c8ae673df83366c18341538f234a26d65a9ecea5c348b453ac1d02f" -dependencies = [ - "bitflags 1.3.2", - "inotify-sys", - "libc", -] - -[[package]] -name = "inotify-sys" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e05c02b5e89bff3b946cedeca278abc628fe811e604f027c45a8aa3cf793d0eb" -dependencies = [ - "libc", -] - -[[package]] -name = "instant" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" -dependencies = [ - "cfg-if 1.0.0", -] - -[[package]] -name = "io-lifetimes" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" -dependencies = [ - "hermit-abi 0.3.3", - "libc", - "windows-sys 0.48.0", -] - -[[package]] -name = "iovec" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" -dependencies = [ - "libc", -] - -[[package]] -name = "itertools" -version = "0.4.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4a9b56eb56058f43dc66e58f40a214b2ccbc9f3df51861b63d51dec7b65bc3f" - -[[package]] -name = "itoa" -version = "1.0.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" - -[[package]] -name = "js-sys" -version = "0.3.61" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "445dde2150c55e483f3d8416706b97ec8e8237c307e5b7b4b8dd15e6af2a0730" -dependencies = [ - "wasm-bindgen", -] - -[[package]] -name = "kernel32-sys" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" -dependencies = [ - "winapi 0.2.8", - "winapi-build", -] - -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - -[[package]] -name = "lazycell" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" - -[[package]] -name = "libc" -version = "0.2.150" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" - -[[package]] -name = "libredox" -version = "0.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" -dependencies = [ - "bitflags 2.4.1", - "libc", - "redox_syscall 0.4.1", -] - -[[package]] -name = "link-cplusplus" -version = "1.0.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecd207c9c713c34f95a097a5b029ac2ce6010530c7b49d7fea24d977dede04f5" -dependencies = [ - "cc", -] - -[[package]] -name = "linux-raw-sys" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" - -[[package]] -name = "linux-raw-sys" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" - -[[package]] -name = "log" -version = "0.4.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" -dependencies = [ - "cfg-if 1.0.0", -] - -[[package]] -name = "mac-notification-sys" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51fca4d74ff9dbaac16a01b924bc3693fa2bba0862c2c633abc73f9a8ea21f64" -dependencies = [ - "cc", - "dirs-next", - "objc-foundation", - "objc_id", - "time 0.3.20", -] - -[[package]] -name = "malloc_buf" -version = "0.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb" -dependencies = [ - "libc", -] - -[[package]] -name = "matrixmultiply" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb99c395ae250e1bf9133673f03ca9f97b7e71b705436bf8f089453445d1e9fe" -dependencies = [ - "rawpointer", -] - -[[package]] -name = "memchr" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" - -[[package]] -name = "memoffset" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" -dependencies = [ - "autocfg", -] - -[[package]] -name = "memoffset" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" -dependencies = [ - "autocfg", -] - -[[package]] -name = "memoffset" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d61c719bcfbcf5d62b3a09efa6088de8c54bc0bfcd3ea7ae39fcc186108b8de1" -dependencies = [ - "autocfg", -] - -[[package]] -name = "minimal-lexical" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" - -[[package]] -name = "mio" -version = "0.6.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4afd66f5b91bf2a3bc13fad0e21caedac168ca4c707504e75585648ae80e4cc4" -dependencies = [ - "cfg-if 0.1.10", - "fuchsia-zircon", - "fuchsia-zircon-sys", - "iovec", - "kernel32-sys", - "libc", - "log", - "miow", - "net2", - "slab", - "winapi 0.2.8", -] - -[[package]] -name = "mio-extras" -version = "2.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52403fe290012ce777c4626790c8951324a2b9e3316b3143779c72b029742f19" -dependencies = [ - "lazycell", - "log", - "mio", - "slab", -] - -[[package]] -name = "miow" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebd808424166322d4a38da87083bfddd3ac4c131334ed55856112eb06d46944d" -dependencies = [ - "kernel32-sys", - "net2", - "winapi 0.2.8", - "ws2_32-sys", -] - -[[package]] -name = "nalgebra" -version = "0.32.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d68d47bba83f9e2006d117a9a33af1524e655516b8919caac694427a6fb1e511" -dependencies = [ - "approx", - "matrixmultiply", - "nalgebra-macros", - "num-complex", - "num-rational", - "num-traits", - "simba", - "typenum", -] - -[[package]] -name = "nalgebra-macros" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d232c68884c0c99810a5a4d333ef7e47689cfd0edc85efc9e54e1e6bf5212766" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "net2" -version = "0.2.39" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b13b648036a2339d06de780866fbdfda0dde886de7b3af2ddeba8b14f4ee34ac" -dependencies = [ - "cfg-if 0.1.10", - "libc", - "winapi 0.3.9", -] - -[[package]] -name = "nix" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfb3ddedaa14746434a02041940495bf11325c22f6d36125d3bdd56090d50a79" -dependencies = [ - "bitflags 0.4.0", - "libc", -] - -[[package]] -name = "nix" -version = "0.22.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4916f159ed8e5de0082076562152a76b7a1f64a01fd9d1e0fea002c37624faf" -dependencies = [ - "bitflags 1.3.2", - "cc", - "cfg-if 1.0.0", - "libc", - "memoffset 0.6.5", -] - -[[package]] -name = "nix" -version = "0.24.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069" -dependencies = [ - "bitflags 1.3.2", - "cfg-if 1.0.0", - "libc", -] - -[[package]] -name = "nix" -version = "0.26.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b" -dependencies = [ - "bitflags 1.3.2", - "cfg-if 1.0.0", - "libc", - "memoffset 0.7.1", -] - -[[package]] -name = "nom" -version = "5.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08959a387a676302eebf4ddbcbc611da04285579f76f88ee0506c63b1a61dd4b" -dependencies = [ - "memchr", - "version_check", -] - -[[package]] -name = "nom" -version = "7.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" -dependencies = [ - "memchr", - "minimal-lexical", -] - -[[package]] -name = "notify" -version = "4.0.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae03c8c853dba7bfd23e571ff0cff7bc9dceb40a4cd684cd1681824183f45257" -dependencies = [ - "bitflags 1.3.2", - "filetime", - "fsevent", - "fsevent-sys", - "inotify", - "libc", - "mio", - "mio-extras", - "walkdir", - "winapi 0.3.9", -] - -[[package]] -name = "notify-rust" -version = "4.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "827c5edfa80235ded4ab3fe8e9dc619b4f866ef16fe9b1c6b8a7f8692c0f2226" -dependencies = [ - "log", - "mac-notification-sys", - "serde", - "tauri-winrt-notification", - "zbus", -] - -[[package]] -name = "num-complex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02e0d21255c828d6f128a1e41534206671e8c3ea0c62f32291e808dc82cff17d" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-integer" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" -dependencies = [ - "autocfg", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" -dependencies = [ - "autocfg", -] - -[[package]] -name = "num_cpus" -version = "1.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" -dependencies = [ - "hermit-abi 0.2.6", - "libc", -] - -[[package]] -name = "objc" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1" -dependencies = [ - "malloc_buf", -] - -[[package]] -name = "objc-foundation" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1add1b659e36c9607c7aab864a76c7a4c2760cd0cd2e120f3fb8b952c7e22bf9" -dependencies = [ - "block", - "objc", - "objc_id", -] - -[[package]] -name = "objc_id" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c92d4ddb4bd7b50d730c215ff871754d0da6b2178849f8a2a2ab69712d0c073b" -dependencies = [ - "objc", -] - -[[package]] -name = "once_cell" -version = "1.17.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" - -[[package]] -name = "openssl-sys" -version = "0.9.96" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3812c071ba60da8b5677cc12bcb1d42989a65553772897a7e0355545a819838f" -dependencies = [ - "cc", - "libc", - "pkg-config", - "vcpkg", -] - -[[package]] -name = "ordered-stream" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aa2b01e1d916879f73a53d01d1d6cee68adbb31d6d9177a8cfce093cced1d50" -dependencies = [ - "futures-core", - "pin-project-lite", -] - -[[package]] -name = "paho-mqtt" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19e405de34b835fb6457d8b0169eda21949f855472b3e346556af9e29fac6eb2" -dependencies = [ - "async-channel 1.9.0", - "crossbeam-channel", - "futures", - "futures-timer", - "libc", - "log", - "paho-mqtt-sys", - "thiserror", -] - -[[package]] -name = "paho-mqtt-sys" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e482419d847af4ec43c07eed70f5f94f87dc712d267aecc91ab940944ab6bf4" -dependencies = [ - "cmake", - "openssl-sys", -] - -[[package]] -name = "parking" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb813b8af86854136c6922af0598d719255ecb2179515e6e7730d468f05c9cae" - -[[package]] -name = "paste" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f746c4065a8fa3fe23974dd82f15431cc8d40779821001404d10d2e79ca7d79" - -[[package]] -name = "phf" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ade2d8b8f33c7333b51bcf0428d37e217e9f32192ae4772156f65063b8ce03dc" -dependencies = [ - "phf_shared", -] - -[[package]] -name = "phf_codegen" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8d39688d359e6b34654d328e262234662d16cc0f60ec8dcbe5e718709342a5a" -dependencies = [ - "phf_generator", - "phf_shared", -] - -[[package]] -name = "phf_generator" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48e4cc64c2ad9ebe670cb8fd69dd50ae301650392e81c05f9bfcb2d5bdbc24b0" -dependencies = [ - "phf_shared", - "rand", -] - -[[package]] -name = "phf_shared" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90fcb95eef784c2ac79119d1dd819e162b5da872ce6f3c3abe1e8ca1c082f72b" -dependencies = [ - "siphasher", -] - -[[package]] -name = "pin-project-lite" -version = "0.2.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" - -[[package]] -name = "pin-utils" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" - -[[package]] -name = "piper" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "668d31b1c4eba19242f2088b2bf3316b82ca31082a8335764db4e083db7485d4" -dependencies = [ - "atomic-waker", - "fastrand 2.0.1", - "futures-io", -] - -[[package]] -name = "pkg-config" -version = "0.3.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" - -[[package]] -name = "polling" -version = "2.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b2d323e8ca7996b3e23126511a523f7e62924d93ecd5ae73b333815b0eb3dce" -dependencies = [ - "autocfg", - "bitflags 1.3.2", - "cfg-if 1.0.0", - "concurrent-queue", - "libc", - "log", - "pin-project-lite", - "windows-sys 0.48.0", -] - -[[package]] -name = "polling" -version = "3.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf63fa624ab313c11656b4cda960bfc46c410187ad493c41f6ba2d8c1e991c9e" -dependencies = [ - "cfg-if 1.0.0", - "concurrent-queue", - "pin-project-lite", - "rustix 0.38.26", - "tracing", - "windows-sys 0.52.0", -] - -[[package]] -name = "ppv-lite86" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" - -[[package]] -name = "proc-macro-crate" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" -dependencies = [ - "once_cell", - "toml_edit", -] - -[[package]] -name = "proc-macro2" -version = "1.0.70" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quick-xml" -version = "0.30.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eff6510e86862b57b210fd8cbe8ed3f0d7d600b9c2863cd4549a2e033c66e956" -dependencies = [ - "memchr", -] - -[[package]] -name = "quote" -version = "1.0.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "libc", - "rand_chacha", - "rand_core", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core", -] - -[[package]] -name = "rand_core" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" -dependencies = [ - "getrandom", -] - -[[package]] -name = "rawpointer" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" - -[[package]] -name = "rayon" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d2df5196e37bcc87abebc0053e20787d73847bb33134a69841207dd0a47f03b" -dependencies = [ - "either", - "rayon-core", -] - -[[package]] -name = "rayon-core" -version = "1.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b8f95bd6966f5c87776639160a66bd8ab9895d9d4ab01ddba9fc60661aebe8d" -dependencies = [ - "crossbeam-channel", - "crossbeam-deque", - "crossbeam-utils", - "num_cpus", -] - -[[package]] -name = "redox_syscall" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" -dependencies = [ - "bitflags 1.3.2", -] - -[[package]] -name = "redox_syscall" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" -dependencies = [ - "bitflags 1.3.2", -] - -[[package]] -name = "redox_users" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a18479200779601e498ada4e8c1e1f50e3ee19deb0259c25825a98b5603b2cb4" -dependencies = [ - "getrandom", - "libredox", - "thiserror", -] - -[[package]] -name = "regex" -version = "1.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12de2eff854e5fa4b1295edd650e227e9d8fb0c9e90b12e7f36d6a6811791a29" -dependencies = [ - "aho-corasick 1.1.2", - "memchr", - "regex-automata", - "regex-syntax", -] - -[[package]] -name = "regex-automata" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49530408a136e16e5b486e883fbb6ba058e8e4e8ae6621a77b048b314336e629" -dependencies = [ - "aho-corasick 1.1.2", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" - -[[package]] -name = "rustix" -version = "0.37.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fea8ca367a3a01fe35e6943c400addf443c0f57670e6ec51196f71a4b8762dd2" -dependencies = [ - "bitflags 1.3.2", - "errno", - "io-lifetimes", - "libc", - "linux-raw-sys 0.3.8", - "windows-sys 0.48.0", -] - -[[package]] -name = "rustix" -version = "0.38.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9470c4bf8246c8daf25f9598dca807fb6510347b1e1cfa55749113850c79d88a" -dependencies = [ - "bitflags 2.4.1", - "errno", - "libc", - "linux-raw-sys 0.4.12", - "windows-sys 0.52.0", -] - -[[package]] -name = "ryu" -version = "1.0.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" - -[[package]] -name = "safe_arch" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "794821e4ccb0d9f979512f9c1973480123f9bd62a90d74ab0f9426fcf8f4a529" -dependencies = [ - "bytemuck", -] - -[[package]] -name = "same-file" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" -dependencies = [ - "winapi-util", -] - -[[package]] -name = "scopeguard" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" - -[[package]] -name = "scratch" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1792db035ce95be60c3f8853017b3999209281c24e2ba5bc8e59bf97a0c590c1" - -[[package]] -name = "semver" -version = "1.0.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" -dependencies = [ - "serde", -] - -[[package]] -name = "serde" -version = "1.0.193" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.193" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.39", -] - -[[package]] -name = "serde_json" -version = "1.0.108" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" -dependencies = [ - "itoa", - "ryu", - "serde", -] - -[[package]] -name = "serde_repr" -version = "0.1.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3081f5ffbb02284dda55132aa26daecedd7372a42417bbbab6f14ab7d6bb9145" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.39", -] - -[[package]] -name = "sha1" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" -dependencies = [ - "cfg-if 1.0.0", - "cpufeatures", - "digest", -] - -[[package]] -name = "shell-escape" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45bb67a18fa91266cc7807181f62f9178a6873bfad7dc788c42e6430db40184f" - -[[package]] -name = "signal-hook-registry" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" -dependencies = [ - "libc", -] - -[[package]] -name = "simba" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "061507c94fc6ab4ba1c9a0305018408e312e17c041eb63bef8aa726fa33aceae" -dependencies = [ - "approx", - "num-complex", - "num-traits", - "paste", - "wide", -] - -[[package]] -name = "siphasher" -version = "0.3.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" - -[[package]] -name = "slab" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" -dependencies = [ - "autocfg", -] - -[[package]] -name = "socket2" -version = "0.4.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f7916fc008ca5542385b89a3d3ce689953c143e9304a9bf8beec1de48994c0d" -dependencies = [ - "libc", - "winapi 0.3.9", -] - -[[package]] -name = "socketcan" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3101efc6ef5af6f1c1a488241b469757b7a183baca63af958cd90e4696446c80" -dependencies = [ - "hex 0.2.0", - "itertools", - "libc", - "nix 0.5.1", - "try_from", -] - -[[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" - -[[package]] -name = "stderrlog" -version = "0.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69a26bbf6de627d389164afa9783739b56746c6c72c4ed16539f4ff54170327b" -dependencies = [ - "atty", - "chrono", - "log", - "termcolor", - "thread_local", -] - -[[package]] -name = "strength_reduce" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe895eb47f22e2ddd4dabc02bce419d2e643c8e3b585c78158b349195bc24d82" - -[[package]] -name = "strsim" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" - -[[package]] -name = "strsim" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "syn" -version = "2.0.39" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "systemstat" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a24aec24a9312c83999a28e3ef9db7e2afd5c64bf47725b758cdc1cafd5b0bd2" -dependencies = [ - "bytesize", - "lazy_static", - "libc", - "nom 7.1.3", - "time 0.3.20", - "winapi 0.3.9", -] - -[[package]] -name = "tauri-winrt-notification" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "006851c9ccefa3c38a7646b8cec804bb429def3da10497bfa977179869c3e8e2" -dependencies = [ - "quick-xml", - "windows 0.51.1", -] - -[[package]] -name = "tempfile" -version = "3.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef1adac450ad7f4b3c28589471ade84f25f731a7a0fe30d71dfa9f60fd808e5" -dependencies = [ - "cfg-if 1.0.0", - "fastrand 2.0.1", - "redox_syscall 0.4.1", - "rustix 0.38.26", - "windows-sys 0.48.0", -] - -[[package]] -name = "termcolor" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" -dependencies = [ - "winapi-util", -] - -[[package]] -name = "terminfo" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da31aef70da0f6352dbcb462683eb4dd2bfad01cf3fc96cf204547b9a839a585" -dependencies = [ - "dirs", - "fnv", - "nom 5.1.3", - "phf", - "phf_codegen", -] - -[[package]] -name = "textwrap" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" -dependencies = [ - "unicode-width", -] - -[[package]] -name = "thiserror" -version = "1.0.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.39", -] - -[[package]] -name = "thread_local" -version = "1.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" -dependencies = [ - "cfg-if 1.0.0", - "once_cell", -] - -[[package]] -name = "time" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" -dependencies = [ - "libc", - "wasi 0.10.0+wasi-snapshot-preview1", - "winapi 0.3.9", -] - -[[package]] -name = "time" -version = "0.3.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd0cbfecb4d19b5ea75bb31ad904eb5b9fa13f21079c3b92017ebdf4999a5890" -dependencies = [ - "serde", - "time-core", -] - -[[package]] -name = "time-core" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd" - -[[package]] -name = "toml_datetime" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" - -[[package]] -name = "toml_edit" -version = "0.19.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - -[[package]] -name = "tracing" -version = "0.1.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" -dependencies = [ - "pin-project-lite", - "tracing-attributes", - "tracing-core", -] - -[[package]] -name = "tracing-attributes" -version = "0.1.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.39", -] - -[[package]] -name = "tracing-core" -version = "0.1.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" -dependencies = [ - "once_cell", -] - -[[package]] -name = "transpose" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6522d49d03727ffb138ae4cbc1283d3774f0d10aa7f9bf52e6784c45daf9b23" -dependencies = [ - "num-integer", - "strength_reduce", -] - -[[package]] -name = "try_from" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "923a7ee3e97dbfe8685261beb4511cc9620a1252405d02693d43169729570111" - -[[package]] -name = "typenum" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" - -[[package]] -name = "uds_windows" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce65604324d3cce9b966701489fbd0cf318cb1f7bd9dd07ac9a4ee6fb791930d" -dependencies = [ - "tempfile", - "winapi 0.3.9", -] - -[[package]] -name = "unicode-ident" -version = "1.0.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" - -[[package]] -name = "unicode-width" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" - -[[package]] -name = "vcpkg" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" - -[[package]] -name = "vec_map" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" - -[[package]] -name = "version_check" -version = "0.9.4" +name = "futures-task" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "efd193069b0ddadc69c46389b740bbccdd97203899b48d09c5f7969591d6bae2" [[package]] -name = "waker-fn" -version = "1.1.1" +name = "futures-timer" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3c4517f54858c779bbcbf228f4fca63d121bf85fbecb2dc578cdf4a39395690" +checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" [[package]] -name = "walkdir" -version = "2.4.0" +name = "futures-util" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" +checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104" dependencies = [ - "same-file", - "winapi-util", + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", ] [[package]] -name = "wasi" -version = "0.10.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" - -[[package]] -name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" +name = "hex" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] -name = "wasm-bindgen" -version = "0.2.84" +name = "itertools" +version = "0.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" dependencies = [ - "cfg-if 1.0.0", - "wasm-bindgen-macro", + "either", ] [[package]] -name = "wasm-bindgen-backend" -version = "0.2.84" +name = "libc" +version = "0.2.150" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9" -dependencies = [ - "bumpalo", - "log", - "once_cell", - "proc-macro2", - "quote", - "syn 1.0.109", - "wasm-bindgen-shared", -] +checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" [[package]] -name = "wasm-bindgen-macro" -version = "0.2.84" +name = "log" +version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.84" +name = "matrixmultiply" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" +checksum = "7574c1cf36da4798ab73da5b215bbf444f50718207754cb522201d78d1cd0ff2" dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", - "wasm-bindgen-backend", - "wasm-bindgen-shared", + "autocfg", + "rawpointer", ] [[package]] -name = "wasm-bindgen-shared" -version = "0.2.84" +name = "memchr" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d" +checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" [[package]] -name = "watchexec" -version = "1.17.2" +name = "memoffset" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38928d7ff5274e31594da2d46453a2c741fa340d1bf0ef6f2cb3e43537361265" +checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" dependencies = [ - "clearscreen", - "command-group", - "derive_builder", - "glob", - "globset", - "lazy_static", - "log", - "nix 0.22.3", - "notify", - "walkdir", - "winapi 0.3.9", + "autocfg", ] [[package]] -name = "which" -version = "4.4.2" +name = "nalgebra" +version = "0.32.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" +checksum = "307ed9b18cc2423f29e83f84fd23a8e73628727990181f18641a8b5dc2ab1caa" dependencies = [ - "either", - "home", - "once_cell", - "rustix 0.38.26", + "approx", + "matrixmultiply", + "nalgebra-macros", + "num-complex", + "num-rational", + "num-traits", + "simba", + "typenum", ] [[package]] -name = "wide" -version = "0.7.8" +name = "nalgebra-macros" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b689b6c49d6549434bf944e6b0f39238cf63693cb7a147e9d887507fffa3b223" +checksum = "91761aed67d03ad966ef783ae962ef9bbaca728d2dd7ceb7939ec110fffad998" dependencies = [ - "bytemuck", - "safe_arch", + "proc-macro2", + "quote", + "syn 1.0.109", ] [[package]] -name = "winapi" -version = "0.2.8" +name = "nb" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" +checksum = "8d5439c4ad607c3c23abf66de8c8bf57ba8adcd1f129e699851a6e43935d339d" [[package]] -name = "winapi" -version = "0.3.9" +name = "neli" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +checksum = "1100229e06604150b3becd61a4965d5c70f3be1759544ea7274166f4be41ef43" dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", + "byteorder", + "libc", + "log", + "neli-proc-macros", ] [[package]] -name = "winapi-build" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-util" -version = "0.1.5" +name = "neli-proc-macros" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +checksum = "c168194d373b1e134786274020dae7fc5513d565ea2ebb9bc9ff17ffb69106d4" dependencies = [ - "winapi 0.3.9", + "either", + "proc-macro2", + "quote", + "serde", + "syn 1.0.109", ] [[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "windows" -version = "0.48.0" +name = "nix" +version = "0.26.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" +checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b" dependencies = [ - "windows-targets 0.48.5", + "bitflags", + "cfg-if", + "libc", + "memoffset", + "pin-utils", ] [[package]] -name = "windows" -version = "0.51.1" +name = "num-complex" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca229916c5ee38c2f2bc1e9d8f04df975b4bd93f9955dc69fabb5d91270045c9" +checksum = "1ba157ca0885411de85d6ca030ba7e2a83a28636056c7c699b07c8b6f7383214" dependencies = [ - "windows-core", - "windows-targets 0.48.5", + "num-traits", ] [[package]] -name = "windows-core" -version = "0.51.1" +name = "num-integer" +version = "0.1.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" dependencies = [ - "windows-targets 0.48.5", + "autocfg", + "num-traits", ] [[package]] -name = "windows-sys" -version = "0.48.0" +name = "num-rational" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" dependencies = [ - "windows-targets 0.48.5", + "autocfg", + "num-integer", + "num-traits", ] [[package]] -name = "windows-sys" -version = "0.52.0" +name = "num-traits" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" dependencies = [ - "windows-targets 0.52.0", + "autocfg", ] [[package]] -name = "windows-targets" -version = "0.48.5" +name = "openssl-sys" +version = "0.9.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +checksum = "3812c071ba60da8b5677cc12bcb1d42989a65553772897a7e0355545a819838f" dependencies = [ - "windows_aarch64_gnullvm 0.48.5", - "windows_aarch64_msvc 0.48.5", - "windows_i686_gnu 0.48.5", - "windows_i686_msvc 0.48.5", - "windows_x86_64_gnu 0.48.5", - "windows_x86_64_gnullvm 0.48.5", - "windows_x86_64_msvc 0.48.5", + "cc", + "libc", + "pkg-config", + "vcpkg", ] [[package]] -name = "windows-targets" -version = "0.52.0" +name = "paho-mqtt" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +checksum = "19e405de34b835fb6457d8b0169eda21949f855472b3e346556af9e29fac6eb2" dependencies = [ - "windows_aarch64_gnullvm 0.52.0", - "windows_aarch64_msvc 0.52.0", - "windows_i686_gnu 0.52.0", - "windows_i686_msvc 0.52.0", - "windows_x86_64_gnu 0.52.0", - "windows_x86_64_gnullvm 0.52.0", - "windows_x86_64_msvc 0.52.0", + "async-channel", + "crossbeam-channel", + "futures", + "futures-timer", + "libc", + "log", + "paho-mqtt-sys", + "thiserror", ] [[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.52.0" +name = "paho-mqtt-sys" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" +checksum = "5e482419d847af4ec43c07eed70f5f94f87dc712d267aecc91ab940944ab6bf4" +dependencies = [ + "cmake", + "openssl-sys", +] [[package]] -name = "windows_aarch64_msvc" -version = "0.48.5" +name = "paste" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" +checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" [[package]] -name = "windows_aarch64_msvc" -version = "0.52.0" +name = "pin-project-lite" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" +checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" [[package]] -name = "windows_i686_gnu" -version = "0.48.5" +name = "pin-utils" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] -name = "windows_i686_gnu" -version = "0.52.0" +name = "pkg-config" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" +checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" [[package]] -name = "windows_i686_msvc" -version = "0.48.5" +name = "proc-macro2" +version = "1.0.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" +checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" +dependencies = [ + "unicode-ident", +] [[package]] -name = "windows_i686_msvc" -version = "0.52.0" +name = "quote" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +dependencies = [ + "proc-macro2", +] [[package]] -name = "windows_x86_64_gnu" -version = "0.48.5" +name = "rawpointer" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" +checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" [[package]] -name = "windows_x86_64_gnu" -version = "0.52.0" +name = "safe_arch" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" +checksum = "f398075ce1e6a179b46f51bd88d0598b92b00d3551f1a2d4ac49e771b56ac354" +dependencies = [ + "bytemuck", +] [[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.5" +name = "serde" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" +checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" +dependencies = [ + "serde_derive", +] [[package]] -name = "windows_x86_64_gnullvm" -version = "0.52.0" +name = "serde_derive" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" +checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] [[package]] -name = "windows_x86_64_msvc" -version = "0.48.5" +name = "simba" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" +checksum = "061507c94fc6ab4ba1c9a0305018408e312e17c041eb63bef8aa726fa33aceae" +dependencies = [ + "approx", + "num-complex", + "num-traits", + "paste", + "wide", +] [[package]] -name = "windows_x86_64_msvc" -version = "0.52.0" +name = "slab" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +dependencies = [ + "autocfg", +] [[package]] -name = "winnow" -version = "0.5.19" +name = "socketcan" +version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "829846f3e3db426d4cee4510841b71a8e58aa2a76b1132579487ae430ccd9c7b" +checksum = "175eef9db7dedf6c5d3f5926fed7471633a9b9929a6ee086bdf436ee954532b6" dependencies = [ - "memchr", + "bitflags", + "byte_conv", + "embedded-can", + "hex", + "itertools", + "libc", + "log", + "nb", + "neli", + "nix", + "thiserror", ] [[package]] -name = "ws2_32-sys" -version = "0.2.1" +name = "syn" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ - "winapi 0.2.8", - "winapi-build", + "proc-macro2", + "quote", + "unicode-ident", ] [[package]] -name = "xdg-home" -version = "1.0.0" +name = "syn" +version = "2.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2769203cd13a0c6015d515be729c526d041e9cf2c0cc478d57faee85f40c6dcd" +checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" dependencies = [ - "nix 0.26.4", - "winapi 0.3.9", + "proc-macro2", + "quote", + "unicode-ident", ] [[package]] -name = "zbus" -version = "3.14.1" +name = "thiserror" +version = "1.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31de390a2d872e4cd04edd71b425e29853f786dc99317ed72d73d6fcf5ebb948" +checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2" dependencies = [ - "async-broadcast", - "async-executor", - "async-fs", - "async-io 1.13.0", - "async-lock 2.8.0", - "async-process", - "async-recursion", - "async-task", - "async-trait", - "blocking", - "byteorder", - "derivative", - "enumflags2", - "event-listener 2.5.3", - "futures-core", - "futures-sink", - "futures-util", - "hex 0.4.3", - "nix 0.26.4", - "once_cell", - "ordered-stream", - "rand", - "serde", - "serde_repr", - "sha1", - "static_assertions", - "tracing", - "uds_windows", - "winapi 0.3.9", - "xdg-home", - "zbus_macros", - "zbus_names", - "zvariant", + "thiserror-impl", ] [[package]] -name = "zbus_macros" -version = "3.14.1" +name = "thiserror-impl" +version = "1.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41d1794a946878c0e807f55a397187c11fc7a038ba5d868e7db4f3bd7760bc9d" +checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" dependencies = [ - "proc-macro-crate", "proc-macro2", "quote", - "regex", - "syn 1.0.109", - "zvariant_utils", + "syn 2.0.39", ] [[package]] -name = "zbus_names" -version = "2.6.0" +name = "typenum" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb80bb776dbda6e23d705cf0123c3b95df99c4ebeaec6c2599d4a5419902b4a9" -dependencies = [ - "serde", - "static_assertions", - "zvariant", -] +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] -name = "zvariant" -version = "3.15.0" +name = "unicode-ident" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44b291bee0d960c53170780af148dca5fa260a63cdd24f1962fa82e03e53338c" -dependencies = [ - "byteorder", - "enumflags2", - "libc", - "serde", - "static_assertions", - "zvariant_derive", -] +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] -name = "zvariant_derive" -version = "3.15.0" +name = "vcpkg" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "934d7a7dfc310d6ee06c87ffe88ef4eca7d3e37bb251dece2ef93da8f17d8ecd" -dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "syn 1.0.109", - "zvariant_utils", -] +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" [[package]] -name = "zvariant_utils" -version = "1.0.1" +name = "wide" +version = "0.7.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7234f0d811589db492d16893e3f21e8e2fd282e6d01b0cddee310322062cc200" +checksum = "c68938b57b33da363195412cfc5fc37c9ed49aa9cfe2156fde64b8d2c9498242" dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", + "bytemuck", + "safe_arch", ] diff --git a/Cargo.toml b/Cargo.toml index e758873..9a30096 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,13 +6,6 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] - -rayon = "1.5.1" -chrono = "0.4.19" -systemstat = "0.2.1" -socketcan = "1.7.0" -transpose = "0.2.2" -matrixmultiply = "0.3.3" -nalgebra = "0.32.2" +socketcan = "3.3.0" paho-mqtt = "0.12.3" -cargo-watch = "8.4.1" +nalgebra = "0.32.3" From 0934cd31abd856c204341d2c0d10ec5717fb57b0 Mon Sep 17 00:00:00 2001 From: Peyton-McKee Date: Fri, 1 Dec 2023 00:50:40 -0500 Subject: [PATCH 27/41] #22 Add Chrono Back --- Cargo.lock | 317 +++++++++++++++++++++++++++++++++---------------- Cargo.toml | 3 +- src/message.rs | 2 +- 3 files changed, 215 insertions(+), 107 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6471bd0..2d1a1ea 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,21 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + [[package]] name = "approx" version = "0.5.1" @@ -30,15 +45,15 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "bitflags" -version = "1.3.2" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +checksum = "8dead7461c1127cf637931a1e50934eb6eee8bff2f74433ac7909e9afcee04a3" [[package]] -name = "byte_conv" -version = "0.1.1" +name = "bumpalo" +version = "3.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "649972315d4931137a26fc2bf3ca95ee257ad796a5b57bdeb04205c91a4b5780" +checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" [[package]] name = "bytemuck" @@ -46,16 +61,11 @@ version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6" -[[package]] -name = "byteorder" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" - [[package]] name = "calypso" version = "0.1.0" dependencies = [ + "chrono", "nalgebra", "paho-mqtt", "socketcan", @@ -76,6 +86,20 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "chrono" +version = "0.4.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "js-sys", + "num-traits", + "wasm-bindgen", + "windows-targets", +] + [[package]] name = "cmake" version = "0.1.50" @@ -94,6 +118,12 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "core-foundation-sys" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" + [[package]] name = "crossbeam-channel" version = "0.5.8" @@ -113,21 +143,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "either" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" - -[[package]] -name = "embedded-can" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9d2e857f87ac832df68fa498d18ddc679175cf3d2e4aa893988e5601baf9438" -dependencies = [ - "nb", -] - [[package]] name = "event-listener" version = "2.5.3" @@ -231,17 +246,46 @@ dependencies = [ [[package]] name = "hex" -version = "0.4.3" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6a22814455d41612f41161581c2883c0c6a1c41852729b17d5ed88f01e153aa" + +[[package]] +name = "iana-time-zone" +version = "0.1.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +checksum = "8326b86b6cff230b97d0d312a6c40a60726df3332e721f72a1b035f451663b20" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] [[package]] name = "itertools" -version = "0.10.5" +version = "0.4.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4a9b56eb56058f43dc66e58f40a214b2ccbc9f3df51861b63d51dec7b65bc3f" + +[[package]] +name = "js-sys" +version = "0.3.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +checksum = "cee9c64da59eae3b50095c18d3e74f8b73c0b86d2792824ff01bbce68ba229ca" dependencies = [ - "either", + "wasm-bindgen", ] [[package]] @@ -272,15 +316,6 @@ version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" -[[package]] -name = "memoffset" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" -dependencies = [ - "autocfg", -] - [[package]] name = "nalgebra" version = "0.32.3" @@ -308,48 +343,14 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "nb" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d5439c4ad607c3c23abf66de8c8bf57ba8adcd1f129e699851a6e43935d339d" - -[[package]] -name = "neli" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1100229e06604150b3becd61a4965d5c70f3be1759544ea7274166f4be41ef43" -dependencies = [ - "byteorder", - "libc", - "log", - "neli-proc-macros", -] - -[[package]] -name = "neli-proc-macros" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c168194d373b1e134786274020dae7fc5513d565ea2ebb9bc9ff17ffb69106d4" -dependencies = [ - "either", - "proc-macro2", - "quote", - "serde", - "syn 1.0.109", -] - [[package]] name = "nix" -version = "0.26.4" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b" +checksum = "bfb3ddedaa14746434a02041940495bf11325c22f6d36125d3bdd56090d50a79" dependencies = [ "bitflags", - "cfg-if", "libc", - "memoffset", - "pin-utils", ] [[package]] @@ -391,6 +392,12 @@ dependencies = [ "autocfg", ] +[[package]] +name = "once_cell" +version = "1.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" + [[package]] name = "openssl-sys" version = "0.9.96" @@ -486,26 +493,6 @@ dependencies = [ "bytemuck", ] -[[package]] -name = "serde" -version = "1.0.193" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.193" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.39", -] - [[package]] name = "simba" version = "0.8.1" @@ -530,21 +517,15 @@ dependencies = [ [[package]] name = "socketcan" -version = "3.3.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "175eef9db7dedf6c5d3f5926fed7471633a9b9929a6ee086bdf436ee954532b6" +checksum = "3101efc6ef5af6f1c1a488241b469757b7a183baca63af958cd90e4696446c80" dependencies = [ - "bitflags", - "byte_conv", - "embedded-can", "hex", "itertools", "libc", - "log", - "nb", - "neli", "nix", - "thiserror", + "try_from", ] [[package]] @@ -589,6 +570,12 @@ dependencies = [ "syn 2.0.39", ] +[[package]] +name = "try_from" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "923a7ee3e97dbfe8685261beb4511cc9620a1252405d02693d43169729570111" + [[package]] name = "typenum" version = "1.17.0" @@ -607,6 +594,60 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" +[[package]] +name = "wasm-bindgen" +version = "0.2.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ed0d4f68a3015cc185aff4db9506a015f4b96f95303897bfa23f846db54064e" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b56f625e64f3a1084ded111c4d5f477df9f8c92df113852fa5a374dbda78826" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn 2.0.39", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0162dbf37223cd2afce98f3d0785506dcb8d266223983e4b5b525859e6e182b2" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ab9b36309365056cd639da3134bf87fa8f3d86008abf99e612384a6eecd459f" + [[package]] name = "wide" version = "0.7.13" @@ -616,3 +657,69 @@ dependencies = [ "bytemuck", "safe_arch", ] + +[[package]] +name = "windows-core" +version = "0.51.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" diff --git a/Cargo.toml b/Cargo.toml index 9a30096..15c0807 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,6 +6,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -socketcan = "3.3.0" +chrono = "0.4.31" +socketcan = "1.7.0" paho-mqtt = "0.12.3" nalgebra = "0.32.3" diff --git a/src/message.rs b/src/message.rs index f75cfa9..54fb720 100644 --- a/src/message.rs +++ b/src/message.rs @@ -1,4 +1,4 @@ -use chrono::prelude::*; +use chrono::{DateTime, Utc}; use super::data::Data; use super::master_mapping::get_message_info; From b1e23ce812df955131d712b1bc1a4c801086bd2b Mon Sep 17 00:00:00 2001 From: Peyton-McKee Date: Wed, 10 Jan 2024 09:55:59 -0500 Subject: [PATCH 28/41] #22 Slight Cleanup --- src/data.rs | 2 +- src/message.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/data.rs b/src/data.rs index fbdd4ab..79ffa15 100644 --- a/src/data.rs +++ b/src/data.rs @@ -5,7 +5,7 @@ use std::fmt; * Wrapper Class for Data coming off the car */ pub struct Data { - pub(crate) timestamp: DateTime, + pub timestamp: DateTime, pub id: u8, pub value: f32, } diff --git a/src/message.rs b/src/message.rs index 54fb720..8120866 100644 --- a/src/message.rs +++ b/src/message.rs @@ -31,7 +31,7 @@ impl Message { * Decodes the message and returns a vector of Data objects. */ pub fn decode(&self) -> Vec { - self.decode_message(&self.timestamp, &self.id, &self.data) + self.decode_message(self.timestamp, &self.id, &self.data) } /** @@ -42,12 +42,12 @@ impl Message { * param data: The data of the message. * return: A vector of Data objects. */ - fn decode_message(&self, timestamp: &DateTime, id: &u32, data: &[u8]) -> Vec { + fn decode_message(&self, timestamp: DateTime, id: &u32, data: &[u8]) -> Vec { let decoder = get_message_info(id).decoder; let mut decoded_data: Vec = Vec::new(); let result = decoder(data); for (data_id, value) in result { - decoded_data.push(Data::new(*timestamp, data_id, value)); + decoded_data.push(Data::new(timestamp, data_id, value)); } decoded_data } From 611ca2c41ee8fbf0d11194a49e279d38dafbf3d6 Mon Sep 17 00:00:00 2001 From: Peyton-McKee Date: Thu, 11 Jan 2024 14:07:16 -0500 Subject: [PATCH 29/41] #20 finalize necessary can messages --- oxy/RustSynth.py | 23 ++--- oxy/YAMLParser.py | 8 +- oxy/mapping.yaml | 178 +++++++++++++++++++++++++++++--- oxy/poc_translator.py | 48 --------- oxy/structs/CANField.py | 4 +- oxy/structs/CANmsg.py | 9 +- oxy/structs/CorrectingFactor.py | 9 -- oxy/structs/Decoding.py | 4 + oxy/structs/Format.py | 56 ++++++++++ src/data.rs | 23 ++++- src/decode_data.rs | 4 +- src/master_mapping.rs | 6 +- src/message.rs | 4 +- 13 files changed, 268 insertions(+), 108 deletions(-) delete mode 100644 oxy/poc_translator.py delete mode 100644 oxy/structs/CorrectingFactor.py create mode 100644 oxy/structs/Format.py diff --git a/oxy/RustSynth.py b/oxy/RustSynth.py index c332f4c..0765c65 100644 --- a/oxy/RustSynth.py +++ b/oxy/RustSynth.py @@ -1,30 +1,27 @@ from structs.CANField import CANField from structs.CANMsg import CANMsg -from structs.Decoding import Decoding - -from typing import Optional - class RustSynth: ''' A class to synthesize Rust from a given CANMsg spec. ''' - inst_hashmap: str = " let mut result = HashMap::new();" + return_type: str = "Vec" + inst_hashmap: str = f" let mut result = {return_type}::new();" closing: str = " result\n}" def synthesize(self, msg: CANMsg) -> str: signature: str = self.signature(msg.desc) generated_lines: list[str] = [] for field in msg.fields: - generated_lines.append(self.finalize_line(field.id, f"({self.parse_decoders(field)}){self.correcting_factor(field)}")) + generated_lines.append(self.finalize_line(field.name, field.id, f"({self.format_data(field, self.parse_decoders(field))})")) total_list: list[str] = [signature, self.inst_hashmap] + generated_lines + [self.closing] return "\n".join(total_list) def signature(self, to_decode: str) -> str: - return f"pub fn decode_{to_decode.replace(' ', '_')}(data: &[u8]) -> HashMap {{" + return f"pub fn decode_{to_decode.replace(' ', '_')}(data: &[u8]) -> {self.return_type} {{" - def finalize_line(self, id: int, val: str) -> str: - return f" result.insert({id}, {val});" + def finalize_line(self, topic: str, id: int, val: str) -> str: + return f" result.push(Data::new({id}, {val}, \"{topic}\"));" def parse_decoders(self, field: CANField) -> str: if isinstance(field.decodings, type(None)): @@ -35,8 +32,8 @@ def parse_decoders(self, field: CANField) -> str: base = f"pd::{decoder.repr}({base}, {decoder.bits}) as {decoder.final_type}" return base - def correcting_factor(self, field:CANField) -> str: - cf: str = "" - if field.correcting_factor: - cf = f" {field.correcting_factor.op} {field.correcting_factor.const}" + def format_data(self, field:CANField, decoded_data: str) -> str: + cf = decoded_data + if field.format: + cf = f"fd::{field.format}({decoded_data})" return cf diff --git a/oxy/YAMLParser.py b/oxy/YAMLParser.py index 72a935f..d72eb48 100644 --- a/oxy/YAMLParser.py +++ b/oxy/YAMLParser.py @@ -1,10 +1,9 @@ -from io import TextIOWrapper from ruamel.yaml import YAML, Any from structs.CANMsg import CANMsg from structs.CANField import CANField -from structs.CorrectingFactor import CorrectingFactor -import structs.Decoding +from structs.Format import Format +from structs.Decoding import Decoding class YAMLParser: ''' @@ -16,8 +15,7 @@ def __init__(self): self.yaml = YAML() self.yaml.register_class(CANMsg) self.yaml.register_class(CANField) - self.yaml.register_class(CorrectingFactor) - for decoding in structs.Decoding.Decoding.__subclasses__(): + for decoding in Decoding.__subclasses__(): self.yaml.register_class(decoding) diff --git a/oxy/mapping.yaml b/oxy/mapping.yaml index 7182e03..b1af387 100644 --- a/oxy/mapping.yaml +++ b/oxy/mapping.yaml @@ -1,23 +1,21 @@ +#BMS BROADCAST !CANMsg -id: 1 +id: "0x80" desc: "accumulator status" fields: - !CANField id: 1 - name: Pack Inst Voltage + name: "BMS/Pack/Voltage" units: "V" size: 2 decodings: - !BigEndian bits: 8 final_type: "f32" - correcting_factor: - !CorrectingFactor - const: 10.0 - op: "/" + format: "high_voltage" - !CANField id: 2 - name: "Pack Current" + name: "BMS/Pack/Current" units: "A" size: 2 decodings: @@ -27,13 +25,10 @@ fields: - !TwosComplement bits: 16 final_type: "f32" - correcting_factor: - !CorrectingFactor - const: 10.0 - op: "/" + format: "current" - !CANField id: 3 - name: "Pack Amp-hours" + name: "BMS/Pack/Amp-hours" units: "Ah" size: 2 decodings: @@ -42,13 +37,168 @@ fields: final_type: "f32" - !CANField id: 4 - name: "Pack SOC" + name: "BMS/Pack/SOC" units: "%" size: 1 final_type: "f32" - !CANField id: 5 - name: "Pack Health" + name: "BMS/Pack/Health" units: "%" size: 1 final_type: "f32" + +!CANMsg +id: "0x81" +desc: "BMS Status" +fields: +- !CANField + id: 106 + name: "BMS/State" + units: "" + size: 1 + final_type: "f32" +- !CANField + id: 107 + name: "BMS/Faults" + unit: "" + size: 4 + decodings: + - !LittleEndian + bits: 8 + final_type: "f32" +- !CANField + id: 10 + name: "BMS/Temps/Average" + units: "C" + size: 1 + decodings: + - !TwosComplement + bits: 8 + final_type: "f32" +- !CANField + id: 11 + name: "BMS/Temps/Internal" + size: 1 + decodings: + - !TwosComplement + bits: 8 + final_type: "f32" +- !CANField + id: 143 + name: "BMS/Cells/BurningStatus" + size: 1 + +!CANMsg +id: "0x82" +desc: "Shutdown Control" +fields: +- !CANField + id: 12 + name: "BMS/Shutdown/MPE" + size: 1 + final_type: "f32" + +!CANMsg +id: "0x83" +desc: "Cell Data" +fields: +- !CANField + id: 13 + name: "BMS/Cells/Volts/High/Value" + size: 2 + decodings: + - !LittleEndian + bits: 8 + final_type: "i32" + format: "cell_voltage" +- !CANField + id: 121 + name: "BMS/Cells/Volts/High/Chip" + size: 1 + decodings: + - !Half + bits: 4 + final_type: "f32" +- !CANField + id: 122 + name: "BMS/Cells/Volts/High/Cell" + index: 2 + size: 1 + decodings: + - !Half + bits: 0 + final_type: "f32" +- !CANField + id: 15 + name: "BMS/Cells/Volts/Low/Value" + size: 2 + index: 3 + decodings: + - !LittleEndian + bits: 8 + final_type: i32 + format: "cell_voltage" +- !CANField + id: 123 + name: "BMS/Cells/Volts/Low/Chip" + index: 5 + size: 1 + decodings: + - !Half + bits: 4 + final_type: "f32" +- !CANField + id: 124 + name: "BMS/Cells/Volts/Low/Cell" + index: 5 + size: 1 + - !Half + bits: 0 + final_type: "f32" +- !CANField + id: 17 + name: "BMS/Cells/Volts/Ave/Value" + size: 2 + index: 6 + decodings: + - !LittleEndian + bits: 8 + final_type: i32 + format: "cell_voltage" + +!CANMsg +id: "0x84" +desc: "Cell Temperatures" + +!CANMsg +i: "0x85" +desc: "Segment Temperatures" + + + +# MPU BROADCAST +!CANMsg +id: "0x500" +desc: "NERduino Acceleromter" +fields: +- !CANField + id: 91 + name: "MPU/Accel/X" + size: + +!CANMsg +id: "0x501" +desc: "MPU Status" + + + +#STEERINGWHEEL +!CANMsg +id: "0x680" +desc: "Wheel State" + + + + + diff --git a/oxy/poc_translator.py b/oxy/poc_translator.py deleted file mode 100644 index 51c2db1..0000000 --- a/oxy/poc_translator.py +++ /dev/null @@ -1,48 +0,0 @@ -from ruamel.yaml import YAML, Any -from functools import reduce - - -yaml: YAML = YAML(typ="safe") - -out_string: str = "" -data: dict[str, Any] = yaml.load(open("mapping.yaml")) -print(data) -print(type(data)) - -function_name: str = "decode" + "_" + "_".join(data['string'].split(" ")) -args: str = "(data: &[u8])" -returnVal: str= " -> HashMap" - -signature: str = "pub fn " + function_name + args + returnVal + " {" -instantiate_hash_map: str = " let mut result = HashMap::new();" -conclusion: str = " result\n}" - -decodings: list[str] = [] -accumulated_size: int = 0 -for field in data["fields"]: # result.insert(1, (pd::big_endian(&data[0..2], 8) as f32) / 10.0); - field: dict - decoded: str - id = field["field_id"] - if field["size"] > 1: # we need to do some decoding, then - to_decode: str = f"&data[{accumulated_size}..{accumulated_size+field['size']}]" - _cf: str = field.get("correcting_factor", "") - correcting_factor: str = f"{' ' + ('/' if '/' in _cf else '*') + ' ' if 'correcting_factor' in field.keys() else ''}{_cf.split('/')[-1]}" - for decodingsetup in field["decoding"]: - decodingsetup: dict[str, dict[str, str]] = {k: reduce(lambda x,y: x|y, v, {}) for k,v in decodingsetup.items()} - for decoder, params in decodingsetup.items(): - match decoder: - case "big_endian": - to_decode = f"pd::big_endian({to_decode}, {params['bits']}) as {params['final_type']}" - case "twos_complement": - to_decode = f"pd::twos_comp({to_decode}, {params['bits']}) as {params['final_type']}" - decoded = f"{id}, {to_decode}{correcting_factor}" - else: # no decoding required! - decoded = f"{id}, data[{accumulated_size}] as {field['final_type']}" - - decodings.append(decoded) - accumulated_size += field["size"] - -formatted_decodings = [f" result.insert({i});" for i in decodings] - -finals: list[str] = [signature, instantiate_hash_map] + formatted_decodings + [conclusion] -print("\n".join(finals)) diff --git a/oxy/structs/CANField.py b/oxy/structs/CANField.py index bf32677..952def3 100644 --- a/oxy/structs/CANField.py +++ b/oxy/structs/CANField.py @@ -1,8 +1,8 @@ from __future__ import annotations -from .CorrectingFactor import CorrectingFactor from .Decoding import * from ruamel.yaml import Optional from dataclasses import dataclass +from .Format import Format @dataclass class CANField: @@ -16,5 +16,5 @@ class CANField: units: str size: int index: int = -1 - correcting_factor: Optional[CorrectingFactor] = None decodings: Optional[list[Decoding]] = None + format: Optional[str] = None diff --git a/oxy/structs/CANmsg.py b/oxy/structs/CANmsg.py index d35664e..bdef91e 100644 --- a/oxy/structs/CANmsg.py +++ b/oxy/structs/CANmsg.py @@ -1,6 +1,4 @@ from __future__ import annotations -from ruamel.yaml import Optional, MappingNode -from structs.CorrectingFactor import CorrectingFactor from .CANField import CANField from dataclasses import dataclass @@ -9,15 +7,16 @@ class CANMsg: ''' Represents a CAN message. Has an id, a description, and a number of individual fields. ''' - id: int + id: str desc: str fields: list[CANField] def __post_init__(self) -> None: idx: int = 0 for field in self.fields: - field.index = idx - idx += field.size + if (field.index is not None): + field.index = idx + idx += field.size def __setstate__(self, state): diff --git a/oxy/structs/CorrectingFactor.py b/oxy/structs/CorrectingFactor.py deleted file mode 100644 index 530354c..0000000 --- a/oxy/structs/CorrectingFactor.py +++ /dev/null @@ -1,9 +0,0 @@ -from dataclasses import dataclass - -@dataclass -class CorrectingFactor: - ''' - Represents a correcting factor to be applied to data after decoding. - ''' - const: float - op: str diff --git a/oxy/structs/Decoding.py b/oxy/structs/Decoding.py index e461fbe..e660936 100644 --- a/oxy/structs/Decoding.py +++ b/oxy/structs/Decoding.py @@ -21,3 +21,7 @@ class LittleEndian(Decoding): @dataclass class TwosComplement(Decoding): repr: str = "twos_comp" + +@dataclass +class Half(Decoding): + repor: str = "half" \ No newline at end of file diff --git a/oxy/structs/Format.py b/oxy/structs/Format.py new file mode 100644 index 0000000..ac1ba1c --- /dev/null +++ b/oxy/structs/Format.py @@ -0,0 +1,56 @@ +from dataclasses import dataclass + +@dataclass +class Format: + ''' + Represents a format to be applied to data after decoding. + ''' + repr: str = "*"*42 + +@dataclass +class Temperature(Format): + repr: str = "temperature" + +@dataclass +class LowVoltage(Format): + repr: str = "low_voltage" + +@dataclass +class Torque(Format): + repr: str = "torque" + +@dataclass +class HighVoltage(Format): + repr: str = "high_voltage" + +@dataclass +class Current(Format): + repr: str = "current" + +@dataclass +class Angle(Format): + repr: str = "angle" + +@dataclass +class AngularVelocity(Format): + repr: str = "angular_velocity" + +@dataclass +class Frequency(Format): + repr: str = "frequency" + +@dataclass +class Power(Format): + repr: str = "power" + +@dataclass +class Timer(Format): + repr: str = "timer" + +@dataclass +class Flux(Format): + repr: str = "flux" + +@dataclass +class CellVoltage(Format): + repr: str = "cell_voltage" \ No newline at end of file diff --git a/src/data.rs b/src/data.rs index 79ffa15..e3c4e48 100644 --- a/src/data.rs +++ b/src/data.rs @@ -8,6 +8,7 @@ pub struct Data { pub timestamp: DateTime, pub id: u8, pub value: f32, + pub topic: String, } /** @@ -27,15 +28,16 @@ impl fmt::Display for Data { impl Data { /** * Constructor - * param timestamp: The time the data is collected - * param id: the id of the data - * param value: the value of the data + * @param id: the id of the data + * @param value: the value of the data + * @param topic: the topic of the data */ - pub fn new(timestamp: DateTime, id: u8, value: f32) -> Self { + pub fn new(id: u8, value: f32, topic: String) -> Self { Self { - timestamp, + timestamp: Utc::now(), id, value, + topic, } } } @@ -107,6 +109,13 @@ impl ProcessData { .collect(); decoded_vals } + + /** + * Decodes the given byte by taking the top four bits after shifting it by the given number of bits. + */ + pub fn half(byte: &u8, bits: u8) -> u32 { + (byte >> bits & 15) as u32 + } } /** @@ -158,4 +167,8 @@ impl FormatData { pub fn flux(value: i64) -> f32 { value as f32 / 1000.0 } + + pub fn cell_voltage(value: i32) -> f32 { + value as f32 / 10000.0 + } } diff --git a/src/decode_data.rs b/src/decode_data.rs index c98a3f1..4337b59 100644 --- a/src/decode_data.rs +++ b/src/decode_data.rs @@ -15,10 +15,10 @@ pub fn decode_mock(_data: &[u8]) -> HashMap { pub fn decode_accumulator_status(data: &[u8]) -> HashMap { let mut result = HashMap::new(); - result.insert(1, (pd::big_endian(&data[0..2], 8) as f32) / 10.0); + result.insert(1, fd::temperature(pd::big_endian(&data[0..2], 8).into())); result.insert( 2, - pd::twos_comp(pd::big_endian(&data[2..4], 8), 16) as f32 / 10.0, + fd::temperature(pd::twos_comp(pd::big_endian(&data[2..4], 8), 16)) ); result.insert(3, pd::big_endian(&data[4..6], 8) as f32); result.insert(4, data[6] as f32); diff --git a/src/master_mapping.rs b/src/master_mapping.rs index 5460c66..2f75cdc 100644 --- a/src/master_mapping.rs +++ b/src/master_mapping.rs @@ -1,13 +1,13 @@ use super::decode_data::*; -use std::collections::HashMap; +use super::data::Data; pub struct MessageInfo { pub description: String, - pub decoder: fn(data: &[u8]) -> HashMap, + pub decoder: fn(data: &[u8]) -> Vec, } impl MessageInfo { - pub fn new(description: String, decoder: fn(data: &[u8]) -> HashMap) -> Self { + pub fn new(description: String, decoder: fn(data: &[u8]) -> Vec) -> Self { Self { description, decoder, diff --git a/src/message.rs b/src/message.rs index 8120866..085ef56 100644 --- a/src/message.rs +++ b/src/message.rs @@ -46,8 +46,8 @@ impl Message { let decoder = get_message_info(id).decoder; let mut decoded_data: Vec = Vec::new(); let result = decoder(data); - for (data_id, value) in result { - decoded_data.push(Data::new(timestamp, data_id, value)); + for data in result { + decoded_data.push(data); } decoded_data } From 77da6fe9bc86eb0b1ca806c8d60cd2adafc809eb Mon Sep 17 00:00:00 2001 From: Peyton-McKee Date: Thu, 11 Jan 2024 15:18:42 -0500 Subject: [PATCH 30/41] Filled out Relevant CAN Fields --- oxy/RustSynth.py | 6 +- oxy/mapping.yaml | 196 +++++++++++++++++++++++---- oxy/structs/{CANmsg.py => CANMsg.py} | 0 src/data.rs | 19 ++- src/lib.rs | 1 - src/mqtt.rs | 2 +- src/socket.rs | 69 ---------- 7 files changed, 187 insertions(+), 106 deletions(-) rename oxy/structs/{CANmsg.py => CANMsg.py} (100%) delete mode 100644 src/socket.rs diff --git a/oxy/RustSynth.py b/oxy/RustSynth.py index 0765c65..edf1b39 100644 --- a/oxy/RustSynth.py +++ b/oxy/RustSynth.py @@ -13,15 +13,15 @@ def synthesize(self, msg: CANMsg) -> str: signature: str = self.signature(msg.desc) generated_lines: list[str] = [] for field in msg.fields: - generated_lines.append(self.finalize_line(field.name, field.id, f"({self.format_data(field, self.parse_decoders(field))})")) + generated_lines.append(self.finalize_line(field.name, field.units, f"({self.format_data(field, self.parse_decoders(field))})")) total_list: list[str] = [signature, self.inst_hashmap] + generated_lines + [self.closing] return "\n".join(total_list) def signature(self, to_decode: str) -> str: return f"pub fn decode_{to_decode.replace(' ', '_')}(data: &[u8]) -> {self.return_type} {{" - def finalize_line(self, topic: str, id: int, val: str) -> str: - return f" result.push(Data::new({id}, {val}, \"{topic}\"));" + def finalize_line(self, topic: str, unit: str, val: str) -> str: + return f" result.push(Data::new({val}, \"{topic}\", \"{unit}\"));" def parse_decoders(self, field: CANField) -> str: if isinstance(field.decodings, type(None)): diff --git a/oxy/mapping.yaml b/oxy/mapping.yaml index b1af387..9ebc148 100644 --- a/oxy/mapping.yaml +++ b/oxy/mapping.yaml @@ -4,7 +4,6 @@ id: "0x80" desc: "accumulator status" fields: - !CANField - id: 1 name: "BMS/Pack/Voltage" units: "V" size: 2 @@ -14,7 +13,6 @@ fields: final_type: "f32" format: "high_voltage" - !CANField - id: 2 name: "BMS/Pack/Current" units: "A" size: 2 @@ -27,7 +25,6 @@ fields: final_type: "f32" format: "current" - !CANField - id: 3 name: "BMS/Pack/Amp-hours" units: "Ah" size: 2 @@ -36,13 +33,11 @@ fields: bits: 8 final_type: "f32" - !CANField - id: 4 name: "BMS/Pack/SOC" units: "%" size: 1 final_type: "f32" - !CANField - id: 5 name: "BMS/Pack/Health" units: "%" size: 1 @@ -53,13 +48,11 @@ id: "0x81" desc: "BMS Status" fields: - !CANField - id: 106 name: "BMS/State" units: "" size: 1 final_type: "f32" - !CANField - id: 107 name: "BMS/Faults" unit: "" size: 4 @@ -68,7 +61,6 @@ fields: bits: 8 final_type: "f32" - !CANField - id: 10 name: "BMS/Temps/Average" units: "C" size: 1 @@ -77,26 +69,26 @@ fields: bits: 8 final_type: "f32" - !CANField - id: 11 name: "BMS/Temps/Internal" size: 1 + units: "C" decodings: - !TwosComplement bits: 8 final_type: "f32" - !CANField - id: 143 name: "BMS/Cells/BurningStatus" size: 1 + units: "" !CANMsg id: "0x82" desc: "Shutdown Control" fields: - !CANField - id: 12 name: "BMS/Shutdown/MPE" size: 1 + units: "" final_type: "f32" !CANMsg @@ -104,63 +96,63 @@ id: "0x83" desc: "Cell Data" fields: - !CANField - id: 13 name: "BMS/Cells/Volts/High/Value" size: 2 + units: "V" decodings: - !LittleEndian bits: 8 final_type: "i32" format: "cell_voltage" - !CANField - id: 121 name: "BMS/Cells/Volts/High/Chip" size: 1 + units: "" decodings: - !Half bits: 4 final_type: "f32" - !CANField - id: 122 name: "BMS/Cells/Volts/High/Cell" index: 2 size: 1 + units: "" decodings: - !Half bits: 0 final_type: "f32" - !CANField - id: 15 name: "BMS/Cells/Volts/Low/Value" size: 2 index: 3 + units: "V" decodings: - !LittleEndian bits: 8 final_type: i32 format: "cell_voltage" - !CANField - id: 123 name: "BMS/Cells/Volts/Low/Chip" index: 5 size: 1 + units: "" decodings: - !Half bits: 4 final_type: "f32" - !CANField - id: 124 name: "BMS/Cells/Volts/Low/Cell" index: 5 size: 1 + units: "" - !Half bits: 0 final_type: "f32" - !CANField - id: 17 name: "BMS/Cells/Volts/Ave/Value" size: 2 index: 6 + units: "V" decodings: - !LittleEndian bits: 8 @@ -170,12 +162,114 @@ fields: !CANMsg id: "0x84" desc: "Cell Temperatures" +fields: +- !CANField + name: "BMS/Cells/Temp/High/Value" + units: "C" + size: 2 + decodings: + - !LittleEndian + bits: 8 + final_type: u32 + - !TwosComplement + bits: 16 + final_type: f32 +- !CANField + name: "BMS/Cells/Temp/High/Cell" + units: "" + size: 1 + decodings: + - !Half + bits: 4 + final_type: f32 +- !CANField + name: "BMS/Cells/Temp/High/Chip" + units: "" + size: 1 + index: 2 + decodings: + - !Half + bits: 0 + final_type: f32 +- !CANField + name: "BMS/Cells/Temp/Low/Value" + units: "C" + size: 2 + index: 3 + decodings: + - !LittleEndian + bits: 8 + final_type: u32 + - !TwosComplement + bits: 16 + final_type: f32 +- !CANField + name: "BMS/Cells/Temp/Low/Cell" + units: "" + size: 1 + index: 5 + decodings: + - !Half + bits: 4 + final_type: f32 +- !CANField + name: "BMS/Cells/Temp/Low/Chip" + units: "" + size: 1 + index: 5 + decodings: + - !Half + bits: 0 + final_type: f32 +- !CANField + name: "BMS/Cells/Temp/Ave/Value" + units: "C" + size: 2 + index: 6 + decodings: + - !LittleEndian + bits: 8 + final_type: u32 + - !TwosComplement + bits: 16 + final_type: f32 !CANMsg -i: "0x85" +id: "0x85" desc: "Segment Temperatures" - - +fields: +- !CANField + name: "BMS/Segment/Temp/1" + units: "C" + size: 1 + decodings: + - !TwosComplement + bits: 8 + final_type: f32 +- !CANField + name: "BMS/Segment/Temp/2" + units: "C" + size: 1 + decodings: + - !TwosComplement + bits: 8 + final_type: f32 +- !CANField + name: "BMS/Segment/Temp/3" + units: "C" + size: 1 + decodings: + - !TwosComplement + bits: 8 + final_type: f32 +- !CANField + name: "BMS/Segment/Temp/4" + units: "C" + size: 1 + decodings: + - !TwosComplement + bits: 8 + final_type: f32 # MPU BROADCAST !CANMsg @@ -183,21 +277,73 @@ id: "0x500" desc: "NERduino Acceleromter" fields: - !CANField - id: 91 name: "MPU/Accel/X" - size: + units: "g" + size: 2 + decodings: + - !BigEndian + bits: 8 + final_type: f32 + format: "acceleration" +- !CANField + name: "MPU/Accel/Y" + units: "g" + size: 2 + decodings: + - !BigEndian + bits: 8 + final_type: f32 + format: "acceleration" +- !CANField + name: "MPU/Accel/Z" + units: "g" + size: 2 + decodings: + - !BigEndian + bits: 8 + final_type: f32 + format: "acceleration" !CANMsg id: "0x501" desc: "MPU Status" - +fields: +- !CANField + name: "MPU/State/Mode" + units: "" + size: 1 + final_type: f32 +- !CANField + name: "MPU/State/Torque_Limit_Percentage" + units: "" + size: 1 + final_type: f32 +- !CANField + name: "MPU/State/Regen_Strength" + units: "" + size: 1 + final_type: f32 +- !CANField + name: "MPU/State/Traction_Control" + units: "" + size: 1 + final_type: f32 #STEERINGWHEEL !CANMsg id: "0x680" desc: "Wheel State" - +- !CANField + name: "WHEEL/Buttons/1" + units: "" + size: 1 + final_type: f32 +- !CANField + name: "WHEEL/Buttons/2" + units: "" + size: 1 + final_type: f32 diff --git a/oxy/structs/CANmsg.py b/oxy/structs/CANMsg.py similarity index 100% rename from oxy/structs/CANmsg.py rename to oxy/structs/CANMsg.py diff --git a/src/data.rs b/src/data.rs index e3c4e48..d18048f 100644 --- a/src/data.rs +++ b/src/data.rs @@ -1,14 +1,12 @@ -use chrono::prelude::*; use std::fmt; /** * Wrapper Class for Data coming off the car */ pub struct Data { - pub timestamp: DateTime, - pub id: u8, pub value: f32, pub topic: String, + pub unit: String } /** @@ -18,7 +16,7 @@ impl fmt::Display for Data { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { // Overrides the string representation of the class. - write!(f, "ID {} - {} - {}", self.id, self.timestamp, self.value) + write!(f, "topic: {}, value: {}, unit: {}", self.topic, self.value, self.unit) } } @@ -32,14 +30,17 @@ impl Data { * @param value: the value of the data * @param topic: the topic of the data */ - pub fn new(id: u8, value: f32, topic: String) -> Self { + pub fn new(value: f32, topic: String, unit: String) -> Self { Self { - timestamp: Utc::now(), - id, value, topic, + unit } } + + pub fn to_json(&self) -> String { + format!("{{\"topic\": \"{}\", \"value\": {}, \"unit\": \"{}\"}}", self.topic, self.value, self.unit) + } } /** @@ -171,4 +172,8 @@ impl FormatData { pub fn cell_voltage(value: i32) -> f32 { value as f32 / 10000.0 } + + pub fn acceleration(value: i32) -> f32 { + value as f32 * 0.0029 + } } diff --git a/src/lib.rs b/src/lib.rs index 252a266..792d80a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,4 +4,3 @@ pub mod decode_data; pub mod master_mapping; pub mod message; pub mod mqtt; -pub mod socket; diff --git a/src/mqtt.rs b/src/mqtt.rs index 84f0377..393fe69 100644 --- a/src/mqtt.rs +++ b/src/mqtt.rs @@ -26,7 +26,7 @@ impl Client for MqttClient { */ fn publish(&mut self, data: &Data) { let topic = "/Calypso".to_string(); - let payload = data.value.to_string(); + let payload = data.to_json(); /* If the client is initialized, publish the data. */ if let Some(client) = &self.client { diff --git a/src/socket.rs b/src/socket.rs deleted file mode 100644 index 81090cf..0000000 --- a/src/socket.rs +++ /dev/null @@ -1,69 +0,0 @@ -use std::{io::Write, os::unix::net::UnixStream}; - -use crate::{client::Client, data::Data}; - -/** - * IPCConnection is a wrapper around the IPC server. - */ -pub struct IPCConnection { - stream: Option, -} - -/** - * Implements the Client trait for IPCConnection. - */ -impl Client for IPCConnection { - /** - * Sends the data over the IPC connection. - */ - fn publish(&mut self, data: &Data) { - self.send(data); - } - - /** - * Attempts to connect to the IPC at the given path - * param path: The path to connect to - */ - fn connect(&mut self, path: &str) { - let stream: UnixStream = match UnixStream::connect(path) { - Ok(stream) => stream, - Err(_) => { - println!("Failed to connect to IPC server, is NERO running?"); - return; - } - }; - self.stream = Some(stream); - } -} - -impl Default for IPCConnection { - /** - * Creates a new IPCConnection. - */ - fn default() -> Self { - Self::new() - } -} - -impl IPCConnection { - /** - * Creates a new IPCConnection. - */ - pub fn new() -> IPCConnection { - IPCConnection { stream: None } - } - /** - * Sends the given data to the IPC server. - * param data: The data object to format and send. - */ - fn send(&mut self, data: &Data) { - if let Some(stream) = &mut self.stream { - let message = format!("{{index:{},value:{}}}", data.id, data.value); - stream - .write_all(message.as_bytes()) - .unwrap_or_else(|_| println!("Failed to send message, is NERO running?")); - } else { - println!("Sender not initialized, please connect first"); - } - } -} From 47b832b883de1eb891ea1a554c0930aab0381099 Mon Sep 17 00:00:00 2001 From: Peyton-McKee Date: Thu, 11 Jan 2024 16:12:50 -0500 Subject: [PATCH 31/41] #20 Write Decode Data to File --- oxy/RustSynth.py | 28 +- oxy/YAMLParser.py | 2 + oxy/mapping.yaml | 631 +++++++++++++++++++--------------------- oxy/structs/CANField.py | 5 +- oxy/structs/Decoding.py | 9 +- oxy/structs/Format.py | 2 +- oxy/structs/Messages.py | 9 + oxy/typedpoc.py | 6 +- src/data.rs | 71 ++--- src/decode_data.rs | 520 +++++---------------------------- src/lib.rs | 1 - src/master_mapping.rs | 244 ---------------- src/message.rs | 1 - 13 files changed, 440 insertions(+), 1089 deletions(-) create mode 100644 oxy/structs/Messages.py delete mode 100644 src/master_mapping.rs diff --git a/oxy/RustSynth.py b/oxy/RustSynth.py index edf1b39..8f0c515 100644 --- a/oxy/RustSynth.py +++ b/oxy/RustSynth.py @@ -1,36 +1,50 @@ from structs.CANField import CANField from structs.CANMsg import CANMsg +from structs.Messages import Messages + class RustSynth: ''' A class to synthesize Rust from a given CANMsg spec. ''' - return_type: str = "Vec" + imports: str = "use super::data::{Data,FormatData as fd, ProcessData as pd}; \n" + return_type: str = "Vec::" inst_hashmap: str = f" let mut result = {return_type}::new();" closing: str = " result\n}" + def parse_messages(self, msgs: Messages) -> str: + str = "" + str += self.imports + for msg in msgs.msgs: + str += self.synthesize(msg) + "\n" + return str + def synthesize(self, msg: CANMsg) -> str: signature: str = self.signature(msg.desc) generated_lines: list[str] = [] for field in msg.fields: - generated_lines.append(self.finalize_line(field.name, field.units, f"({self.format_data(field, self.parse_decoders(field))})")) + generated_lines.append(self.finalize_line(field.name, field.unit, f"{self.format_data(field, self.parse_decoders(field))}")) total_list: list[str] = [signature, self.inst_hashmap] + generated_lines + [self.closing] return "\n".join(total_list) def signature(self, to_decode: str) -> str: - return f"pub fn decode_{to_decode.replace(' ', '_')}(data: &[u8]) -> {self.return_type} {{" + return f"pub fn decode_{to_decode.replace(' ', '_').lower()}(data: &[u8]) -> {self.return_type} {{" def finalize_line(self, topic: str, unit: str, val: str) -> str: return f" result.push(Data::new({val}, \"{topic}\", \"{unit}\"));" def parse_decoders(self, field: CANField) -> str: if isinstance(field.decodings, type(None)): - return f"data[{field.index}] as f32" + return f"data[{field.index}] as {field.final_type}" else: - base: str = f"&data[{field.index}..{field.index + field.size}]" + base: str + if field.size == 1: + base = f"data[{field.index}]" + else : + base = f"&data[{field.index}..{field.index + field.size}]" for decoder in field.decodings: - base = f"pd::{decoder.repr}({base}, {decoder.bits}) as {decoder.final_type}" - return base + base = f"pd::{decoder.repr}({base} as {decoder.entry_type}, {decoder.bits})" + return f"{base} as {field.final_type}" def format_data(self, field:CANField, decoded_data: str) -> str: cf = decoded_data diff --git a/oxy/YAMLParser.py b/oxy/YAMLParser.py index d72eb48..af54cf4 100644 --- a/oxy/YAMLParser.py +++ b/oxy/YAMLParser.py @@ -4,6 +4,7 @@ from structs.CANField import CANField from structs.Format import Format from structs.Decoding import Decoding +from structs.Messages import Messages class YAMLParser: ''' @@ -13,6 +14,7 @@ class YAMLParser: def __init__(self): self.yaml = YAML() + self.yaml.register_class(Messages) self.yaml.register_class(CANMsg) self.yaml.register_class(CANField) for decoding in Decoding.__subclasses__(): diff --git a/oxy/mapping.yaml b/oxy/mapping.yaml index 9ebc148..9edb3d6 100644 --- a/oxy/mapping.yaml +++ b/oxy/mapping.yaml @@ -1,349 +1,312 @@ +!Messages +msgs: #BMS BROADCAST -!CANMsg -id: "0x80" -desc: "accumulator status" -fields: -- !CANField - name: "BMS/Pack/Voltage" - units: "V" - size: 2 - decodings: - - !BigEndian - bits: 8 - final_type: "f32" - format: "high_voltage" -- !CANField - name: "BMS/Pack/Current" - units: "A" - size: 2 - decodings: - - !BigEndian - bits: 8 - final_type: "u32" - - !TwosComplement - bits: 16 - final_type: "f32" - format: "current" -- !CANField - name: "BMS/Pack/Amp-hours" - units: "Ah" - size: 2 - decodings: - - !BigEndian - bits: 8 - final_type: "f32" -- !CANField - name: "BMS/Pack/SOC" - units: "%" - size: 1 - final_type: "f32" -- !CANField - name: "BMS/Pack/Health" - units: "%" - size: 1 - final_type: "f32" +- !CANMsg + id: "0x80" + desc: "accumulator status" + fields: + - !CANField + name: "BMS/Pack/Voltage" + unit: "V" + size: 2 + decodings: + - !BigEndian + bits: 8 + format: "high_voltage" + - !CANField + name: "BMS/Pack/Current" + unit: "A" + size: 2 + decodings: + - !BigEndian + bits: 8 + - !TwosComplement + bits: 16 + format: "current" + - !CANField + name: "BMS/Pack/Amp-hours" + unit: "Ah" + size: 2 + decodings: + - !BigEndian + bits: 8 + - !CANField + name: "BMS/Pack/SOC" + unit: "%" + size: 1 + - !CANField + name: "BMS/Pack/Health" + unit: "%" + size: 1 -!CANMsg -id: "0x81" -desc: "BMS Status" -fields: -- !CANField - name: "BMS/State" - units: "" - size: 1 - final_type: "f32" -- !CANField - name: "BMS/Faults" - unit: "" - size: 4 - decodings: - - !LittleEndian - bits: 8 - final_type: "f32" -- !CANField - name: "BMS/Temps/Average" - units: "C" - size: 1 - decodings: - - !TwosComplement - bits: 8 - final_type: "f32" -- !CANField - name: "BMS/Temps/Internal" - size: 1 - units: "C" - decodings: - - !TwosComplement - bits: 8 - final_type: "f32" -- !CANField - name: "BMS/Cells/BurningStatus" - size: 1 - units: "" +- !CANMsg + id: "0x81" + desc: "BMS Status" + fields: + - !CANField + name: "BMS/State" + unit: "" + size: 1 + - !CANField + name: "BMS/Faults" + unit: "" + size: 4 + decodings: + - !LittleEndian + bits: 8 + - !CANField + name: "BMS/Temps/Average" + unit: "C" + size: 1 + decodings: + - !TwosComplement + bits: 8 + - !CANField + name: "BMS/Temps/Internal" + size: 1 + unit: "C" + decodings: + - !TwosComplement + bits: 8 + - !CANField + name: "BMS/Cells/BurningStatus" + size: 1 + unit: "" -!CANMsg -id: "0x82" -desc: "Shutdown Control" -fields: -- !CANField - name: "BMS/Shutdown/MPE" - size: 1 - units: "" - final_type: "f32" +- !CANMsg + id: "0x82" + desc: "Shutdown Control" + fields: + - !CANField + name: "BMS/Shutdown/MPE" + size: 1 + unit: "" -!CANMsg -id: "0x83" -desc: "Cell Data" -fields: -- !CANField - name: "BMS/Cells/Volts/High/Value" - size: 2 - units: "V" - decodings: - - !LittleEndian - bits: 8 - final_type: "i32" - format: "cell_voltage" -- !CANField - name: "BMS/Cells/Volts/High/Chip" - size: 1 - units: "" - decodings: - - !Half - bits: 4 - final_type: "f32" -- !CANField - name: "BMS/Cells/Volts/High/Cell" - index: 2 - size: 1 - units: "" - decodings: - - !Half - bits: 0 - final_type: "f32" -- !CANField - name: "BMS/Cells/Volts/Low/Value" - size: 2 - index: 3 - units: "V" - decodings: - - !LittleEndian - bits: 8 - final_type: i32 - format: "cell_voltage" -- !CANField - name: "BMS/Cells/Volts/Low/Chip" - index: 5 - size: 1 - units: "" - decodings: - - !Half - bits: 4 - final_type: "f32" -- !CANField - name: "BMS/Cells/Volts/Low/Cell" - index: 5 - size: 1 - units: "" - - !Half - bits: 0 - final_type: "f32" -- !CANField - name: "BMS/Cells/Volts/Ave/Value" - size: 2 - index: 6 - units: "V" - decodings: - - !LittleEndian - bits: 8 - final_type: i32 - format: "cell_voltage" +- !CANMsg + id: "0x83" + desc: "Cell Data" + fields: + - !CANField + name: "BMS/Cells/Volts/High/Value" + size: 2 + unit: "V" + decodings: + - !LittleEndian + bits: 8 + format: "cell_voltage" + - !CANField + name: "BMS/Cells/Volts/High/Chip" + size: 1 + unit: "" + decodings: + - !Half + bits: 4 + - !CANField + name: "BMS/Cells/Volts/High/Cell" + index: 2 + size: 1 + unit: "" + decodings: + - !Half + bits: 0 + - !CANField + name: "BMS/Cells/Volts/Low/Value" + size: 2 + index: 3 + unit: "V" + decodings: + - !LittleEndian + bits: 8 + format: "cell_voltage" + - !CANField + name: "BMS/Cells/Volts/Low/Chip" + index: 5 + size: 1 + unit: "" + decodings: + - !Half + bits: 4 + - !CANField + name: "BMS/Cells/Volts/Low/Cell" + index: 5 + size: 1 + unit: "" + decodings: + - !Half + bits: 0 + - !CANField + name: "BMS/Cells/Volts/Ave/Value" + size: 2 + index: 6 + unit: "V" + decodings: + - !LittleEndian + bits: 8 + format: "cell_voltage" -!CANMsg -id: "0x84" -desc: "Cell Temperatures" -fields: -- !CANField - name: "BMS/Cells/Temp/High/Value" - units: "C" - size: 2 - decodings: - - !LittleEndian - bits: 8 - final_type: u32 - - !TwosComplement - bits: 16 - final_type: f32 -- !CANField - name: "BMS/Cells/Temp/High/Cell" - units: "" - size: 1 - decodings: - - !Half - bits: 4 - final_type: f32 -- !CANField - name: "BMS/Cells/Temp/High/Chip" - units: "" - size: 1 - index: 2 - decodings: - - !Half - bits: 0 - final_type: f32 -- !CANField - name: "BMS/Cells/Temp/Low/Value" - units: "C" - size: 2 - index: 3 - decodings: - - !LittleEndian - bits: 8 - final_type: u32 - - !TwosComplement - bits: 16 - final_type: f32 -- !CANField - name: "BMS/Cells/Temp/Low/Cell" - units: "" - size: 1 - index: 5 - decodings: - - !Half - bits: 4 - final_type: f32 -- !CANField - name: "BMS/Cells/Temp/Low/Chip" - units: "" - size: 1 - index: 5 - decodings: - - !Half - bits: 0 - final_type: f32 -- !CANField - name: "BMS/Cells/Temp/Ave/Value" - units: "C" - size: 2 - index: 6 - decodings: - - !LittleEndian - bits: 8 - final_type: u32 - - !TwosComplement - bits: 16 - final_type: f32 +- !CANMsg + id: "0x84" + desc: "Cell Temperatures" + fields: + - !CANField + name: "BMS/Cells/Temp/High/Value" + unit: "C" + size: 2 + decodings: + - !LittleEndian + bits: 8 + - !TwosComplement + bits: 16 + - !CANField + name: "BMS/Cells/Temp/High/Cell" + unit: "" + size: 1 + decodings: + - !Half + bits: 4 + - !CANField + name: "BMS/Cells/Temp/High/Chip" + unit: "" + size: 1 + index: 2 + decodings: + - !Half + bits: 0 + - !CANField + name: "BMS/Cells/Temp/Low/Value" + unit: "C" + size: 2 + index: 3 + decodings: + - !LittleEndian + bits: 8 + - !TwosComplement + bits: 16 + - !CANField + name: "BMS/Cells/Temp/Low/Cell" + unit: "" + size: 1 + index: 5 + decodings: + - !Half + bits: 4 + - !CANField + name: "BMS/Cells/Temp/Low/Chip" + unit: "" + size: 1 + index: 5 + decodings: + - !Half + bits: 0 + - !CANField + name: "BMS/Cells/Temp/Ave/Value" + unit: "C" + size: 2 + index: 6 + decodings: + - !LittleEndian + bits: 8 + - !TwosComplement + bits: 16 -!CANMsg -id: "0x85" -desc: "Segment Temperatures" -fields: -- !CANField - name: "BMS/Segment/Temp/1" - units: "C" - size: 1 - decodings: - - !TwosComplement - bits: 8 - final_type: f32 -- !CANField - name: "BMS/Segment/Temp/2" - units: "C" - size: 1 - decodings: - - !TwosComplement - bits: 8 - final_type: f32 -- !CANField - name: "BMS/Segment/Temp/3" - units: "C" - size: 1 - decodings: - - !TwosComplement - bits: 8 - final_type: f32 -- !CANField - name: "BMS/Segment/Temp/4" - units: "C" - size: 1 - decodings: - - !TwosComplement - bits: 8 - final_type: f32 +- !CANMsg + id: "0x85" + desc: "Segment Temperatures" + fields: + - !CANField + name: "BMS/Segment/Temp/1" + unit: "C" + size: 1 + decodings: + - !TwosComplement + bits: 8 + - !CANField + name: "BMS/Segment/Temp/2" + unit: "C" + size: 1 + decodings: + - !TwosComplement + bits: 8 + - !CANField + name: "BMS/Segment/Temp/3" + unit: "C" + size: 1 + decodings: + - !TwosComplement + bits: 8 + - !CANField + name: "BMS/Segment/Temp/4" + unit: "C" + size: 1 + decodings: + - !TwosComplement + bits: 8 # MPU BROADCAST -!CANMsg -id: "0x500" -desc: "NERduino Acceleromter" -fields: -- !CANField - name: "MPU/Accel/X" - units: "g" - size: 2 - decodings: - - !BigEndian - bits: 8 - final_type: f32 - format: "acceleration" -- !CANField - name: "MPU/Accel/Y" - units: "g" - size: 2 - decodings: - - !BigEndian - bits: 8 - final_type: f32 - format: "acceleration" -- !CANField - name: "MPU/Accel/Z" - units: "g" - size: 2 - decodings: - - !BigEndian - bits: 8 - final_type: f32 - format: "acceleration" +- !CANMsg + id: "0x500" + desc: "NERduino Acceleromter" + fields: + - !CANField + name: "MPU/Accel/X" + unit: "g" + size: 2 + decodings: + - !BigEndian + bits: 8 + format: "acceleration" + - !CANField + name: "MPU/Accel/Y" + unit: "g" + size: 2 + decodings: + - !BigEndian + bits: 8 + format: "acceleration" + - !CANField + name: "MPU/Accel/Z" + unit: "g" + size: 2 + decodings: + - !BigEndian + bits: 8 + format: "acceleration" -!CANMsg -id: "0x501" -desc: "MPU Status" -fields: -- !CANField - name: "MPU/State/Mode" - units: "" - size: 1 - final_type: f32 -- !CANField - name: "MPU/State/Torque_Limit_Percentage" - units: "" - size: 1 - final_type: f32 -- !CANField - name: "MPU/State/Regen_Strength" - units: "" - size: 1 - final_type: f32 -- !CANField - name: "MPU/State/Traction_Control" - units: "" - size: 1 - final_type: f32 +- !CANMsg + id: "0x501" + desc: "MPU Status" + fields: + - !CANField + name: "MPU/State/Mode" + unit: "" + size: 1 + - !CANField + name: "MPU/State/Torque_Limit_Percentage" + unit: "" + size: 1 + - !CANField + name: "MPU/State/Regen_Strength" + unit: "" + size: 1 + - !CANField + name: "MPU/State/Traction_Control" + unit: "" + size: 1 #STEERINGWHEEL -!CANMsg -id: "0x680" -desc: "Wheel State" -- !CANField - name: "WHEEL/Buttons/1" - units: "" - size: 1 - final_type: f32 -- !CANField - name: "WHEEL/Buttons/2" - units: "" - size: 1 - final_type: f32 +- !CANMsg + id: "0x680" + desc: "Wheel State" + fields: + - !CANField + name: "WHEEL/Buttons/1" + unit: "" + size: 1 + - !CANField + name: "WHEEL/Buttons/2" + unit: "" + size: 1 diff --git a/oxy/structs/CANField.py b/oxy/structs/CANField.py index 952def3..6ca53d1 100644 --- a/oxy/structs/CANField.py +++ b/oxy/structs/CANField.py @@ -7,14 +7,15 @@ @dataclass class CANField: ''' - Represents a field in a CAN message. Has an id, a name, units, a size, + Represents a field in a CAN message. Has an id, a name, a unit, a size, and an optional CorrectingFactor and Decodings. Also knows its own index within its parent CANMsg, which is assigned at load from YAML. ''' id: int name: str - units: str + unit: str size: int index: int = -1 + final_type: str = "f32" decodings: Optional[list[Decoding]] = None format: Optional[str] = None diff --git a/oxy/structs/Decoding.py b/oxy/structs/Decoding.py index e660936..bf05872 100644 --- a/oxy/structs/Decoding.py +++ b/oxy/structs/Decoding.py @@ -7,21 +7,26 @@ class Decoding: that represents a decoding to be applied to a slice of data. ''' bits: int - final_type: str + entry_type: str repr: str = "*"*42 @dataclass class BigEndian(Decoding): repr: str = "big_endian" + entry_type = "&[u8]" @dataclass class LittleEndian(Decoding): repr: str = "little_endian" + entry_type = "&[u8]" @dataclass class TwosComplement(Decoding): repr: str = "twos_comp" + entry_type = "u32" + @dataclass class Half(Decoding): - repor: str = "half" \ No newline at end of file + repr: str = "half" + entry_type = "u8" diff --git a/oxy/structs/Format.py b/oxy/structs/Format.py index ac1ba1c..6e3bdcf 100644 --- a/oxy/structs/Format.py +++ b/oxy/structs/Format.py @@ -5,7 +5,7 @@ class Format: ''' Represents a format to be applied to data after decoding. ''' - repr: str = "*"*42 + repr: str = "" @dataclass class Temperature(Format): diff --git a/oxy/structs/Messages.py b/oxy/structs/Messages.py new file mode 100644 index 0000000..a9cb99f --- /dev/null +++ b/oxy/structs/Messages.py @@ -0,0 +1,9 @@ +from dataclasses import dataclass +from .CANMsg import CANMsg + +@dataclass +class Messages: + ''' + Represents a list of CAN messages. Has a list of CANMsgs. + ''' + msgs: list[CANMsg] \ No newline at end of file diff --git a/oxy/typedpoc.py b/oxy/typedpoc.py index 89abd50..2012540 100644 --- a/oxy/typedpoc.py +++ b/oxy/typedpoc.py @@ -1,4 +1,8 @@ from YAMLParser import YAMLParser from RustSynth import RustSynth -print(RustSynth().synthesize(YAMLParser().parse(open("mapping.yaml", "r")))) +f = open("../src/decode_data.rs", "w") + +f.write(RustSynth().parse_messages(YAMLParser().parse(open("mapping.yaml", "r")))) + +f.close() diff --git a/src/data.rs b/src/data.rs index d18048f..eadab45 100644 --- a/src/data.rs +++ b/src/data.rs @@ -30,11 +30,11 @@ impl Data { * @param value: the value of the data * @param topic: the topic of the data */ - pub fn new(value: f32, topic: String, unit: String) -> Self { + pub fn new(value: f32, topic: &str, unit: &str) -> Self { Self { value, - topic, - unit + topic: topic.to_string(), + unit: unit.to_string() } } @@ -49,24 +49,14 @@ impl Data { pub struct ProcessData {} impl ProcessData { - /** - * Groups the given data bytes into lists of specified length. - */ - pub fn group_bytes(data_bytes: &[u8], group_length: usize) -> Vec> { - data_bytes - .chunks(group_length) - .map(|chunk| chunk.to_vec()) - .collect() - } - /** * Computes the twos complement of the given value. */ - pub fn twos_comp(val: u32, bits: usize) -> i64 { + pub fn twos_comp(val: u32, bits: usize) -> f32 { if (val & (1 << (bits - 1))) != 0 { - (val as i64) - (1 << bits) + (val as f32) - ((1 << bits) as f32) } else { - val as i64 + val as f32 } } @@ -94,27 +84,10 @@ impl ProcessData { result } - /** - * Decodes the given data bytes by grouping them into 2 byte chunks, - * transforming them into little endian, and then computing the twos complement. - */ - pub fn default_decode(byte_vals: &[u8]) -> Vec { - let grouped_vals = ProcessData::group_bytes(byte_vals, 2); - let parsed_vals: Vec = grouped_vals - .iter() - .map(|val| ProcessData::little_endian(val, 8)) - .collect(); - let decoded_vals: Vec = parsed_vals - .iter() - .map(|val| ProcessData::twos_comp(*val, 16)) - .collect(); - decoded_vals - } - /** * Decodes the given byte by taking the top four bits after shifting it by the given number of bits. */ - pub fn half(byte: &u8, bits: u8) -> u32 { + pub fn half(byte: u8, bits: u8) -> u32 { (byte >> bits & 15) as u32 } } @@ -125,31 +98,31 @@ impl ProcessData { pub struct FormatData {} impl FormatData { - pub fn temperature(value: i64) -> f32 { - value as f32 / 10.0 + pub fn temperature(value: f32) -> f32 { + value / 10.0 } - pub fn low_voltage(value: i64) -> f32 { - value as f32 / 100.0 + pub fn low_voltage(value: f32) -> f32 { + value / 100.0 } - pub fn torque(value: i64) -> f32 { - value as f32 / 10.0 + pub fn torque(value: f32) -> f32 { + value / 10.0 } - pub fn high_voltage(value: i64) -> f32 { - value as f32 / 10.0 + pub fn high_voltage(value: f32) -> f32 { + value / 10.0 } - pub fn current(value: i64) -> f32 { - value as f32 / 10.0 + pub fn current(value: f32) -> f32 { + value / 10.0 } - pub fn angle(value: i64) -> f32 { - value as f32 / 10.0 + pub fn angle(value: f32) -> f32 { + value / 10.0 } - pub fn angular_velocity(value: i64) -> i64 { + pub fn angular_velocity(value: f32) -> f32 { -value } @@ -169,11 +142,11 @@ impl FormatData { value as f32 / 1000.0 } - pub fn cell_voltage(value: i32) -> f32 { + pub fn cell_voltage(value: f32) -> f32 { value as f32 / 10000.0 } - pub fn acceleration(value: i32) -> f32 { + pub fn acceleration(value: f32) -> f32 { value as f32 * 0.0029 } } diff --git a/src/decode_data.rs b/src/decode_data.rs index 4337b59..a300f53 100644 --- a/src/decode_data.rs +++ b/src/decode_data.rs @@ -1,449 +1,75 @@ -// This file specifies methods to decode messages into the many pieces of data they contain. - -// use nalgebra::convert; -use nalgebra::{Matrix3, Vector3}; -use std::collections::HashMap; - -use super::data::FormatData as fd; -use super::data::ProcessData as pd; - -pub fn decode_mock(_data: &[u8]) -> HashMap { - let mut result = HashMap::new(); - result.insert(0, 0.0); - result -} - -pub fn decode_accumulator_status(data: &[u8]) -> HashMap { - let mut result = HashMap::new(); - result.insert(1, fd::temperature(pd::big_endian(&data[0..2], 8).into())); - result.insert( - 2, - fd::temperature(pd::twos_comp(pd::big_endian(&data[2..4], 8), 16)) - ); - result.insert(3, pd::big_endian(&data[4..6], 8) as f32); - result.insert(4, data[6] as f32); - result.insert(5, data[7] as f32); - result -} - -pub fn decode_bms_status(data: &[u8]) -> HashMap { - let mut result = HashMap::new(); - result.insert(106, data[0] as f32); - result.insert(107, pd::little_endian(&data[1..5], 8) as f32); - result.insert(10, pd::twos_comp(data[5] as u32, 8) as f32); - result.insert(11, pd::twos_comp(data[6] as u32, 8) as f32); - result.insert(143, data[7] as f32); - result -} - -pub fn decode3(data: &[u8]) -> HashMap { - let mut result = HashMap::new(); - result.insert(12, data[0] as f32); - result -} - -pub fn decode_cell_voltages(data: &[u8]) -> HashMap { - let high_cell_volt_chip_number = (data[2] >> 4) & 15; - let high_cell_volt_cell_number = data[2] & 15; - let low_cell_volt_chip_number = (data[5] >> 4) & 15; - let low_cell_volt_cell_number = data[5] & 15; - let mut result = HashMap::new(); - result.insert(13, (pd::little_endian(&data[0..2], 8) as f32) / 10000.0); - result.insert(121, high_cell_volt_chip_number as f32); - result.insert(122, high_cell_volt_cell_number as f32); - result.insert(15, (pd::little_endian(&data[3..5], 8) as f32) / 10000.0); - result.insert(123, low_cell_volt_chip_number as f32); - result.insert(124, low_cell_volt_cell_number as f32); - result.insert(17, (pd::little_endian(&data[6..8], 8) as f32) / 10000.0); - result -} - -pub fn decode5(data: &[u8]) -> HashMap { - let decoded_data = pd::default_decode(data); - let final_data = decoded_data - .iter() - .map(|d| fd::temperature(*d)) - .collect::>(); - let mut result = HashMap::new(); - result.insert(18, final_data[0]); - result.insert(19, final_data[1]); - result.insert(20, final_data[2]); - result.insert(21, final_data[3]); - result -} - -pub fn decode6(data: &[u8]) -> HashMap { - let decoded_data = pd::default_decode(data); - let final_data = decoded_data - .iter() - .map(|d| fd::temperature(*d)) - .collect::>(); - let mut result = HashMap::new(); - result.insert(22, final_data[0]); - result.insert(23, final_data[1]); - result.insert(24, final_data[2]); - result.insert(25, final_data[3]); - result -} - -pub fn decode7(data: &[u8]) -> HashMap { - let decoded_data = pd::default_decode(data); - let final_data = decoded_data[..3] - .iter() - .map(|d| fd::temperature(*d)) - .collect::>(); - let mut result = HashMap::new(); - result.insert(26, final_data[0]); - result.insert(27, final_data[1]); - result.insert(28, final_data[2]); - result.insert(29, fd::torque(decoded_data[3])); - result -} - -// TODO: Fill this method out (complicated with bit shifts) -pub fn decode8(_data: &[u8]) -> HashMap { - let mut result = HashMap::new(); - result.insert(30, 0.0); - result.insert(31, 0.0); - result.insert(32, 0.0); - result.insert(33, 0.0); - result.insert(34, 0.0); - result.insert(35, 0.0); - result -} - -pub fn decode9(data: &[u8]) -> HashMap { - let mut result = HashMap::new(); - result.insert(36, data[0] as f32); - result.insert(37, data[1] as f32); - result.insert(38, data[2] as f32); - result.insert(39, data[3] as f32); - result.insert(40, data[4] as f32); - result.insert(41, data[5] as f32); - result.insert(42, data[6] as f32); - result.insert(43, data[7] as f32); - result -} - -pub fn decode10(data: &[u8]) -> HashMap { - let decoded_data = pd::default_decode(data); - let motor_speed: f32 = fd::angular_velocity(decoded_data[1]) as f32; - let vehicle_speed = motor_speed * 0.013048225; - let mut result = HashMap::new(); - result.insert(44, fd::angle(decoded_data[0])); - result.insert(45, motor_speed); - result.insert(46, fd::frequency(decoded_data[2])); - result.insert(47, fd::angle(decoded_data[3])); - result.insert(101, vehicle_speed); - result -} - -pub fn decode11(data: &[u8]) -> HashMap { - let decoded_data = pd::default_decode(data); - let final_data = decoded_data - .iter() - .map(|d| fd::current(*d)) - .collect::>(); - let mut result = HashMap::new(); - result.insert(48, final_data[0]); - result.insert(49, final_data[1]); - result.insert(50, final_data[2]); - result.insert(51, final_data[3]); - result -} - -pub fn decode12(data: &[u8]) -> HashMap { - let decoded_data = pd::default_decode(data); - let final_data: Vec = decoded_data.iter().map(|d| fd::high_voltage(*d)).collect(); - let mut result = HashMap::new(); - result.insert(52, final_data[0]); - result.insert(53, final_data[1]); - result.insert(54, final_data[2]); - result.insert(55, final_data[3]); - result -} - -pub fn decode13(data: &[u8]) -> HashMap { - let decoded_data = pd::default_decode(data); - let mut result = HashMap::new(); - result.insert(56, fd::flux(decoded_data[0])); - result.insert(57, fd::flux(decoded_data[1])); - result.insert(58, fd::current(decoded_data[2])); - result.insert(59, fd::current(decoded_data[3])); - result -} - -pub fn decode14(data: &[u8]) -> HashMap { - let decoded_data = pd::default_decode(data); - let final_data: Vec = decoded_data.iter().map(|d| fd::low_voltage(*d)).collect(); - let mut result = HashMap::new(); - result.insert(60, final_data[0]); - result.insert(61, final_data[1]); - result.insert(62, final_data[2]); - result.insert(63, final_data[3]); - result -} - -pub fn decode15(data: &[u8]) -> HashMap { - let mut result = HashMap::new(); - result.insert(64, pd::little_endian(&data[0..2], 8) as f32); - result.insert(65, data[2] as f32); - result.insert(66, data[3] as f32); - result.insert(67, (data[4] & 1) as f32); - result.insert(68, ((data[4] >> 5) & 7) as f32); - result.insert(69, (data[5] & 1) as f32); - result.insert(70, (data[6] & 1) as f32); - result.insert(71, ((data[6] >> 7) & 1) as f32); - result.insert(72, (data[7] & 1) as f32); - result.insert(73, ((data[7] >> 1) & 1) as f32); - result.insert(74, ((data[7] >> 2) & 1) as f32); - result -} - -pub fn decode16(data: &[u8]) -> HashMap { - let binding = pd::group_bytes(data, 2); - let data = binding.iter().map(|d| pd::little_endian(d, 8) as f32); - let grouped_data = data.collect::>(); - let mut result = HashMap::new(); - result.insert(75, grouped_data[0]); - result.insert(76, grouped_data[1]); - result.insert(77, grouped_data[2]); - result.insert(78, grouped_data[3]); - result -} - -pub fn decode17(data: &[u8]) -> HashMap { - let decoded_data = pd::default_decode(&data[0..4]); - let timer_data = pd::little_endian(&data[4..], 8) as i32; - let mut result = HashMap::new(); - result.insert(79, fd::torque(decoded_data[0])); - result.insert(80, fd::torque(decoded_data[1])); - result.insert(81, fd::timer(timer_data)); - result -} - -pub fn decode18(data: &[u8]) -> HashMap { - let decoded_data = pd::default_decode(data); - let mut result = HashMap::new(); - result.insert(82, fd::torque(decoded_data[0])); - result.insert(83, fd::angular_velocity(decoded_data[1]) as f32); - result.insert(84, data[4] as f32); - result.insert(85, (data[5] & 1) as f32); - result.insert(86, ((data[5] >> 1) & 1) as f32); - result.insert(87, ((data[5] >> 2) & 1) as f32); - result.insert(88, fd::torque(decoded_data[3])); - result -} - -pub fn decode19(data: &[u8]) -> HashMap { - let mut result = HashMap::new(); - result.insert(89, pd::little_endian(&data[0..2], 8) as f32); - result.insert(90, pd::little_endian(&data[2..4], 8) as f32); - result -} - -pub fn decode_accelerometer_data(data: &[u8]) -> HashMap { - let decoded_data = pd::default_decode(data); - let converted_data = decoded_data - .iter() - .map(|val| *val as f32 * 0.0029) - .collect::>(); - let matrix_data: Vector3 = - Vector3::new(converted_data[0], converted_data[1], converted_data[2]); - let transform_matrix = Matrix3::new( - 1.0, - 0.0, - 0.0, - 0.0, - f32::cos(f32::to_radians(70.0)), - f32::sin(f32::to_radians(70.0)), - 0.0, - -f32::sin(f32::to_radians(70.0)), - f32::cos(f32::to_radians(70.0)), - ); - let transformed_data = transform_matrix * matrix_data; - let mut result = HashMap::new(); - result.insert(91, transformed_data[0]); - result.insert(92, transformed_data[1]); - result.insert(93, transformed_data[2]); - result -} - -pub fn decode21(data: &[u8]) -> HashMap { - let temp = pd::little_endian(&data[0..2], 8) as f32; - let humid = pd::little_endian(&data[2..4], 8) as f32; - let temp_f = -49.0 + (315.0 * temp / 65535.0); - let temp_c = -45.0 + (175.0 * temp / 65535.0); - let rel_humid = 100.0 * humid / 65535.0; - let mut result = HashMap::new(); - result.insert(94, temp_c); - result.insert(95, temp_f); - result.insert(96, rel_humid); - result -} - -// fn decode22(data: &[u8]) -> HashMap { -// let cell_id = data[0] as u32; -// let instant_voltage = pd::big_endian(&data[1..3], 8); -// let internal_resistance = (pd::big_endian(&data[3..5], 8) & 32767) as u32; -// let shunted = ((data[3] >> 7) & 1) as u32; -// let open_voltage = pd::big_endian(&data[5..7], 8); -// let mut result = HashMap::new(); -// result.insert( -// 97, -// "Cell ID: ".to_string() -// + &cell_id.to_string() -// + ", Instant Voltage: " -// + &instant_voltage.to_string() -// + ", Internal Resistance: " -// + &internal_resistance.to_string() -// + ", Shunted: " -// + &shunted.to_string() -// + ", Open Voltage: " -// + &open_voltage.to_string(), -// ); - -// result -// } - -pub fn decode29(data: &[u8]) -> HashMap { - let glv_current = pd::twos_comp(pd::little_endian(data, 8), 32) as f32; - let mut result = HashMap::new(); - result.insert(98, glv_current / 1000000.0); - result -} - -pub fn decode34(data: &[u8]) -> HashMap { - let voltage1 = pd::twos_comp(pd::little_endian(&data[0..4], 8), 32) as f32; - let voltage2 = pd::twos_comp(pd::little_endian(&data[4..], 8), 32) as f32; - let mut result = HashMap::new(); - result.insert(99, voltage1 / 1000000.0); - result.insert(100, voltage2 / 1000000.0); - result -} - -pub fn decode35(data: &[u8]) -> HashMap { - let mut result: HashMap = HashMap::new(); - result.insert(102, pd::big_endian(&data[0..2], 8) as f32); - result.insert(103, pd::big_endian(&data[2..4], 8) as f32); - result.insert(104, data[4] as f32); - result -} - -pub fn decode_mpu_dashboard_info(data: &[u8]) -> HashMap { - let mut result = HashMap::new(); - result.insert(105, data[0] as f32); - result.insert(130, data[1] as f32); - result.insert(131, data[2] as f32); - result.insert(132, data[3] as f32); - result.insert(133, data[4] as f32); - result.insert(144, data[5] as f32); - result.insert(145, data[6] as f32); - result.insert(146, data[7] as f32); - result -} - -pub fn decode_gps_1(data: &[u8]) -> HashMap { - let longitude = pd::twos_comp(pd::little_endian(&data[0..4], 8), 32) as f32 / 10000000.0; - let latitude = pd::twos_comp(pd::little_endian(&data[4..8], 8), 32) as f32 / 10000000.0; - let mut result = HashMap::new(); - result.insert(108, longitude); - result.insert(109, latitude); - result -} - -pub fn decode_gps_2(data: &[u8]) -> HashMap { - let altitude = pd::twos_comp(pd::little_endian(&data[4..8], 8), 32) as f32 / 1000.0; - let mut result: HashMap = HashMap::new(); - result.insert( - 110, - pd::twos_comp(pd::little_endian(&data[0..4], 8), 32) as f32, - ); - result.insert(111, altitude); - result -} - -pub fn decode_gps_3(data: &[u8]) -> HashMap { - let ground_speed = pd::twos_comp(pd::little_endian(&data[0..4], 8), 32) as f32 / 1000.0; - let heading = pd::twos_comp(pd::little_endian(&data[4..8], 8), 32) as f32 / 100000.0; - let mut result = HashMap::new(); - result.insert(112, ground_speed); - result.insert(113, heading); - result -} - -pub fn decode_cell_temps(data: &[u8]) -> HashMap { - let high_cell_temp_chip_number = (data[2] >> 4) & 15; - let high_cell_temp_cell_number = data[2] & 15; - let low_cell_temp_chip_number = (data[5] >> 4) & 15; - let low_cell_temp_cell_number = data[5] & 15; - - let mut result = HashMap::new(); - result.insert( - 114, - pd::twos_comp(pd::little_endian(&data[0..2], 8), 16) as f32, - ); - result.insert(115, high_cell_temp_chip_number as f32); - result.insert(116, high_cell_temp_cell_number as f32); - result.insert( - 117, - pd::twos_comp(pd::little_endian(&data[3..5], 8), 16) as f32, - ); - result.insert(118, low_cell_temp_chip_number as f32); - result.insert(119, low_cell_temp_cell_number as f32); - result.insert( - 120, - pd::twos_comp(pd::little_endian(&data[6..8], 8), 16) as f32, - ); - - result -} - -pub fn decode_segment_temps(data: &[u8]) -> HashMap { - let mut result = HashMap::new(); - result.insert(125, pd::twos_comp(data[0] as u32, 8) as f32); - result.insert(126, pd::twos_comp(data[1] as u32, 8) as f32); - result.insert(127, pd::twos_comp(data[2] as u32, 8) as f32); - result.insert(128, pd::twos_comp(data[3] as u32, 8) as f32); - - result -} - -pub fn decode_logging_status(data: &[u8]) -> HashMap { - let mut result = HashMap::new(); - result.insert(129, data[0] as f32); - - result -} - -pub fn decode_lv_battery_1(data: &[u8]) -> HashMap { - let mut result = HashMap::new(); - result.insert(134, (pd::little_endian(&data[0..2], 8)) as f32); - result.insert(135, data[2] as f32); - result.insert(136, (pd::little_endian(&data[3..5], 8)) as f32); - result.insert(137, data[5] as f32); - result.insert(138, (pd::little_endian(&data[6..8], 8)) as f32); - result -} - -pub fn decode_lv_battery_2(data: &[u8]) -> HashMap { - let mut result = HashMap::new(); - result.insert( - 139, - (pd::twos_comp(pd::little_endian(&data[0..2], 8), 16) as f32) * (192.264 / 1000000.0) * 4.0, - ); - result.insert( - 140, - (pd::twos_comp(pd::little_endian(&data[2..4], 8), 16) as f32) * (1.648 / 1000.0), - ); - result.insert( - 141, - (pd::twos_comp(pd::little_endian(&data[4..6], 8), 16) as f32) * (1.648 / 1000.0), - ); - result.insert( - 142, - (pd::twos_comp(pd::little_endian(&data[6..8], 8), 16) as f32) * (1.46487 / 1000000.0) - / (0.5 / 1000.0), - ); +use super::data::{Data,FormatData as fd, ProcessData as pd}; +pub fn decode_accumulator_status(data: &[u8]) -> Vec:: { + let mut result = Vec::::new(); + result.push(Data::new(fd::high_voltage(pd::big_endian(&data[0..2] as &[u8], 8) as f32), "BMS/Pack/Voltage", "V")); + result.push(Data::new(fd::current(pd::twos_comp(pd::big_endian(&data[2..4] as &[u8], 8) as u32, 16) as f32), "BMS/Pack/Current", "A")); + result.push(Data::new(pd::big_endian(&data[4..6] as &[u8], 8) as f32, "BMS/Pack/Amp-hours", "Ah")); + result.push(Data::new(data[6] as f32, "BMS/Pack/SOC", "%")); + result.push(Data::new(data[7] as f32, "BMS/Pack/Health", "%")); + result +} +pub fn decode_bms_status(data: &[u8]) -> Vec:: { + let mut result = Vec::::new(); + result.push(Data::new(data[0] as f32, "BMS/State", "")); + result.push(Data::new(pd::little_endian(&data[1..5] as &[u8], 8) as f32, "BMS/Faults", "")); + result.push(Data::new(pd::twos_comp(data[5] as u32, 8) as f32, "BMS/Temps/Average", "C")); + result.push(Data::new(pd::twos_comp(data[6] as u32, 8) as f32, "BMS/Temps/Internal", "C")); + result.push(Data::new(data[7] as f32, "BMS/Cells/BurningStatus", "")); + result +} +pub fn decode_shutdown_control(data: &[u8]) -> Vec:: { + let mut result = Vec::::new(); + result.push(Data::new(data[0] as f32, "BMS/Shutdown/MPE", "")); + result +} +pub fn decode_cell_data(data: &[u8]) -> Vec:: { + let mut result = Vec::::new(); + result.push(Data::new(fd::cell_voltage(pd::little_endian(&data[0..2] as &[u8], 8) as f32), "BMS/Cells/Volts/High/Value", "V")); + result.push(Data::new(pd::half(data[2] as u8, 4) as f32, "BMS/Cells/Volts/High/Chip", "")); + result.push(Data::new(pd::half(data[3] as u8, 0) as f32, "BMS/Cells/Volts/High/Cell", "")); + result.push(Data::new(fd::cell_voltage(pd::little_endian(&data[4..6] as &[u8], 8) as f32), "BMS/Cells/Volts/Low/Value", "V")); + result.push(Data::new(pd::half(data[6] as u8, 4) as f32, "BMS/Cells/Volts/Low/Chip", "")); + result.push(Data::new(pd::half(data[7] as u8, 0) as f32, "BMS/Cells/Volts/Low/Cell", "")); + result.push(Data::new(fd::cell_voltage(pd::little_endian(&data[8..10] as &[u8], 8) as f32), "BMS/Cells/Volts/Ave/Value", "V")); + result +} +pub fn decode_cell_temperatures(data: &[u8]) -> Vec:: { + let mut result = Vec::::new(); + result.push(Data::new(pd::twos_comp(pd::little_endian(&data[0..2] as &[u8], 8) as u32, 16) as f32, "BMS/Cells/Temp/High/Value", "C")); + result.push(Data::new(pd::half(data[2] as u8, 4) as f32, "BMS/Cells/Temp/High/Cell", "")); + result.push(Data::new(pd::half(data[3] as u8, 0) as f32, "BMS/Cells/Temp/High/Chip", "")); + result.push(Data::new(pd::twos_comp(pd::little_endian(&data[4..6] as &[u8], 8) as u32, 16) as f32, "BMS/Cells/Temp/Low/Value", "C")); + result.push(Data::new(pd::half(data[6] as u8, 4) as f32, "BMS/Cells/Temp/Low/Cell", "")); + result.push(Data::new(pd::half(data[7] as u8, 0) as f32, "BMS/Cells/Temp/Low/Chip", "")); + result.push(Data::new(pd::twos_comp(pd::little_endian(&data[8..10] as &[u8], 8) as u32, 16) as f32, "BMS/Cells/Temp/Ave/Value", "C")); + result +} +pub fn decode_segment_temperatures(data: &[u8]) -> Vec:: { + let mut result = Vec::::new(); + result.push(Data::new(pd::twos_comp(data[0] as u32, 8) as f32, "BMS/Segment/Temp/1", "C")); + result.push(Data::new(pd::twos_comp(data[1] as u32, 8) as f32, "BMS/Segment/Temp/2", "C")); + result.push(Data::new(pd::twos_comp(data[2] as u32, 8) as f32, "BMS/Segment/Temp/3", "C")); + result.push(Data::new(pd::twos_comp(data[3] as u32, 8) as f32, "BMS/Segment/Temp/4", "C")); + result +} +pub fn decode_nerduino_acceleromter(data: &[u8]) -> Vec:: { + let mut result = Vec::::new(); + result.push(Data::new(fd::acceleration(pd::big_endian(&data[0..2] as &[u8], 8) as f32), "MPU/Accel/X", "g")); + result.push(Data::new(fd::acceleration(pd::big_endian(&data[2..4] as &[u8], 8) as f32), "MPU/Accel/Y", "g")); + result.push(Data::new(fd::acceleration(pd::big_endian(&data[4..6] as &[u8], 8) as f32), "MPU/Accel/Z", "g")); + result +} +pub fn decode_mpu_status(data: &[u8]) -> Vec:: { + let mut result = Vec::::new(); + result.push(Data::new(data[0] as f32, "MPU/State/Mode", "")); + result.push(Data::new(data[1] as f32, "MPU/State/Torque_Limit_Percentage", "")); + result.push(Data::new(data[2] as f32, "MPU/State/Regen_Strength", "")); + result.push(Data::new(data[3] as f32, "MPU/State/Traction_Control", "")); + result +} +pub fn decode_wheel_state(data: &[u8]) -> Vec:: { + let mut result = Vec::::new(); + result.push(Data::new(data[0] as f32, "WHEEL/Buttons/1", "")); + result.push(Data::new(data[1] as f32, "WHEEL/Buttons/2", "")); result } diff --git a/src/lib.rs b/src/lib.rs index 792d80a..dee3003 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,5 @@ pub mod client; pub mod data; pub mod decode_data; -pub mod master_mapping; pub mod message; pub mod mqtt; diff --git a/src/master_mapping.rs b/src/master_mapping.rs deleted file mode 100644 index 2f75cdc..0000000 --- a/src/master_mapping.rs +++ /dev/null @@ -1,244 +0,0 @@ -use super::decode_data::*; -use super::data::Data; - -pub struct MessageInfo { - pub description: String, - pub decoder: fn(data: &[u8]) -> Vec, -} - -impl MessageInfo { - pub fn new(description: String, decoder: fn(data: &[u8]) -> Vec) -> Self { - Self { - description, - decoder, - } - } -} - -// Mapping from external message ID to decoding information -pub fn get_message_info(id: &u32) -> MessageInfo { - match id { - 1 => MessageInfo::new("accumulator status".to_string(), decode_accumulator_status), - 2 => MessageInfo::new("BMS status".to_string(), decode_bms_status), - 3 => MessageInfo::new("shutdown control".to_string(), decode3), - 4 => MessageInfo::new("cell data".to_string(), decode_cell_voltages), - 160 => MessageInfo::new( - "temperatures (igbt modules, gate driver board)".to_string(), - decode5, - ), - 161 => MessageInfo::new("temperatures (control board)".to_string(), decode6), - 162 => MessageInfo::new("temperatures (motor)".to_string(), decode7), - 163 => MessageInfo::new("analog input voltages".to_string(), decode8), - 164 => MessageInfo::new("digital input status".to_string(), decode9), - 165 => MessageInfo::new("motor position information".to_string(), decode10), - 166 => MessageInfo::new("Current information".to_string(), decode11), - 167 => MessageInfo::new("Voltage Information".to_string(), decode12), - 168 => MessageInfo::new("Flux Information".to_string(), decode13), - 169 => MessageInfo::new("Internal Voltages".to_string(), decode14), - 170 => MessageInfo::new("Internal States".to_string(), decode15), - 171 => MessageInfo::new("Fault Codes".to_string(), decode16), - 172 => MessageInfo::new("Torque and Timer Decoder".to_string(), decode17), - 192 => MessageInfo::new("Command Data".to_string(), decode18), - 514 => MessageInfo::new("Current Limits".to_string(), decode19), - 768 => MessageInfo::new( - "NERduino Accelerometer".to_string(), - decode_accelerometer_data, - ), - 769 => MessageInfo::new("NERduino Humidity".to_string(), decode21), - 7 => MessageInfo::new("Cell Voltages".to_string(), decode_mock), - 193 => MessageInfo::new("Unknown 1".to_string(), decode_mock), - 6 => MessageInfo::new("Unknown 2".to_string(), decode_mock), - 194 => MessageInfo::new("Unknown 3".to_string(), decode_mock), - 1744 => MessageInfo::new("Unknown 4".to_string(), decode_mock), - 1745 => MessageInfo::new("Unknown 5".to_string(), decode_mock), - 175 => MessageInfo::new("Unknown 6".to_string(), decode_mock), - 770 => MessageInfo::new("GLV Current".to_string(), decode29), - 2015 => MessageInfo::new("Unknown 2015".to_string(), decode_mock), - 2027 => MessageInfo::new("Unknown 2027".to_string(), decode_mock), - 2019 => MessageInfo::new("Unknown 2019".to_string(), decode_mock), - 771 => MessageInfo::new("Strain Gauge".to_string(), decode34), - 1024 => MessageInfo::new("Wheel State".to_string(), decode35), - 10 => MessageInfo::new("MPU States".to_string(), decode_mpu_dashboard_info), - 772 => MessageInfo::new("GPS Data 1".to_string(), decode_gps_1), - 773 => MessageInfo::new("GPS Data 2".to_string(), decode_gps_2), - 774 => MessageInfo::new("GPS Data 3".to_string(), decode_gps_3), - 8 => MessageInfo::new("Cell Temperatures".to_string(), decode_cell_temps), - 9 => MessageInfo::new("Segment Temperatures".to_string(), decode_segment_temps), - 775 => MessageInfo::new("Logging Status".to_string(), decode_logging_status), - 1025 => MessageInfo::new("LV Battery 1".to_string(), decode_lv_battery_1), - 1026 => MessageInfo::new("LV Battery 2".to_string(), decode_lv_battery_2), - _ => MessageInfo::new("Unknown".to_string(), decode_mock), - } -} - -//Unused Data Ids Implementation in rust -/* -pub struct DataInfo { - name: String, - units: String, -} - -impl DataInfo { - pub fn new(name: String, units: String) -> Self { - Self { name, units } - } -} - -// maps from data id to DataInfo containing the name of the data and its units -pub fn get_data_info(id: u8) -> DataInfo { - match id { - 0 => DataInfo::new("Mock Data".to_string(), "".to_string()), - 1 => DataInfo::new("Pack Inst Voltage".to_string(), "V".to_string()), - 2 => DataInfo::new("Pack Current".to_string(), "A".to_string()), - 3 => DataInfo::new("Pack Amphours".to_string(), "Ah".to_string()), - 4 => DataInfo::new("Pack SOC".to_string(), "%".to_string()), - 5 => DataInfo::new("Pack Health".to_string(), "%".to_string()), - 6 => DataInfo::new("Failsafe Statuses".to_string(), "HEX".to_string()), - 7 => DataInfo::new("DTC Status 1".to_string(), "HEX".to_string()), - 8 => DataInfo::new("DTC Status 2".to_string(), "HEX".to_string()), - 9 => DataInfo::new("Current Limits Status".to_string(), "".to_string()), - 10 => DataInfo::new("Average Temp".to_string(), "C".to_string()), - 11 => DataInfo::new("Internal Temp".to_string(), "C".to_string()), - 12 => DataInfo::new("MPE State".to_string(), "BIN".to_string()), - 13 => DataInfo::new("High Cell Voltage".to_string(), "V".to_string()), - 14 => DataInfo::new("High Cell Voltage ID".to_string(), "".to_string()), - 15 => DataInfo::new("Low Cell Voltage".to_string(), "V".to_string()), - 16 => DataInfo::new("Low Cell Voltage ID".to_string(), "".to_string()), - 17 => DataInfo::new("Average Cell Voltage".to_string(), "V".to_string()), - 18 => DataInfo::new("Module A Temperature".to_string(), "C".to_string()), - 19 => DataInfo::new("Module B Temperature".to_string(), "C".to_string()), - 20 => DataInfo::new("Module C Temperature".to_string(), "C".to_string()), - 21 => DataInfo::new("Gate Driver Board Temperature".to_string(), "C".to_string()), - 22 => DataInfo::new("Control Board Temperature".to_string(), "C".to_string()), - 23 => DataInfo::new("RTD #1 Temperature".to_string(), "C".to_string()), - 24 => DataInfo::new("RTD #2 Temperature".to_string(), "C".to_string()), - 25 => DataInfo::new("RTD #3 Temperature".to_string(), "C".to_string()), - 26 => DataInfo::new("RTD #4 Temperature".to_string(), "C".to_string()), - 27 => DataInfo::new("RTD #5 Temperature".to_string(), "C".to_string()), - 28 => DataInfo::new("Motor Temperature".to_string(), "C".to_string()), - 29 => DataInfo::new("Torque Shudder".to_string(), "N-m".to_string()), - 30 => DataInfo::new("Analog Input 1".to_string(), "V".to_string()), - 31 => DataInfo::new("Analog Input 2".to_string(), "V".to_string()), - 32 => DataInfo::new("Analog Input 3".to_string(), "V".to_string()), - 33 => DataInfo::new("Analog Input 4".to_string(), "V".to_string()), - 34 => DataInfo::new("Analog Input 5".to_string(), "V".to_string()), - 35 => DataInfo::new("Analog Input 6".to_string(), "V".to_string()), - 36 => DataInfo::new("Digital Input 1".to_string(), "BIN".to_string()), - 37 => DataInfo::new("Digital Input 2".to_string(), "BIN".to_string()), - 38 => DataInfo::new("Digital Input 3".to_string(), "BIN".to_string()), - 39 => DataInfo::new("Digital Input 4".to_string(), "BIN".to_string()), - 40 => DataInfo::new("Digital Input 5".to_string(), "BIN".to_string()), - 41 => DataInfo::new("Digital Input 6".to_string(), "BIN".to_string()), - 42 => DataInfo::new("Digital Input 7".to_string(), "BIN".to_string()), - 43 => DataInfo::new("Digital Input 8".to_string(), "BIN".to_string()), - 44 => DataInfo::new("Motor Angle Electrical".to_string(), "Deg".to_string()), - 45 => DataInfo::new("Motor Speed".to_string(), "RPM".to_string()), - 46 => DataInfo::new("Electrical Output Frequency".to_string(), "Hz".to_string()), - 48 => DataInfo::new("Phase A Current".to_string(), "A".to_string()), - 49 => DataInfo::new("Phase B Current".to_string(), "A".to_string()), - 50 => DataInfo::new("Phase C Current".to_string(), "A".to_string()), - 51 => DataInfo::new("DC Bus Current".to_string(), "A".to_string()), - 52 => DataInfo::new("DC Bus Voltage".to_string(), "V".to_string()), - 53 => DataInfo::new("Output Voltage".to_string(), "V".to_string()), - 54 => DataInfo::new("VAB_Vd Voltage".to_string(), "V".to_string()), - 55 => DataInfo::new("VBC_Vq Voltage".to_string(), "V".to_string()), - 56 => DataInfo::new("Flux Command".to_string(), "Wb".to_string()), - 57 => DataInfo::new("Flux Feedback".to_string(), "wb".to_string()), - 58 => DataInfo::new("Id Feedback".to_string(), "A".to_string()), - 59 => DataInfo::new("Iq Feedback".to_string(), "A".to_string()), - 60 => DataInfo::new("1.5V Reference Voltage".to_string(), "V".to_string()), - 61 => DataInfo::new("2.5V Reference Voltage".to_string(), "V".to_string()), - 62 => DataInfo::new("5.0V Reference Voltage".to_string(), "V".to_string()), - 63 => DataInfo::new("12V System Voltage".to_string(), "V".to_string()), - 64 => DataInfo::new("VSM State".to_string(), "".to_string()), - 65 => DataInfo::new("Inverter State".to_string(), "".to_string()), - 66 => DataInfo::new("Relay State".to_string(), "BIN".to_string()), - 67 => DataInfo::new("Inverter Run Mode".to_string(), "BIN".to_string()), - 68 => { - DataInfo::new( - "Inverter Active Discharge State".to_string(), - "BIN".to_string(), - ) - } - 69 => DataInfo::new("Inverter Command Mode".to_string(), "BIN".to_string()), - 70 => DataInfo::new("Inverter Enable State".to_string(), "BIN".to_string()), - 71 => DataInfo::new("Inverter Enable Lockout".to_string(), "BIN".to_string()), - 72 => DataInfo::new("Direction Command".to_string(), "BIN".to_string()), - 73 => DataInfo::new("BMS Active".to_string(), "BIN".to_string()), - 74 => DataInfo::new("BMS Limiting Torque".to_string(), "BIN".to_string()), - 75 => DataInfo::new("POST Fault Lo".to_string(), "BIN".to_string()), - 76 => DataInfo::new("POST Fault Hi".to_string(), "BIN".to_string()), - 77 => DataInfo::new("Run Fault Lo".to_string(), "BIN".to_string()), - 78 => DataInfo::new("Run Fault Hi".to_string(), "BIN".to_string()), - 79 => DataInfo::new("Commanded Torque".to_string(), "N-m".to_string()), - 80 => DataInfo::new("Torque Feedback".to_string(), "N-m".to_string()), - 81 => DataInfo::new("Power on Timer".to_string(), "s".to_string()), - 82 => DataInfo::new("Torque Command".to_string(), "N-m".to_string()), - 83 => DataInfo::new("Speed Command".to_string(), "RPM".to_string()), - 84 => DataInfo::new("Direction Command".to_string(), "BIN".to_string()), - 85 => DataInfo::new("Inverter Enable".to_string(), "BIN".to_string()), - 86 => DataInfo::new("Inverter Discharge".to_string(), "BIN".to_string()), - 87 => DataInfo::new("Speed Mode Enable".to_string(), "BIN".to_string()), - 88 => DataInfo::new("Commanded Torque Limit".to_string(), "N-m".to_string()), - 89 => DataInfo::new("Pack DCL".to_string(), "A".to_string()), - 90 => DataInfo::new("Pack CCL".to_string(), "A".to_string()), - 91 => DataInfo::new("TCU X-Axis Acceleration".to_string(), "g".to_string()), - 92 => DataInfo::new("TCU Y-Axis Acceleration".to_string(), "g".to_string()), - 93 => DataInfo::new("TCU Z-Axis Acceleration".to_string(), "g".to_string()), - 94 => DataInfo::new("TCU Temperature C".to_string(), "C".to_string()), - 95 => DataInfo::new("TCU Temperature F".to_string(), "F".to_string()), - 96 => DataInfo::new("Relative Humidity".to_string(), "%".to_string()), - 97 => DataInfo::new("Cell Voltage Info".to_string(), "".to_string()), - 98 => DataInfo::new("GLV Current".to_string(), "A".to_string()), - 99 => DataInfo::new("Strain Gauge Voltage 1".to_string(), "V".to_string()), - 100 => DataInfo::new("Strain Gauge Voltage 2".to_string(), "V".to_string()), - 101 => DataInfo::new("Vehicle Speed".to_string(), "MPH".to_string()), - 102 => DataInfo::new("Wheel Knob 1".to_string(), "".to_string()), - 103 => DataInfo::new("Wheel Knob 2".to_string(), "".to_string()), - 104 => DataInfo::new("Wheel Buttons".to_string(), "".to_string()), - 105 => DataInfo::new("MPU Mode State".to_string(), "".to_string()), - 106 => DataInfo::new("BMS State".to_string(), "".to_string()), - 107 => DataInfo::new("BMS Faults".to_string(), "HEX".to_string()), - 108 => DataInfo::new("Latitude".to_string(), "Deg".to_string()), - 109 => DataInfo::new("Longitude".to_string(), "Deg".to_string()), - 110 => DataInfo::new("GPS Fix Status".to_string(), "".to_string()), - 111 => DataInfo::new("Altitude".to_string(), "m".to_string()), - 112 => DataInfo::new("Ground Speed".to_string(), "m/s".to_string()), - 113 => DataInfo::new("Heading Direction".to_string(), "Deg".to_string()), - 114 => DataInfo::new("High Cell Temp".to_string(), "C".to_string()), - 115 => DataInfo::new("High Cell Temp Chip Number".to_string(), "".to_string()), - 116 => DataInfo::new("High Cell Temp Cell Number".to_string(), "".to_string()), - 117 => DataInfo::new("Low Cell Temp".to_string(), "C".to_string()), - 118 => DataInfo::new("Low Cell Temp Chip Number".to_string(), "".to_string()), - 119 => DataInfo::new("Low Cell temp Cell Number".to_string(), "".to_string()), - 120 => DataInfo::new("Average Cell Temp".to_string(), "C".to_string()), - 121 => DataInfo::new("High Cell Voltage Chip Number".to_string(), "".to_string()), - 122 => DataInfo::new("High Cell Voltage Cell Number".to_string(), "".to_string()), - 123 => DataInfo::new("Low Cell Voltage Chip Number".to_string(), "".to_string()), - 124 => DataInfo::new("Low Cell Voltage Cell Number".to_string(), "".to_string()), - 125 => DataInfo::new("Segment 1 Average Temperature".to_string(), "C".to_string()), - 126 => DataInfo::new("Segment 2 Average Temperature".to_string(), "C".to_string()), - 127 => DataInfo::new("Segment 3 Average Temperature".to_string(), "C".to_string()), - 128 => DataInfo::new("Segment 4 Average Temperature".to_string(), "C".to_string()), - 129 => DataInfo::new("Logging Status".to_string(), "".to_string()), - 130 => DataInfo::new("Accumulator Fan Percentage".to_string(), "%".to_string()), - 131 => DataInfo::new("Motor Fan Percentage".to_string(), "%".to_string()), - 132 => DataInfo::new("Torque Limit Percentage".to_string(), "%".to_string()), - 133 => DataInfo::new("Regen Strength value".to_string(), "".to_string()), - 134 => DataInfo::new("Carger State".to_string(), "".to_string()), - 135 => DataInfo::new("Measurement System Valid".to_string(), "".to_string()), - 136 => DataInfo::new("System Status".to_string(), "".to_string()), - 137 => DataInfo::new("Charge Status".to_string(), "".to_string()), - 138 => DataInfo::new("ibat".to_string(), "A".to_string()), - 139 => DataInfo::new("vbat".to_string(), "V".to_string()), - 140 => DataInfo::new("vin".to_string(), "V".to_string()), - 141 => DataInfo::new("vsys".to_string(), "V".to_string()), - 142 => DataInfo::new("iin".to_string(), "A".to_string()), - 143 => DataInfo::new("Cell Burning Status".to_string(), "".to_string()), - 144 => DataInfo::new("Traction Control On".to_string(), "".to_string()), - 145 => DataInfo::new("Precharge State".to_string(), "".to_string()), - 146 => DataInfo::new("BMS Prefault Status".to_string(), "".to_string()), - _ => DataInfo::new("".to_string(), "".to_string()), - } -} -*/ diff --git a/src/message.rs b/src/message.rs index 085ef56..b34fe38 100644 --- a/src/message.rs +++ b/src/message.rs @@ -1,7 +1,6 @@ use chrono::{DateTime, Utc}; use super::data::Data; -use super::master_mapping::get_message_info; /** * Wrapper class for an individual message. From 13decd2bd626e61f4ef4615a925678948131b604 Mon Sep 17 00:00:00 2001 From: Peyton-McKee Date: Thu, 11 Jan 2024 16:51:29 -0500 Subject: [PATCH 32/41] #20 Compile --- oxy/RustSynth.py | 69 +++++++++++++++++++++++++++++++++++-------- oxy/structs/Result.py | 8 +++++ oxy/typedpoc.py | 11 +++++-- src/data.rs | 20 ++++++------- src/decode_data.rs | 6 ++++ src/lib.rs | 1 + src/main.rs | 10 ++----- src/master_mapping.rs | 27 +++++++++++++++++ src/message.rs | 11 +++---- 9 files changed, 123 insertions(+), 40 deletions(-) create mode 100644 oxy/structs/Result.py create mode 100644 src/master_mapping.rs diff --git a/oxy/RustSynth.py b/oxy/RustSynth.py index 8f0c515..3cc18d2 100644 --- a/oxy/RustSynth.py +++ b/oxy/RustSynth.py @@ -1,34 +1,79 @@ from structs.CANField import CANField from structs.CANMsg import CANMsg from structs.Messages import Messages +from structs.Result import Result class RustSynth: ''' A class to synthesize Rust from a given CANMsg spec. ''' - imports: str = "use super::data::{Data,FormatData as fd, ProcessData as pd}; \n" - return_type: str = "Vec::" - inst_hashmap: str = f" let mut result = {return_type}::new();" - closing: str = " result\n}" + decode_data_import: str = "use super::data::{Data,FormatData as fd, ProcessData as pd}; \n" + + decode_return_type: str = "Vec::" + decode_return_value: str = f" let mut result = {decode_return_type}::new();" + decode_closing: str = " result\n}" + + decode_mock: str = """ +pub fn decode_mock(_data: &[u8]) -> Vec:: { + let mut result = Vec::::new(); + result.push(Data::new(0.0, "Mock", "")); + result +} +""" + + master_mapping_import: str = "use super::decode_data::*; \nuse super::data::Data; \n" + + master_mapping_signature: str = "pub fn get_message_info(id: &u32) -> MessageInfo { \n match id {" + + master_mapping_closing: str = " _ => MessageInfo::new(decode_mock), \n }\n}" + + message_info = """ +pub struct MessageInfo { + pub decoder: fn(data: &[u8]) -> Vec, +} + +impl MessageInfo { + pub fn new(decoder: fn(data: &[u8]) -> Vec) -> Self { + Self { + decoder + } + } +} +""" + + def parse_messages(self, msgs: Messages) -> Result: + result = Result("", "") + result.decode_data += self.decode_data_import + result.decode_data += self.decode_mock + + result.master_mapping += self.master_mapping_import + result.master_mapping += self.message_info + result.master_mapping += self.master_mapping_signature - def parse_messages(self, msgs: Messages) -> str: - str = "" - str += self.imports for msg in msgs.msgs: - str += self.synthesize(msg) + "\n" - return str + result.decode_data += self.synthesize(msg) + "\n" + result.master_mapping += self.map_msg_to_decoder(msg) + + result.master_mapping += self.master_mapping_closing + return result + + def map_msg_to_decoder(self, msg: CANMsg) -> str: + return f" {msg.id} => MessageInfo::new({self.function_name(msg.desc)}),\n" def synthesize(self, msg: CANMsg) -> str: signature: str = self.signature(msg.desc) generated_lines: list[str] = [] for field in msg.fields: generated_lines.append(self.finalize_line(field.name, field.unit, f"{self.format_data(field, self.parse_decoders(field))}")) - total_list: list[str] = [signature, self.inst_hashmap] + generated_lines + [self.closing] + total_list: list[str] = [signature, self.decode_return_value] + generated_lines + [self.decode_closing] return "\n".join(total_list) + + def function_name(self, desc: str) -> str: + return f"decode_{desc.replace(' ', '_').lower()}" - def signature(self, to_decode: str) -> str: - return f"pub fn decode_{to_decode.replace(' ', '_').lower()}(data: &[u8]) -> {self.return_type} {{" + def signature(self, desc: str) -> str: + return f"pub fn {self.function_name(desc)}(data: &[u8]) -> {self.decode_return_type} {{" def finalize_line(self, topic: str, unit: str, val: str) -> str: return f" result.push(Data::new({val}, \"{topic}\", \"{unit}\"));" diff --git a/oxy/structs/Result.py b/oxy/structs/Result.py new file mode 100644 index 0000000..662cd48 --- /dev/null +++ b/oxy/structs/Result.py @@ -0,0 +1,8 @@ + +class Result: + decode_data: str + master_mapping: str + + def __init__(self, decode_data: str, master_mapping: str): + self.decode_data = decode_data + self.master_mapping = master_mapping \ No newline at end of file diff --git a/oxy/typedpoc.py b/oxy/typedpoc.py index 2012540..a7595e7 100644 --- a/oxy/typedpoc.py +++ b/oxy/typedpoc.py @@ -1,8 +1,13 @@ from YAMLParser import YAMLParser from RustSynth import RustSynth -f = open("../src/decode_data.rs", "w") +decode_data = open("../src/decode_data.rs", "w") +master_mapping = open("../src/master_mapping.rs", "w") -f.write(RustSynth().parse_messages(YAMLParser().parse(open("mapping.yaml", "r")))) +result = RustSynth().parse_messages(YAMLParser().parse(open("mapping.yaml", "r"))) -f.close() +decode_data.write(result.decode_data) +decode_data.close() + +master_mapping.write(result.master_mapping) +master_mapping.close() \ No newline at end of file diff --git a/src/data.rs b/src/data.rs index eadab45..9c14737 100644 --- a/src/data.rs +++ b/src/data.rs @@ -126,27 +126,27 @@ impl FormatData { -value } - pub fn frequency(value: i64) -> f32 { - value as f32 / 10.0 + pub fn frequency(value: f32) -> f32 { + value / 10.0 } - pub fn power(value: i32) -> f32 { - value as f32 / 10.0 + pub fn power(value: f32) -> f32 { + value / 10.0 } - pub fn timer(value: i32) -> f32 { - value as f32 * 0.003 + pub fn timer(value: f32) -> f32 { + value * 0.003 } - pub fn flux(value: i64) -> f32 { - value as f32 / 1000.0 + pub fn flux(value: f32) -> f32 { + value / 1000.0 } pub fn cell_voltage(value: f32) -> f32 { - value as f32 / 10000.0 + value / 10000.0 } pub fn acceleration(value: f32) -> f32 { - value as f32 * 0.0029 + value * 0.0029 } } diff --git a/src/decode_data.rs b/src/decode_data.rs index a300f53..0bc8f1b 100644 --- a/src/decode_data.rs +++ b/src/decode_data.rs @@ -1,4 +1,10 @@ use super::data::{Data,FormatData as fd, ProcessData as pd}; + +pub fn decode_mock(_data: &[u8]) -> Vec:: { + let mut result = Vec::::new(); + result.push(Data::new(0.0, "Mock", "")); + result +} pub fn decode_accumulator_status(data: &[u8]) -> Vec:: { let mut result = Vec::::new(); result.push(Data::new(fd::high_voltage(pd::big_endian(&data[0..2] as &[u8], 8) as f32), "BMS/Pack/Voltage", "V")); diff --git a/src/lib.rs b/src/lib.rs index dee3003..455565d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,3 +3,4 @@ pub mod data; pub mod decode_data; pub mod message; pub mod mqtt; +pub mod master_mapping; \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 9e1bc40..038f5f9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,8 +3,7 @@ use std::{ process::{self, Command}, }; -use calypso::{client::Client, message::Message, mqtt::MqttClient, socket::IPCConnection}; -use chrono::{DateTime, Utc}; +use calypso::{client::Client, message::Message, mqtt::MqttClient}; use socketcan::CANSocket; fn configure_can() { @@ -64,9 +63,8 @@ fn read_can(mut publisher: Box) { continue; } }; - let date: DateTime = Utc::now(); let data = msg.data(); - let message = Message::new(date, msg.id(), data.to_vec()); + let message = Message::new(msg.id(), data.to_vec()); let decoded_data = message.decode(); for (_i, data) in decoded_data.iter().enumerate() { publisher.publish(data) @@ -96,10 +94,6 @@ fn parse_args() -> (String, Box) { String::from(path), Box::new(MqttClient::new()) as Box, ), - "ipc" => ( - String::from(path), - Box::new(IPCConnection::new()) as Box, - ), _ => { println!("Please provide a valid client type"); process::exit(1); diff --git a/src/master_mapping.rs b/src/master_mapping.rs new file mode 100644 index 0000000..95a5b7a --- /dev/null +++ b/src/master_mapping.rs @@ -0,0 +1,27 @@ +use super::decode_data::*; +use super::data::Data; + +pub struct MessageInfo { + pub decoder: fn(data: &[u8]) -> Vec, +} + +impl MessageInfo { + pub fn new(decoder: fn(data: &[u8]) -> Vec) -> Self { + Self { + decoder + } + } +} +pub fn get_message_info(id: &u32) -> MessageInfo { + match id { 0x80 => MessageInfo::new(decode_accumulator_status), + 0x81 => MessageInfo::new(decode_bms_status), + 0x82 => MessageInfo::new(decode_shutdown_control), + 0x83 => MessageInfo::new(decode_cell_data), + 0x84 => MessageInfo::new(decode_cell_temperatures), + 0x85 => MessageInfo::new(decode_segment_temperatures), + 0x500 => MessageInfo::new(decode_nerduino_acceleromter), + 0x501 => MessageInfo::new(decode_mpu_status), + 0x680 => MessageInfo::new(decode_wheel_state), + _ => MessageInfo::new(decode_mock), + } +} \ No newline at end of file diff --git a/src/message.rs b/src/message.rs index b34fe38..0a8c9be 100644 --- a/src/message.rs +++ b/src/message.rs @@ -1,12 +1,10 @@ -use chrono::{DateTime, Utc}; - use super::data::Data; +use super::master_mapping::get_message_info; /** * Wrapper class for an individual message. */ pub struct Message { - timestamp: DateTime, id: u32, data: Vec, } @@ -18,9 +16,8 @@ impl Message { /** * Creates a new message with the given timestamp, id, and data. */ - pub fn new(timestamp: DateTime, id: u32, data: Vec) -> Self { + pub fn new(id: u32, data: Vec) -> Self { Self { - timestamp, id, data, } @@ -30,7 +27,7 @@ impl Message { * Decodes the message and returns a vector of Data objects. */ pub fn decode(&self) -> Vec { - self.decode_message(self.timestamp, &self.id, &self.data) + Message::decode_message(&self.id, &self.data) } /** @@ -41,7 +38,7 @@ impl Message { * param data: The data of the message. * return: A vector of Data objects. */ - fn decode_message(&self, timestamp: DateTime, id: &u32, data: &[u8]) -> Vec { + fn decode_message(id: &u32, data: &[u8]) -> Vec { let decoder = get_message_info(id).decoder; let mut decoded_data: Vec = Vec::new(); let result = decoder(data); From 80ac68878ac2851ff6c67f247553a8dd2a0c52fc Mon Sep 17 00:00:00 2001 From: Peyton-McKee Date: Thu, 11 Jan 2024 16:58:39 -0500 Subject: [PATCH 33/41] #20 Cleanup Some Linting errors --- oxy/RustSynth.py | 8 ++-- src/data.rs | 6 +-- src/decode_data.rs | 112 ++++++++++++++++++++++++++------------------- 3 files changed, 72 insertions(+), 54 deletions(-) diff --git a/oxy/RustSynth.py b/oxy/RustSynth.py index 3cc18d2..76feecb 100644 --- a/oxy/RustSynth.py +++ b/oxy/RustSynth.py @@ -11,8 +11,8 @@ class RustSynth: decode_data_import: str = "use super::data::{Data,FormatData as fd, ProcessData as pd}; \n" decode_return_type: str = "Vec::" - decode_return_value: str = f" let mut result = {decode_return_type}::new();" - decode_closing: str = " result\n}" + decode_return_value: str = f" let result = vec![" + decode_close: str = " ]; \n result\n}\n" decode_mock: str = """ pub fn decode_mock(_data: &[u8]) -> Vec:: { @@ -66,7 +66,7 @@ def synthesize(self, msg: CANMsg) -> str: generated_lines: list[str] = [] for field in msg.fields: generated_lines.append(self.finalize_line(field.name, field.unit, f"{self.format_data(field, self.parse_decoders(field))}")) - total_list: list[str] = [signature, self.decode_return_value] + generated_lines + [self.decode_closing] + total_list: list[str] = [signature, self.decode_return_value] + generated_lines + [self.decode_close] return "\n".join(total_list) def function_name(self, desc: str) -> str: @@ -76,7 +76,7 @@ def signature(self, desc: str) -> str: return f"pub fn {self.function_name(desc)}(data: &[u8]) -> {self.decode_return_type} {{" def finalize_line(self, topic: str, unit: str, val: str) -> str: - return f" result.push(Data::new({val}, \"{topic}\", \"{unit}\"));" + return f" Data::new({val}, \"{topic}\", \"{unit}\")," def parse_decoders(self, field: CANField) -> str: if isinstance(field.decodings, type(None)): diff --git a/src/data.rs b/src/data.rs index 9c14737..f13f818 100644 --- a/src/data.rs +++ b/src/data.rs @@ -52,11 +52,11 @@ impl ProcessData { /** * Computes the twos complement of the given value. */ - pub fn twos_comp(val: u32, bits: usize) -> f32 { + pub fn twos_comp(val: u32, bits: usize) -> i64 { if (val & (1 << (bits - 1))) != 0 { - (val as f32) - ((1 << bits) as f32) + (val as i64) - ((1 << bits) as i64) } else { - val as f32 + val as i64 } } diff --git a/src/decode_data.rs b/src/decode_data.rs index 0bc8f1b..d38aa85 100644 --- a/src/decode_data.rs +++ b/src/decode_data.rs @@ -6,76 +6,94 @@ pub fn decode_mock(_data: &[u8]) -> Vec:: { result } pub fn decode_accumulator_status(data: &[u8]) -> Vec:: { - let mut result = Vec::::new(); - result.push(Data::new(fd::high_voltage(pd::big_endian(&data[0..2] as &[u8], 8) as f32), "BMS/Pack/Voltage", "V")); - result.push(Data::new(fd::current(pd::twos_comp(pd::big_endian(&data[2..4] as &[u8], 8) as u32, 16) as f32), "BMS/Pack/Current", "A")); - result.push(Data::new(pd::big_endian(&data[4..6] as &[u8], 8) as f32, "BMS/Pack/Amp-hours", "Ah")); - result.push(Data::new(data[6] as f32, "BMS/Pack/SOC", "%")); - result.push(Data::new(data[7] as f32, "BMS/Pack/Health", "%")); + let result = vec![ + Data::new(fd::high_voltage(pd::big_endian(&data[0..2] as &[u8], 8) as f32), "BMS/Pack/Voltage", "V"), + Data::new(fd::current(pd::twos_comp(pd::big_endian(&data[2..4] as &[u8], 8) as u32, 16) as f32), "BMS/Pack/Current", "A"), + Data::new(pd::big_endian(&data[4..6] as &[u8], 8) as f32, "BMS/Pack/Amp-hours", "Ah"), + Data::new(data[6] as f32, "BMS/Pack/SOC", "%"), + Data::new(data[7] as f32, "BMS/Pack/Health", "%"), + ]; result } + pub fn decode_bms_status(data: &[u8]) -> Vec:: { - let mut result = Vec::::new(); - result.push(Data::new(data[0] as f32, "BMS/State", "")); - result.push(Data::new(pd::little_endian(&data[1..5] as &[u8], 8) as f32, "BMS/Faults", "")); - result.push(Data::new(pd::twos_comp(data[5] as u32, 8) as f32, "BMS/Temps/Average", "C")); - result.push(Data::new(pd::twos_comp(data[6] as u32, 8) as f32, "BMS/Temps/Internal", "C")); - result.push(Data::new(data[7] as f32, "BMS/Cells/BurningStatus", "")); + let result = vec![ + Data::new(data[0] as f32, "BMS/State", ""), + Data::new(pd::little_endian(&data[1..5] as &[u8], 8) as f32, "BMS/Faults", ""), + Data::new(pd::twos_comp(data[5] as u32, 8) as f32, "BMS/Temps/Average", "C"), + Data::new(pd::twos_comp(data[6] as u32, 8) as f32, "BMS/Temps/Internal", "C"), + Data::new(data[7] as f32, "BMS/Cells/BurningStatus", ""), + ]; result } + pub fn decode_shutdown_control(data: &[u8]) -> Vec:: { - let mut result = Vec::::new(); - result.push(Data::new(data[0] as f32, "BMS/Shutdown/MPE", "")); + let result = vec![ + Data::new(data[0] as f32, "BMS/Shutdown/MPE", ""), + ]; result } + pub fn decode_cell_data(data: &[u8]) -> Vec:: { - let mut result = Vec::::new(); - result.push(Data::new(fd::cell_voltage(pd::little_endian(&data[0..2] as &[u8], 8) as f32), "BMS/Cells/Volts/High/Value", "V")); - result.push(Data::new(pd::half(data[2] as u8, 4) as f32, "BMS/Cells/Volts/High/Chip", "")); - result.push(Data::new(pd::half(data[3] as u8, 0) as f32, "BMS/Cells/Volts/High/Cell", "")); - result.push(Data::new(fd::cell_voltage(pd::little_endian(&data[4..6] as &[u8], 8) as f32), "BMS/Cells/Volts/Low/Value", "V")); - result.push(Data::new(pd::half(data[6] as u8, 4) as f32, "BMS/Cells/Volts/Low/Chip", "")); - result.push(Data::new(pd::half(data[7] as u8, 0) as f32, "BMS/Cells/Volts/Low/Cell", "")); - result.push(Data::new(fd::cell_voltage(pd::little_endian(&data[8..10] as &[u8], 8) as f32), "BMS/Cells/Volts/Ave/Value", "V")); + let result = vec![ + Data::new(fd::cell_voltage(pd::little_endian(&data[0..2] as &[u8], 8) as f32), "BMS/Cells/Volts/High/Value", "V"), + Data::new(pd::half(data[2] as u8, 4) as f32, "BMS/Cells/Volts/High/Chip", ""), + Data::new(pd::half(data[3] as u8, 0) as f32, "BMS/Cells/Volts/High/Cell", ""), + Data::new(fd::cell_voltage(pd::little_endian(&data[4..6] as &[u8], 8) as f32), "BMS/Cells/Volts/Low/Value", "V"), + Data::new(pd::half(data[6] as u8, 4) as f32, "BMS/Cells/Volts/Low/Chip", ""), + Data::new(pd::half(data[7] as u8, 0) as f32, "BMS/Cells/Volts/Low/Cell", ""), + Data::new(fd::cell_voltage(pd::little_endian(&data[8..10] as &[u8], 8) as f32), "BMS/Cells/Volts/Ave/Value", "V"), + ]; result } + pub fn decode_cell_temperatures(data: &[u8]) -> Vec:: { - let mut result = Vec::::new(); - result.push(Data::new(pd::twos_comp(pd::little_endian(&data[0..2] as &[u8], 8) as u32, 16) as f32, "BMS/Cells/Temp/High/Value", "C")); - result.push(Data::new(pd::half(data[2] as u8, 4) as f32, "BMS/Cells/Temp/High/Cell", "")); - result.push(Data::new(pd::half(data[3] as u8, 0) as f32, "BMS/Cells/Temp/High/Chip", "")); - result.push(Data::new(pd::twos_comp(pd::little_endian(&data[4..6] as &[u8], 8) as u32, 16) as f32, "BMS/Cells/Temp/Low/Value", "C")); - result.push(Data::new(pd::half(data[6] as u8, 4) as f32, "BMS/Cells/Temp/Low/Cell", "")); - result.push(Data::new(pd::half(data[7] as u8, 0) as f32, "BMS/Cells/Temp/Low/Chip", "")); - result.push(Data::new(pd::twos_comp(pd::little_endian(&data[8..10] as &[u8], 8) as u32, 16) as f32, "BMS/Cells/Temp/Ave/Value", "C")); + let result = vec![ + Data::new(pd::twos_comp(pd::little_endian(&data[0..2] as &[u8], 8) as u32, 16) as f32, "BMS/Cells/Temp/High/Value", "C"), + Data::new(pd::half(data[2] as u8, 4) as f32, "BMS/Cells/Temp/High/Cell", ""), + Data::new(pd::half(data[3] as u8, 0) as f32, "BMS/Cells/Temp/High/Chip", ""), + Data::new(pd::twos_comp(pd::little_endian(&data[4..6] as &[u8], 8) as u32, 16) as f32, "BMS/Cells/Temp/Low/Value", "C"), + Data::new(pd::half(data[6] as u8, 4) as f32, "BMS/Cells/Temp/Low/Cell", ""), + Data::new(pd::half(data[7] as u8, 0) as f32, "BMS/Cells/Temp/Low/Chip", ""), + Data::new(pd::twos_comp(pd::little_endian(&data[8..10] as &[u8], 8) as u32, 16) as f32, "BMS/Cells/Temp/Ave/Value", "C"), + ]; result } + pub fn decode_segment_temperatures(data: &[u8]) -> Vec:: { - let mut result = Vec::::new(); - result.push(Data::new(pd::twos_comp(data[0] as u32, 8) as f32, "BMS/Segment/Temp/1", "C")); - result.push(Data::new(pd::twos_comp(data[1] as u32, 8) as f32, "BMS/Segment/Temp/2", "C")); - result.push(Data::new(pd::twos_comp(data[2] as u32, 8) as f32, "BMS/Segment/Temp/3", "C")); - result.push(Data::new(pd::twos_comp(data[3] as u32, 8) as f32, "BMS/Segment/Temp/4", "C")); + let result = vec![ + Data::new(pd::twos_comp(data[0] as u32, 8) as f32, "BMS/Segment/Temp/1", "C"), + Data::new(pd::twos_comp(data[1] as u32, 8) as f32, "BMS/Segment/Temp/2", "C"), + Data::new(pd::twos_comp(data[2] as u32, 8) as f32, "BMS/Segment/Temp/3", "C"), + Data::new(pd::twos_comp(data[3] as u32, 8) as f32, "BMS/Segment/Temp/4", "C"), + ]; result } + pub fn decode_nerduino_acceleromter(data: &[u8]) -> Vec:: { - let mut result = Vec::::new(); - result.push(Data::new(fd::acceleration(pd::big_endian(&data[0..2] as &[u8], 8) as f32), "MPU/Accel/X", "g")); - result.push(Data::new(fd::acceleration(pd::big_endian(&data[2..4] as &[u8], 8) as f32), "MPU/Accel/Y", "g")); - result.push(Data::new(fd::acceleration(pd::big_endian(&data[4..6] as &[u8], 8) as f32), "MPU/Accel/Z", "g")); + let result = vec![ + Data::new(fd::acceleration(pd::big_endian(&data[0..2] as &[u8], 8) as f32), "MPU/Accel/X", "g"), + Data::new(fd::acceleration(pd::big_endian(&data[2..4] as &[u8], 8) as f32), "MPU/Accel/Y", "g"), + Data::new(fd::acceleration(pd::big_endian(&data[4..6] as &[u8], 8) as f32), "MPU/Accel/Z", "g"), + ]; result } + pub fn decode_mpu_status(data: &[u8]) -> Vec:: { - let mut result = Vec::::new(); - result.push(Data::new(data[0] as f32, "MPU/State/Mode", "")); - result.push(Data::new(data[1] as f32, "MPU/State/Torque_Limit_Percentage", "")); - result.push(Data::new(data[2] as f32, "MPU/State/Regen_Strength", "")); - result.push(Data::new(data[3] as f32, "MPU/State/Traction_Control", "")); + let result = vec![ + Data::new(data[0] as f32, "MPU/State/Mode", ""), + Data::new(data[1] as f32, "MPU/State/Torque_Limit_Percentage", ""), + Data::new(data[2] as f32, "MPU/State/Regen_Strength", ""), + Data::new(data[3] as f32, "MPU/State/Traction_Control", ""), + ]; result } + pub fn decode_wheel_state(data: &[u8]) -> Vec:: { - let mut result = Vec::::new(); - result.push(Data::new(data[0] as f32, "WHEEL/Buttons/1", "")); - result.push(Data::new(data[1] as f32, "WHEEL/Buttons/2", "")); + let result = vec![ + Data::new(data[0] as f32, "WHEEL/Buttons/1", ""), + Data::new(data[1] as f32, "WHEEL/Buttons/2", ""), + ]; result } + From c058dcf9d4252e3473aa8e4576524a7e302fb716 Mon Sep 17 00:00:00 2001 From: Peyton-McKee Date: Thu, 11 Jan 2024 17:09:35 -0500 Subject: [PATCH 34/41] #20 Disable Clippy --- oxy/RustSynth.py | 7 +++++-- src/decode_data.rs | 7 ++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/oxy/RustSynth.py b/oxy/RustSynth.py index 76feecb..450cbc5 100644 --- a/oxy/RustSynth.py +++ b/oxy/RustSynth.py @@ -8,6 +8,7 @@ class RustSynth: A class to synthesize Rust from a given CANMsg spec. ''' + ignore_clippy: str = "#![allow(clippy)]" decode_data_import: str = "use super::data::{Data,FormatData as fd, ProcessData as pd}; \n" decode_return_type: str = "Vec::" @@ -16,8 +17,9 @@ class RustSynth: decode_mock: str = """ pub fn decode_mock(_data: &[u8]) -> Vec:: { - let mut result = Vec::::new(); - result.push(Data::new(0.0, "Mock", "")); + let result = vec![ + Data::new(0.0, "Mock", "") + ]; result } """ @@ -44,6 +46,7 @@ class RustSynth: def parse_messages(self, msgs: Messages) -> Result: result = Result("", "") + result.decode_data += self.ignore_clippy result.decode_data += self.decode_data_import result.decode_data += self.decode_mock diff --git a/src/decode_data.rs b/src/decode_data.rs index d38aa85..988f226 100644 --- a/src/decode_data.rs +++ b/src/decode_data.rs @@ -1,8 +1,9 @@ -use super::data::{Data,FormatData as fd, ProcessData as pd}; +#![allow(clippy)]use super::data::{Data,FormatData as fd, ProcessData as pd}; pub fn decode_mock(_data: &[u8]) -> Vec:: { - let mut result = Vec::::new(); - result.push(Data::new(0.0, "Mock", "")); + let result = vec![ + Data::new(0.0, "Mock", "") + ]; result } pub fn decode_accumulator_status(data: &[u8]) -> Vec:: { From 0e6e06e91c10e6392aabd677c86628ea4943242b Mon Sep 17 00:00:00 2001 From: Peyton-McKee Date: Thu, 11 Jan 2024 17:11:15 -0500 Subject: [PATCH 35/41] #20 Actually dont allow clippy --- oxy/RustSynth.py | 2 +- src/decode_data.rs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/oxy/RustSynth.py b/oxy/RustSynth.py index 450cbc5..6e40ac6 100644 --- a/oxy/RustSynth.py +++ b/oxy/RustSynth.py @@ -8,7 +8,7 @@ class RustSynth: A class to synthesize Rust from a given CANMsg spec. ''' - ignore_clippy: str = "#![allow(clippy)]" + ignore_clippy: str = "#![allow(clippy::all)]\n" decode_data_import: str = "use super::data::{Data,FormatData as fd, ProcessData as pd}; \n" decode_return_type: str = "Vec::" diff --git a/src/decode_data.rs b/src/decode_data.rs index 988f226..7d76103 100644 --- a/src/decode_data.rs +++ b/src/decode_data.rs @@ -1,4 +1,5 @@ -#![allow(clippy)]use super::data::{Data,FormatData as fd, ProcessData as pd}; +#![allow(clippy::all)] +use super::data::{Data,FormatData as fd, ProcessData as pd}; pub fn decode_mock(_data: &[u8]) -> Vec:: { let result = vec![ From 16fcc6aa4a44de60bc6df7306a8c58422273c986 Mon Sep 17 00:00:00 2001 From: Peyton-McKee Date: Thu, 11 Jan 2024 17:14:11 -0500 Subject: [PATCH 36/41] #20 Clippy --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 038f5f9..cf414e4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -66,7 +66,7 @@ fn read_can(mut publisher: Box) { let data = msg.data(); let message = Message::new(msg.id(), data.to_vec()); let decoded_data = message.decode(); - for (_i, data) in decoded_data.iter().enumerate() { + for data in decoded_data.iter() { publisher.publish(data) } } From 7a0864273f231cee312e26f4a31eb5c9bd9ea2fa Mon Sep 17 00:00:00 2001 From: Peyton-McKee Date: Thu, 11 Jan 2024 17:23:03 -0500 Subject: [PATCH 37/41] #20 Delete Unused Files --- src/decode_files.rs | 87 ----------------- src/decode_statuses.rs | 209 ----------------------------------------- src/telem_main.rs | 98 ------------------- src/thread.rs | 9 -- 4 files changed, 403 deletions(-) delete mode 100644 src/decode_files.rs delete mode 100644 src/decode_statuses.rs delete mode 100644 src/telem_main.rs delete mode 100644 src/thread.rs diff --git a/src/decode_files.rs b/src/decode_files.rs deleted file mode 100644 index 8b1f0d0..0000000 --- a/src/decode_files.rs +++ /dev/null @@ -1,87 +0,0 @@ -// This file specifies methods to decode message fields (timestamp, id, data bytes) from -// a line in a log file. - -use chrono::prelude::*; -use std::convert::TryInto; - -use message::Message; - -mod message; - -enum LogFormat { - Textual1, - Textual1Legacy, - Textual2, - Binary, -} - -fn process_line(line: &str, format: LogFormat) -> Message { - // Processes a line of textual data according to a given format. - - match format { - LogFormat::Textual1 => _process_textual1(line), - LogFormat::Textual1Legacy => _process_textual1_legacy(line), - LogFormat::Textual2 => _process_textual2(line), - LogFormat::Binary => _process_binary(line), - } -} - -fn _process_textual1(line: &str) -> Message { - // Processes a line of data in the format "Timestamp id length [data1,data2,...]" - // Example line format: 1679511802367 514 8 [54,0,10,0,0,0,0,0] - - let fields: Vec<&str> = line.trim().split(' ').collect(); - let timestamp = NaiveDateTime::from_timestamp(fields[0].parse::().unwrap() / 1000, 0); - let id = fields[1].parse::().unwrap(); - let length = fields[2].parse::().unwrap(); - let data: Vec = fields[3][1..fields[3].len() - 1] - .split(',') - .map(|x| x.parse().unwrap()) - .collect(); - // remove commas and brackets at start and end - let int_data: Vec = data - .chunks_exact(2) - .map(|x| i16::from_le_bytes(x.try_into().unwrap())) - .collect(); - Message::new(timestamp, id, int_data) -} - -fn _process_textual1_legacy(line: &str) -> Message { - // Processes a line of data in the format: Timestamp id length [data1,data2,...] - // Example line format: 2021-01-01T00:00:00.003Z 514 8 [54,0,10,0,0,0,0,0] - - let fields: Vec<&str> = line.trim().split(' ').collect(); - let timestamp = NaiveDateTime::parse_from_str(fields[0], "%Y-%m-%dT%H:%M:%S.%fZ") - .unwrap() - .into(); - let id = fields[1].parse::().unwrap(); - let length = fields[2].parse::().unwrap(); - let data: Vec = fields[3][1..fields[3].len() - 1] - .split(',') - .map(|x| x.parse().unwrap()) - .collect(); - let int_data: Vec = data - .chunks_exact(2) - .map(|x| i16::from_le_bytes(x.try_into().unwrap())) - .collect(); - Message::new(timestamp, id, int_data) -} - -fn _process_textual2(line: &str) -> Message { - // Processes a line of data in the format "Timestamp id length data1 data2 ..." - // Example line format: 1659901910.121 514 8 54 0 10 0 0 0 0 0 - - let fields: Vec<&str> = line.trim().split(' ').collect(); - let timestamp = NaiveDateTime::from_timestamp(fields[0].parse::().unwrap(), 0); - let id = fields[1].parse::().unwrap(); - let length = fields[2].parse::().unwrap(); - let data: Vec = fields[3..3 + length] - .iter() - .map(|x| x.parse().unwrap()) - .collect(); - Message::new(timestamp, id, data) -} - -fn _process_binary(line: &str) -> Message { - panic!("Binary files not currently supported.") -} diff --git a/src/decode_statuses.rs b/src/decode_statuses.rs deleted file mode 100644 index 9deb5da..0000000 --- a/src/decode_statuses.rs +++ /dev/null @@ -1,209 +0,0 @@ -use std::collections::HashMap; - -use crate::data::Data; - -// Mapping from data IDs to the status bits they encode -// Each data ID contains a hash map with keys that are bit names and values that are the indexes -const STATUS_MAP: HashMap> = [ - (6, HashMap::new()), // Failsafe Statuses - (7, HashMap::new()), // DTC Status 1 - (8, HashMap::new()), // DTC Status 2 - (9, HashMap::new()), // Current Limits Status - (12, HashMap::new()), // MPE State - ( - // VSM State - 64, - hashmap![ - "VSM Start State" => 0, - "Pre-charge Init State" => 1, - "Pre-charge Active State" => 2, - "Pre-charge Complete State" => 3, - "VSM Wait State" => 4, - "VSM Ready State" => 5, - "Motor Running State" => 6, - "Blink Fault Code State" => 7 - ], - ), - ( - // Inverter State - 65, - hashmap![ - "Power on State" => 0, - "Stop State" => 1, - "Open Loop State" => 2, - "Closed Loop State" => 3, - "Wait State" => 4, - "Idle Run State" => 8, - "Idle Stop State" => 9 - ], - ), - ( - // Relay State - 66, - hashmap![ - "Relay 1 Status" => 0, - "Relay 2 Status" => 1, - "Relay 3 Status" => 2, - "Relay 4 Status" => 3, - "Relay 5 Status" => 4, - "Relay 6 Status" => 5, - ], - ), - ( - // Inverter Run Mode - 67, - hashmap!["Inverter Run Mode" => 0], - ), - ( - // Inverter Command Mode - 69, - hashmap!["Inverter Command Mode" => 0], - ), - ( - // Inverter Enable State - 70, - hashmap!["Inverter Enable State" => 0], - ), - ( - // Inverter Enable Lockout - 71, - hashmap!["Inverter Enable Lockout" => 0], - ), - ( - // Direction Command - 72, - hashmap!["Direction Command" => 0], - ), - ( - // BMS Active - 73, - hashmap!["BMS Active" => 0], - ), - ( - // BMS Limiting Torque - 74, - hashmap!["BMS Limiting Torque" => 0], - ), - ( - // POST Fault Lo - 75, - hashmap![ - "Hardware Gate/Desaturation Fault" => 0, - "HW Over-current Fault" => 1, - "Accelerator Shorted" => 2, - "Accelerator Open" => 3, - "Current Sensor Low" => 4, - "Current Sensor High" => 5, - "Module Temperature Low" => 6, - "Module Temperature High" => 7, - "Control PCB Temperature Low" => 8, - "Control PCB Temperature High" => 9, - "Gate Drive PCB Temperature Low" => 10, - "Gate Drive PCB Temperature High" => 11, - "5V Sense Voltage Low" => 12, - "5V Sense Voltage High" => 13, - "12V Sense Voltage Low" => 14, - "12V Sense Voltage High" => 15 - ], - ), - ( - 76, - hashmap![ // POST Fault Hi - "2.5V Sense Voltage Low" => 0, - "2.5V Sense Voltage High" => 1, - "1.5V Sense Voltage Low" => 2, - "1.5V Sense Voltage High" => 3, - "DC Bus Voltage High" => 4, - "DC Bus Voltage Low" => 5, - "Pre-charge Timeout" => 6, - "Pre-charge Voltage Failure" => 7, - "Brake Shorted" => 14, - "Brake Open" => 15 - ], - ), - ( - 77, - hashmap![ // Run Fault Lo - "Motor Over-speed Fault" => 0, - "Over-current Fault" => 1, - "Over-voltage Fault" => 2, - "Inverter Over-temperature Fault" => 3, - "Accelerator Input Shorted Fault" => 4, - "Accelerator Input Open Fault" => 5, - "Direction Command Fault" => 6, - "Inverter Response Time-out Fault" => 7, - "Hardware Gate/Desaturation Fault" => 8, - "Hardware Over-current Fault" => 9, - "Under-voltage Fault" => 10, - "CAN Command Message Lost Fault" => 11, - "Motor Over-temperature Fault" => 12 - ], - ), - ( - 78, - hashmap![ // Run Fault Hi - "Brake Input Shorted Fault" => 0, - "Brake Input Open Fault" => 1, - "Module A Over-temperature Fault" => 2, - "Module B Over temperature Fault" => 3, - "Module C Over-temperature Fault" => 4, - "PCB Over-temperature Fault" => 5, - "Gate Drive Board 1 Over-temperature Fault" => 6, - "Gate Drive Board 2 Over-temperature Fault" => 7, - "Gate Drive Board 3 Over-temperature Fault" => 8, - "Current Sensor Fault" => 9, - "Hardware Over-Voltage Fault" => 11, - "Resolver Not Connected" => 14, - "Inverter Discharge Active" => 15 - ], - ), - ( - // Direction Command - 84, - hashmap!["Direction Command" => 0], - ), - ( - // Inverter Enable - 85, - hashmap!["Inverter Enable" => 0], - ), - ( - // Inverter Discharge - 86, - hashmap!["Inverter Discharge" => 0], - ), - ( - // Speed Mode Enable - 87, - hashmap!["Speed Mode Enable" => 0], - ), - (// Cell Voltage Info -), -]; - -fn get_status(data: &Data, name: &str) -> i32 { - if !STATUS_MAP.contains_key(&data.id) { - panic!("Data ID has no associated status mapping"); - } - let bitmap = &STATUS_MAP[&data.id]; - - if !bitmap.contains_key(name) { - panic!("Status name could not be found in the given data point"); - } - let index = bitmap[name]; - - return (data.value >> index) & 1; -} - -fn get_statuses(data: &Data) -> HashMap<&str, i32> { - if !STATUS_MAP.contains_key(&data.id) { - panic!("Data ID has no associated status mapping"); - } - let bitmap = &STATUS_MAP[&data.id]; - - // Convert each dict value to the bit value at the index - return bitmap - .iter() - .map(|(name, index)| (*name, (data.value >> index) & 1)) - .collect(); -} diff --git a/src/telem_main.rs b/src/telem_main.rs deleted file mode 100644 index 3d3de3d..0000000 --- a/src/telem_main.rs +++ /dev/null @@ -1,98 +0,0 @@ -use std::fs::File; -use std::io::BufRead; -use std::io::BufReader; -use std::io::Write; -use rayon::prelude::*; -use chrono::prelude::*; - -use master_mapping::DATA_IDS; -use master_mapping::MESSAGE_IDS; - -mod master_mapping; - -const DEFAULT_LOGS_DIRECTORY: &str = "./logs/"; -const DEFAULT_OUTPUT_PATH: &str = "./output/"; -const PROCESSORS: u8 = 8; -const PROCESS_CHUNK_SIZE: u32 = 85000; //Processes data in chunks, specified by this variable - -fn get_line_count(filepaths: &[String]) -> usize { - /* - * Gets the total line count of all the files in the list. - - There is no native way to get line counts of files without looping, so - this function gets the total size and estimates the line count based - on a subset of N lines. - */ - if filepaths.is_empty() { - return 0; - } - - const n: u8 = 20; - let tested_lines: u8 = 0; - let tested_size: u8 = 0; - let total_size: u64 = filepaths.iter().map(|filepath| fs::metadata(filepath).unwrap().len()).sum(); - - for filepath in filepaths { - let file = File::open(filepath).unwrap(); - let reader = BufReader::new(file); - - for line in reader.lines() { - let line = line.unwrap(); - total_size += line.len(); - tested_lines += 1; - - if tested_lines >= n { - return (total_size / tested_lines) * (total_size / tested_lines); - } - } - } - return total_size / (tested_size / tested_lines) -} - -fn find_time(start: &[&str], finish: &[&str]) { - /* - * Prints the difference between the two times provided - Both inputs are lists of strings: - - minutes being the zeroth index of the list - - seconds being the first index of the list - - microseconds being the second index of the list - */ - - let start_minutes = start[0].parse::().unwrap(); - let start_seconds = start[1].parse::().unwrap(); - let start_microseconds = start[2].parse::().unwrap(); - - let finish_minutes = finish[0].parse::().unwrap(); - let finish_seconds = finish[1].parse::().unwrap(); - let finish_microseconds = finish[2].parse::().unwrap(); - - let mut minutes = finish_minutes - start_minutes; - let mut seconds = finish_seconds - start_seconds; - let mut microseconds = finish_microseconds - start_microseconds; - - if microseconds < 0 { - seconds -= 1; - microseconds += 1_000_000; - } - - if seconds < 0 { - minutes -= 1; - seconds += 60; - } - - println!("Time to process (Minutes:Seconds.Microseconds): {}:{}.{:06}", minutes, seconds, microseconds); -} - -fn process_lines(lines: &mut Vec, writer: &mut csv::Writer<&mut dyn Write>) { - /* - * Processes a chunk of lines and writes the results to the CSV. - */ - let out: Vec> = lines.par_iter().map(|line| thread(line)).collect(); - lines.clear(); - for data in out { - for sub_data in data { - let str_time = sub_data.timestamp.format("%Y-%m-%dT%H:%M:%S.%fZ").to_string(); - writer.write_record(&[&str_time, &sub_data.id.to_string(), &DATA_IDS[sub_data.id]["name"], &sub_data.value.to_string()]).unwrap(); - } - } -} diff --git a/src/thread.rs b/src/thread.rs deleted file mode 100644 index c2e2362..0000000 --- a/src/thread.rs +++ /dev/null @@ -1,9 +0,0 @@ -use decode_files::{LogFormat, processLine}; -use message::Message; - -const FORMAT: LogFormat = LogFormat::Textual1; - -fn thread(line: &str) -> Result, MessageFormatException> { - let message = processLine(line, FORMAT)?; - message.decode() -} \ No newline at end of file From 4586ead6d9d136dd11a54c25bd90d80ab7bca277 Mon Sep 17 00:00:00 2001 From: Peyton-McKee Date: Thu, 11 Jan 2024 17:44:47 -0500 Subject: [PATCH 38/41] #20 Seperate Yaml Files --- oxy/RustSynth.py | 4 +- oxy/YAMLParser.py | 2 +- oxy/typedpoc.py | 10 ++++- oxy/{mapping.yaml => yaml/bms.yaml} | 70 ----------------------------- oxy/yaml/mpu.yaml | 51 +++++++++++++++++++++ oxy/yaml/wheel.yaml | 14 ++++++ 6 files changed, 77 insertions(+), 74 deletions(-) rename oxy/{mapping.yaml => yaml/bms.yaml} (79%) create mode 100644 oxy/yaml/mpu.yaml create mode 100644 oxy/yaml/wheel.yaml diff --git a/oxy/RustSynth.py b/oxy/RustSynth.py index 6e40ac6..2d3c491 100644 --- a/oxy/RustSynth.py +++ b/oxy/RustSynth.py @@ -44,7 +44,7 @@ class RustSynth: } """ - def parse_messages(self, msgs: Messages) -> Result: + def parse_messages(self, msgs: [CANMsg]) -> Result: result = Result("", "") result.decode_data += self.ignore_clippy result.decode_data += self.decode_data_import @@ -54,7 +54,7 @@ def parse_messages(self, msgs: Messages) -> Result: result.master_mapping += self.message_info result.master_mapping += self.master_mapping_signature - for msg in msgs.msgs: + for msg in msgs: result.decode_data += self.synthesize(msg) + "\n" result.master_mapping += self.map_msg_to_decoder(msg) diff --git a/oxy/YAMLParser.py b/oxy/YAMLParser.py index af54cf4..8805bb4 100644 --- a/oxy/YAMLParser.py +++ b/oxy/YAMLParser.py @@ -21,5 +21,5 @@ def __init__(self): self.yaml.register_class(decoding) - def parse(self, file: Any) -> CANMsg: + def parse(self, file: Any) -> Messages: return self.yaml.load(file) diff --git a/oxy/typedpoc.py b/oxy/typedpoc.py index a7595e7..3aa2ba8 100644 --- a/oxy/typedpoc.py +++ b/oxy/typedpoc.py @@ -4,7 +4,15 @@ decode_data = open("../src/decode_data.rs", "w") master_mapping = open("../src/master_mapping.rs", "w") -result = RustSynth().parse_messages(YAMLParser().parse(open("mapping.yaml", "r"))) +bms_messages = YAMLParser().parse(open("yaml/bms.yaml", "r")) +mpu_messages = YAMLParser().parse(open("yaml/mpu.yaml", "r")) +wheel_messages = YAMLParser().parse(open("yaml/wheel.yaml", "r")) + + +bms_messages.msgs.extend(mpu_messages.msgs) +bms_messages.msgs.extend(wheel_messages.msgs) + +result = RustSynth().parse_messages(bms_messages.msgs) decode_data.write(result.decode_data) decode_data.close() diff --git a/oxy/mapping.yaml b/oxy/yaml/bms.yaml similarity index 79% rename from oxy/mapping.yaml rename to oxy/yaml/bms.yaml index 9edb3d6..87ced71 100644 --- a/oxy/mapping.yaml +++ b/oxy/yaml/bms.yaml @@ -241,73 +241,3 @@ msgs: decodings: - !TwosComplement bits: 8 - -# MPU BROADCAST -- !CANMsg - id: "0x500" - desc: "NERduino Acceleromter" - fields: - - !CANField - name: "MPU/Accel/X" - unit: "g" - size: 2 - decodings: - - !BigEndian - bits: 8 - format: "acceleration" - - !CANField - name: "MPU/Accel/Y" - unit: "g" - size: 2 - decodings: - - !BigEndian - bits: 8 - format: "acceleration" - - !CANField - name: "MPU/Accel/Z" - unit: "g" - size: 2 - decodings: - - !BigEndian - bits: 8 - format: "acceleration" - -- !CANMsg - id: "0x501" - desc: "MPU Status" - fields: - - !CANField - name: "MPU/State/Mode" - unit: "" - size: 1 - - !CANField - name: "MPU/State/Torque_Limit_Percentage" - unit: "" - size: 1 - - !CANField - name: "MPU/State/Regen_Strength" - unit: "" - size: 1 - - !CANField - name: "MPU/State/Traction_Control" - unit: "" - size: 1 - - -#STEERINGWHEEL -- !CANMsg - id: "0x680" - desc: "Wheel State" - fields: - - !CANField - name: "WHEEL/Buttons/1" - unit: "" - size: 1 - - !CANField - name: "WHEEL/Buttons/2" - unit: "" - size: 1 - - - - diff --git a/oxy/yaml/mpu.yaml b/oxy/yaml/mpu.yaml new file mode 100644 index 0000000..e3ff76e --- /dev/null +++ b/oxy/yaml/mpu.yaml @@ -0,0 +1,51 @@ +!Messages +msgs: +- !CANMsg + id: "0x500" + desc: "NERduino Acceleromter" + fields: + - !CANField + name: "MPU/Accel/X" + unit: "g" + size: 2 + decodings: + - !BigEndian + bits: 8 + format: "acceleration" + - !CANField + name: "MPU/Accel/Y" + unit: "g" + size: 2 + decodings: + - !BigEndian + bits: 8 + format: "acceleration" + - !CANField + name: "MPU/Accel/Z" + unit: "g" + size: 2 + decodings: + - !BigEndian + bits: 8 + format: "acceleration" + +- !CANMsg + id: "0x501" + desc: "MPU Status" + fields: + - !CANField + name: "MPU/State/Mode" + unit: "" + size: 1 + - !CANField + name: "MPU/State/Torque_Limit_Percentage" + unit: "" + size: 1 + - !CANField + name: "MPU/State/Regen_Strength" + unit: "" + size: 1 + - !CANField + name: "MPU/State/Traction_Control" + unit: "" + size: 1 \ No newline at end of file diff --git a/oxy/yaml/wheel.yaml b/oxy/yaml/wheel.yaml new file mode 100644 index 0000000..3f92646 --- /dev/null +++ b/oxy/yaml/wheel.yaml @@ -0,0 +1,14 @@ +!Messages +msgs: +- !CANMsg + id: "0x680" + desc: "Wheel State" + fields: + - !CANField + name: "WHEEL/Buttons/1" + unit: "" + size: 1 + - !CANField + name: "WHEEL/Buttons/2" + unit: "" + size: 1 \ No newline at end of file From dc5b2d541895f99b4188623d1233ebde9940115e Mon Sep 17 00:00:00 2001 From: Peyton-McKee Date: Sat, 13 Jan 2024 14:22:51 -0500 Subject: [PATCH 39/41] #20 Add Documentation, remove unused dependencies --- Cargo.lock | 357 +----------- Cargo.toml | 2 - oxy/RustSynth.py | 31 +- oxy/YAMLParser.py | 1 - oxy/{yaml => can-messages}/bms.yaml | 0 oxy/{yaml => can-messages}/mpu.yaml | 2 +- oxy/{yaml => can-messages}/wheel.yaml | 0 oxy/structs/Format.py | 2 +- oxy/structs/Messages.py | 2 +- oxy/structs/Result.py | 7 +- oxy/typedpoc.py | 6 +- python/__init__.py | 0 python/__main__.py | 148 ----- python/data.py | 123 ----- python/decode_data.py | 338 ------------ python/decode_files.py | 77 --- python/decode_statuses.py | 188 ------- python/master_mapping.py | 763 -------------------------- python/message.py | 49 -- python/thread.py | 9 - src/data.rs | 56 +- src/mqtt.rs | 2 +- 22 files changed, 54 insertions(+), 2109 deletions(-) rename oxy/{yaml => can-messages}/bms.yaml (100%) rename oxy/{yaml => can-messages}/mpu.yaml (96%) rename oxy/{yaml => can-messages}/wheel.yaml (100%) delete mode 100644 python/__init__.py delete mode 100644 python/__main__.py delete mode 100644 python/data.py delete mode 100644 python/decode_data.py delete mode 100644 python/decode_files.py delete mode 100644 python/decode_statuses.py delete mode 100644 python/master_mapping.py delete mode 100644 python/message.py delete mode 100644 python/thread.py diff --git a/Cargo.lock b/Cargo.lock index 2d1a1ea..1d655d7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,30 +2,6 @@ # It is not intended for manual editing. version = 3 -[[package]] -name = "android-tzdata" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" - -[[package]] -name = "android_system_properties" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" -dependencies = [ - "libc", -] - -[[package]] -name = "approx" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cab112f0a86d568ea0e627cc1d6be74a1e9cd55214684db5561995f6dad897c6" -dependencies = [ - "num-traits", -] - [[package]] name = "async-channel" version = "1.9.0" @@ -49,24 +25,10 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8dead7461c1127cf637931a1e50934eb6eee8bff2f74433ac7909e9afcee04a3" -[[package]] -name = "bumpalo" -version = "3.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" - -[[package]] -name = "bytemuck" -version = "1.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6" - [[package]] name = "calypso" version = "0.1.0" dependencies = [ - "chrono", - "nalgebra", "paho-mqtt", "socketcan", ] @@ -86,20 +48,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "chrono" -version = "0.4.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" -dependencies = [ - "android-tzdata", - "iana-time-zone", - "js-sys", - "num-traits", - "wasm-bindgen", - "windows-targets", -] - [[package]] name = "cmake" version = "0.1.50" @@ -118,12 +66,6 @@ dependencies = [ "crossbeam-utils", ] -[[package]] -name = "core-foundation-sys" -version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" - [[package]] name = "crossbeam-channel" version = "0.5.8" @@ -205,7 +147,7 @@ checksum = "53b153fd91e4b0147f4aced87be237c98248656bb01050b96bf3ee89220a8ddb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn", ] [[package]] @@ -250,44 +192,12 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6a22814455d41612f41161581c2883c0c6a1c41852729b17d5ed88f01e153aa" -[[package]] -name = "iana-time-zone" -version = "0.1.58" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8326b86b6cff230b97d0d312a6c40a60726df3332e721f72a1b035f451663b20" -dependencies = [ - "android_system_properties", - "core-foundation-sys", - "iana-time-zone-haiku", - "js-sys", - "wasm-bindgen", - "windows-core", -] - -[[package]] -name = "iana-time-zone-haiku" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" -dependencies = [ - "cc", -] - [[package]] name = "itertools" version = "0.4.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4a9b56eb56058f43dc66e58f40a214b2ccbc9f3df51861b63d51dec7b65bc3f" -[[package]] -name = "js-sys" -version = "0.3.66" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cee9c64da59eae3b50095c18d3e74f8b73c0b86d2792824ff01bbce68ba229ca" -dependencies = [ - "wasm-bindgen", -] - [[package]] name = "libc" version = "0.2.150" @@ -300,49 +210,12 @@ version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" -[[package]] -name = "matrixmultiply" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7574c1cf36da4798ab73da5b215bbf444f50718207754cb522201d78d1cd0ff2" -dependencies = [ - "autocfg", - "rawpointer", -] - [[package]] name = "memchr" version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" -[[package]] -name = "nalgebra" -version = "0.32.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "307ed9b18cc2423f29e83f84fd23a8e73628727990181f18641a8b5dc2ab1caa" -dependencies = [ - "approx", - "matrixmultiply", - "nalgebra-macros", - "num-complex", - "num-rational", - "num-traits", - "simba", - "typenum", -] - -[[package]] -name = "nalgebra-macros" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91761aed67d03ad966ef783ae962ef9bbaca728d2dd7ceb7939ec110fffad998" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "nix" version = "0.5.1" @@ -353,51 +226,6 @@ dependencies = [ "libc", ] -[[package]] -name = "num-complex" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ba157ca0885411de85d6ca030ba7e2a83a28636056c7c699b07c8b6f7383214" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-integer" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" -dependencies = [ - "autocfg", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" -dependencies = [ - "autocfg", -] - -[[package]] -name = "once_cell" -version = "1.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" - [[package]] name = "openssl-sys" version = "0.9.96" @@ -436,12 +264,6 @@ dependencies = [ "openssl-sys", ] -[[package]] -name = "paste" -version = "1.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" - [[package]] name = "pin-project-lite" version = "0.2.13" @@ -478,34 +300,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "rawpointer" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" - -[[package]] -name = "safe_arch" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f398075ce1e6a179b46f51bd88d0598b92b00d3551f1a2d4ac49e771b56ac354" -dependencies = [ - "bytemuck", -] - -[[package]] -name = "simba" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "061507c94fc6ab4ba1c9a0305018408e312e17c041eb63bef8aa726fa33aceae" -dependencies = [ - "approx", - "num-complex", - "num-traits", - "paste", - "wide", -] - [[package]] name = "slab" version = "0.4.9" @@ -528,17 +322,6 @@ dependencies = [ "try_from", ] -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - [[package]] name = "syn" version = "2.0.39" @@ -567,7 +350,7 @@ checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn", ] [[package]] @@ -576,12 +359,6 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "923a7ee3e97dbfe8685261beb4511cc9620a1252405d02693d43169729570111" -[[package]] -name = "typenum" -version = "1.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" - [[package]] name = "unicode-ident" version = "1.0.12" @@ -593,133 +370,3 @@ name = "vcpkg" version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" - -[[package]] -name = "wasm-bindgen" -version = "0.2.89" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ed0d4f68a3015cc185aff4db9506a015f4b96f95303897bfa23f846db54064e" -dependencies = [ - "cfg-if", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.89" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b56f625e64f3a1084ded111c4d5f477df9f8c92df113852fa5a374dbda78826" -dependencies = [ - "bumpalo", - "log", - "once_cell", - "proc-macro2", - "quote", - "syn 2.0.39", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.89" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0162dbf37223cd2afce98f3d0785506dcb8d266223983e4b5b525859e6e182b2" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.89" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.39", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.89" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ab9b36309365056cd639da3134bf87fa8f3d86008abf99e612384a6eecd459f" - -[[package]] -name = "wide" -version = "0.7.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c68938b57b33da363195412cfc5fc37c9ed49aa9cfe2156fde64b8d2c9498242" -dependencies = [ - "bytemuck", - "safe_arch", -] - -[[package]] -name = "windows-core" -version = "0.51.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" -dependencies = [ - "windows-targets", -] - -[[package]] -name = "windows-targets" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" -dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" - -[[package]] -name = "windows_i686_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" - -[[package]] -name = "windows_i686_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" diff --git a/Cargo.toml b/Cargo.toml index 15c0807..4aa1040 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,5 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -chrono = "0.4.31" socketcan = "1.7.0" paho-mqtt = "0.12.3" -nalgebra = "0.32.3" diff --git a/oxy/RustSynth.py b/oxy/RustSynth.py index 2d3c491..6b93ad5 100644 --- a/oxy/RustSynth.py +++ b/oxy/RustSynth.py @@ -8,12 +8,12 @@ class RustSynth: A class to synthesize Rust from a given CANMsg spec. ''' - ignore_clippy: str = "#![allow(clippy::all)]\n" - decode_data_import: str = "use super::data::{Data,FormatData as fd, ProcessData as pd}; \n" + ignore_clippy: str = "#![allow(clippy::all)]\n" # Ignoring clippy for decode_data because it's autogenerated and has some unnecessary type casting to ensure correct types + decode_data_import: str = "use super::data::{Data,FormatData as fd, ProcessData as pd}; \n" # Importing the Data struct and the FormatData and ProcessData traits - decode_return_type: str = "Vec::" - decode_return_value: str = f" let result = vec![" - decode_close: str = " ]; \n result\n}\n" + decode_return_type: str = "Vec::" # The return type of any decode function + decode_return_value: str = f" let result = vec![" # Initializing the result vector + decode_close: str = " ]; \n result\n}\n" # Returning the result vector and closing the function decode_mock: str = """ pub fn decode_mock(_data: &[u8]) -> Vec:: { @@ -22,13 +22,13 @@ class RustSynth: ]; result } -""" +""" # A mock decode function that is used for messages that don't have a decode function - master_mapping_import: str = "use super::decode_data::*; \nuse super::data::Data; \n" + master_mapping_import: str = "use super::decode_data::*; \nuse super::data::Data; \n" # Importing all the functions in decode_data.rs file and the Data struct - master_mapping_signature: str = "pub fn get_message_info(id: &u32) -> MessageInfo { \n match id {" + master_mapping_signature: str = "pub fn get_message_info(id: &u32) -> MessageInfo { \n match id {" # The signature of the master_mapping function - master_mapping_closing: str = " _ => MessageInfo::new(decode_mock), \n }\n}" + master_mapping_closing: str = " _ => MessageInfo::new(decode_mock), \n }\n}" # The closing of the master_mapping function and the default case for the match statement that returns the mock decode function message_info = """ pub struct MessageInfo { @@ -42,8 +42,9 @@ class RustSynth: } } } -""" +""" # The MessageInfo struct that is used to store the decode function for a given message + # The main function of the RustSynth class. Takes a list of CANMsgs and returns a Result object that contains the synthesized Rust code for the decode_data.rs and master_mapping.rs files def parse_messages(self, msgs: [CANMsg]) -> Result: result = Result("", "") result.decode_data += self.ignore_clippy @@ -61,26 +62,33 @@ def parse_messages(self, msgs: [CANMsg]) -> Result: result.master_mapping += self.master_mapping_closing return result + # Helper function that maps a given CANMsg to its decode function def map_msg_to_decoder(self, msg: CANMsg) -> str: return f" {msg.id} => MessageInfo::new({self.function_name(msg.desc)}),\n" + # Helper function that synthesizes the decode function for a given CANMsg def synthesize(self, msg: CANMsg) -> str: signature: str = self.signature(msg.desc) generated_lines: list[str] = [] + # Generate a line for each field in the message for field in msg.fields: generated_lines.append(self.finalize_line(field.name, field.unit, f"{self.format_data(field, self.parse_decoders(field))}")) total_list: list[str] = [signature, self.decode_return_value] + generated_lines + [self.decode_close] return "\n".join(total_list) - + + # Helper function that generates the name of a decode function for a given CANMsg based off the can message description def function_name(self, desc: str) -> str: return f"decode_{desc.replace(' ', '_').lower()}" + # Helper function that generates the signature of a decode function for a given CANMsg based off the can message description def signature(self, desc: str) -> str: return f"pub fn {self.function_name(desc)}(data: &[u8]) -> {self.decode_return_type} {{" + # Helper function that generates a line the data struct for a given CANField value def finalize_line(self, topic: str, unit: str, val: str) -> str: return f" Data::new({val}, \"{topic}\", \"{unit}\")," + # Helper function that parses the decoders for a given CANField by applying the decoders to the data and casting the result to the final type of the CANField. def parse_decoders(self, field: CANField) -> str: if isinstance(field.decodings, type(None)): return f"data[{field.index}] as {field.final_type}" @@ -94,6 +102,7 @@ def parse_decoders(self, field: CANField) -> str: base = f"pd::{decoder.repr}({base} as {decoder.entry_type}, {decoder.bits})" return f"{base} as {field.final_type}" + # Helper function that formats the data for a given CANField based off the format of the CANField if it exists, returns the decoded data otherwise def format_data(self, field:CANField, decoded_data: str) -> str: cf = decoded_data if field.format: diff --git a/oxy/YAMLParser.py b/oxy/YAMLParser.py index 8805bb4..c6dae1f 100644 --- a/oxy/YAMLParser.py +++ b/oxy/YAMLParser.py @@ -1,5 +1,4 @@ from ruamel.yaml import YAML, Any - from structs.CANMsg import CANMsg from structs.CANField import CANField from structs.Format import Format diff --git a/oxy/yaml/bms.yaml b/oxy/can-messages/bms.yaml similarity index 100% rename from oxy/yaml/bms.yaml rename to oxy/can-messages/bms.yaml diff --git a/oxy/yaml/mpu.yaml b/oxy/can-messages/mpu.yaml similarity index 96% rename from oxy/yaml/mpu.yaml rename to oxy/can-messages/mpu.yaml index e3ff76e..f017731 100644 --- a/oxy/yaml/mpu.yaml +++ b/oxy/can-messages/mpu.yaml @@ -2,7 +2,7 @@ msgs: - !CANMsg id: "0x500" - desc: "NERduino Acceleromter" + desc: "MPU Acceleromter" fields: - !CANField name: "MPU/Accel/X" diff --git a/oxy/yaml/wheel.yaml b/oxy/can-messages/wheel.yaml similarity index 100% rename from oxy/yaml/wheel.yaml rename to oxy/can-messages/wheel.yaml diff --git a/oxy/structs/Format.py b/oxy/structs/Format.py index 6e3bdcf..bb923dd 100644 --- a/oxy/structs/Format.py +++ b/oxy/structs/Format.py @@ -53,4 +53,4 @@ class Flux(Format): @dataclass class CellVoltage(Format): - repr: str = "cell_voltage" \ No newline at end of file + repr: str = "cell_voltage" diff --git a/oxy/structs/Messages.py b/oxy/structs/Messages.py index a9cb99f..eeac46e 100644 --- a/oxy/structs/Messages.py +++ b/oxy/structs/Messages.py @@ -6,4 +6,4 @@ class Messages: ''' Represents a list of CAN messages. Has a list of CANMsgs. ''' - msgs: list[CANMsg] \ No newline at end of file + msgs: list[CANMsg] diff --git a/oxy/structs/Result.py b/oxy/structs/Result.py index 662cd48..9b1d317 100644 --- a/oxy/structs/Result.py +++ b/oxy/structs/Result.py @@ -1,8 +1,13 @@ class Result: + """ + This class is used to store the results of the RustSynth.py script. + decode_data is the synthesized Rust code for the decode_data.rs file. + master_mapping is the synthesized Rust code for the master_mapping.rs file. + """ decode_data: str master_mapping: str def __init__(self, decode_data: str, master_mapping: str): self.decode_data = decode_data - self.master_mapping = master_mapping \ No newline at end of file + self.master_mapping = master_mapping diff --git a/oxy/typedpoc.py b/oxy/typedpoc.py index 3aa2ba8..052ab37 100644 --- a/oxy/typedpoc.py +++ b/oxy/typedpoc.py @@ -4,9 +4,9 @@ decode_data = open("../src/decode_data.rs", "w") master_mapping = open("../src/master_mapping.rs", "w") -bms_messages = YAMLParser().parse(open("yaml/bms.yaml", "r")) -mpu_messages = YAMLParser().parse(open("yaml/mpu.yaml", "r")) -wheel_messages = YAMLParser().parse(open("yaml/wheel.yaml", "r")) +bms_messages = YAMLParser().parse(open("can-messages/bms.yaml", "r")) +mpu_messages = YAMLParser().parse(open("can-messages/mpu.yaml", "r")) +wheel_messages = YAMLParser().parse(open("can-messages/wheel.yaml", "r")) bms_messages.msgs.extend(mpu_messages.msgs) diff --git a/python/__init__.py b/python/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/python/__main__.py b/python/__main__.py deleted file mode 100644 index d65d8e4..0000000 --- a/python/__main__.py +++ /dev/null @@ -1,148 +0,0 @@ -import multiprocessing -from datetime import datetime - -from os import listdir, path -import csv -import sys -from typing import List - -from python.master_mapping import DATA_IDS -from python.thread import thread - -DEFAULT_LOGS_DIRECTORY = "./logs/" -DEFAULT_OUTPUT_PATH = "./output.csv" -PROCESSORS = 8 -PROCESS_CHUNK_SIZE = 85000 # Processes data in chunks, specified by this variable - - -def getLineCount(filepaths: List[str]) -> int: - """ - Gets the total line count of all the files in the list. - - There is no native way to get line counts of files without looping, so - this function gets the total size and estimates the line count based - on a subset of N lines. - """ - if len(filepaths) == 0: - return 0 - - N = 20 - tested_lines = 0 - tested_size = 0 - total_size = sum(path.getsize(fp) for fp in filepaths) - - for fp in filepaths: - with open(fp) as file: - for line in file: - tested_lines += 1 - tested_size += len(line) - if tested_lines >= N: - return int(total_size / (tested_size / tested_lines)) - return int(total_size / (tested_size / tested_lines)) - -def find_time(start, finish): - """ - Prints the difference between the two times provided - Both inputs are lists of strings: - - minutes being the zeroth index of the list - - seconds being the first index of the list - - microseconds being the second index of the list - """ - - minutes = int(finish[0]) - int(start[0]) - seconds = int(finish[1]) - int(start[1]) - microseconds = int(finish[2]) - int(start[2]) - - if microseconds < 0: - seconds -= 1 - microseconds += 1000000 - - if seconds < 0: - minutes -= 1 - seconds += 60 - - print("Time to process (Minutes:Seconds.Microseconds): " + str(minutes) + ":" + str(seconds) + "." + str( - microseconds)) - - -def process_lines(lines, writer): - """ - Processes a chunk of lines and writes the results to the CSV. - """ - with multiprocessing.Pool(PROCESSORS) as p: - out = p.map(thread, lines) - lines.clear() - for data in out: - for sub_data in data: - str_time = sub_data.timestamp.strftime("%Y-%m-%dT%H:%M:%S.%fZ") - writer.writerow([str_time, sub_data.id, DATA_IDS[sub_data.id]["name"], sub_data.value]) - - -if __name__ == "__main__": - """ - Processes the log files in the log folder and puts them in the output.csv file. - Command line args: - - arg 1 = output directory of the csv file - - Must be a directory name - - A file called 'output.csv' is created here - - args 2... = space separated list of file paths to process - - Each path must be a text file - Default file paths are all those in "./logs/" - Default output directory is the current location - """ - - start_time = datetime.now().strftime("%M:%S:%f").split(":") - output_path = "" - paths_to_process = [] - - # If manually specifying the paths - if len(sys.argv) > 1: - # Formats the input file path strings correctly - for i in range(1, len(sys.argv)): - sys.argv[i] = sys.argv[i].replace("\\","/") - - output_path = sys.argv[1] + "/output.csv" - paths_to_process = sys.argv[2:] - else: - output_path = DEFAULT_OUTPUT_PATH - paths_to_process = [DEFAULT_LOGS_DIRECTORY + name for name in listdir(DEFAULT_LOGS_DIRECTORY)] - - line_count = getLineCount(paths_to_process) - print(f"Processing a total of {line_count} lines") - - current_line = 0 - manager = multiprocessing.Manager() - return_dict = manager.dict() - - print(f"Writing to the CSV") - header = ["time", "data_id", "description", "value"] - - with open(output_path, "w", encoding="UTF8", newline="") as f: - writer = csv.writer(f) - writer.writerow(header) - - for fp in paths_to_process: - with open(fp) as file: - line_num = 0 - lines = [] - for line in file: - line_num += 1 - current_line += 1 - if current_line % 5000 == 0: - print(f"Line {line_num}") - - lines.append(line) - try: - if line_num % PROCESS_CHUNK_SIZE == 0: - # When stored data reaches specified amount, use threads to decode data faster - process_lines(lines, writer) - except: - print(f"Error with line {line_num} in file {file.name}") - pass - - if lines: - # Handles leftover stored lines when the loop ends - process_lines(lines, writer) - - finish_time = datetime.now().strftime("%M:%S:%f").split(":") - find_time(start_time, finish_time) diff --git a/python/data.py b/python/data.py deleted file mode 100644 index b04c194..0000000 --- a/python/data.py +++ /dev/null @@ -1,123 +0,0 @@ -from typing import List, Any -from datetime import datetime - - -class Data: - """ - Wrapper class for an individual piece of data. - """ - - def __init__(self, timestamp: datetime, id: int, value: Any): - self.timestamp = timestamp - self.id = id - self.value = value - - def __str__(self): - """ - Overrides the string representation of the class. - """ - return f"ID {self.id} - {self.timestamp} - {self.value}" - - -class ProcessData: - """ - Utility functions to process message data. - """ - - @staticmethod - def groupBytes(data_bytes: List[int], group_length: int = 2) -> List[List[int]]: - """ - Splits the given data bytes into lists of specified length. - """ - return [data_bytes[i : i + group_length] for i in range(0, len(data_bytes), group_length)] - - @staticmethod - def twosComp(val: int, bits: int = 16) -> int: - """ - Computes the twos complement of the given value. - """ - if (val & (1 << (bits - 1))) != 0: - val = val - (1 << bits) - return val - - @staticmethod - def littleEndian(data_bytes: List[int], bits: int = 8) -> int: - """ - Transforms the given data bytes into a value in little endian. - Little Endian byte order stores low order bytes first. - """ - result = 0 - for i in range(len(data_bytes)): - result |= data_bytes[i] << (bits * i) - return result - - @staticmethod - def bigEndian(data_bytes: List[int], bits: int = 8) -> int: - """ - Transforms the given data bytes into a value in big endian. - Big Endian byte order stores low order bytes last. - """ - result = 0 - for i in range(len(data_bytes)): - result |= data_bytes[i] << (bits * (len(data_bytes) - i - 1)) - return result - - @staticmethod - def defaultDecode(byte_vals: List[int]) -> List[int]: - """ - Default decode structure seen by a majority of the messages. - """ - grouped_vals = ProcessData.groupBytes(byte_vals) - parsed_vals = [ProcessData.littleEndian(val) for val in grouped_vals] - decoded_vals = [ProcessData.twosComp(val) for val in parsed_vals] - return decoded_vals - - -class FormatData: - """ - Utility functions to scale data values of a specific type. - """ - - @staticmethod - def temperature(value): - return value / 10 - - @staticmethod - def lowVoltage(value): - return value / 100 - - @staticmethod - def torque(value): - return value / 10 - - @staticmethod - def highVoltage(value): - return value / 10 - - @staticmethod - def current(value): - return value / 10 - - @staticmethod - def angle(value): - return value / 10 - - @staticmethod - def angularVelocity(value): - return -value - - @staticmethod - def frequency(value): - return value / 10 - - @staticmethod - def power(value): - return value / 10 - - @staticmethod - def timer(value): - return value * 0.003 - - @staticmethod - def flux(value): - return value / 1000 diff --git a/python/decode_data.py b/python/decode_data.py deleted file mode 100644 index 29aba85..0000000 --- a/python/decode_data.py +++ /dev/null @@ -1,338 +0,0 @@ -""" -This file specifies methods to decode messages into the many pieces of data they contain. -""" - -from typing import Any, Dict, List -import numpy as np -from data import ( - ProcessData as pd, - FormatData as fd, -) - - -def decodeMock(data: List[int]) -> Dict[int, Any]: - return { - 0: 0 - } - -def decodeAccumulatorStatus(data: List[int]) -> Dict[int, Any]: - return { - 1: pd.bigEndian(data[0:2]), - 2: pd.twosComp(pd.bigEndian(data[2:4])) / 10, - 3: pd.bigEndian(data[4:6]), - 4: data[6], - 5: data[7] - } - -def decodeBMSStatus(data: List[int]) -> Dict[int, Any]: - return { - 106: data[0], - 107: pd.littleEndian(data[1:5]), - 10: pd.twosComp(data[5], 8), - 11: pd.twosComp(data[6], 8) - } - -def decode3(data: List[int]) -> Dict[int, Any]: - return { - 12: data[0] - } - -def decodeCellVoltages(data: List[int]) -> Dict[int, Any]: - high_cell_volt_chip_number = (data[2] >> 4) & 15 - high_cell_volt_cell_number = (data[2] >> 0) & 15 - low_cell_volt_chip_number = (data[5] >> 4) & 15 - low_cell_volt_cell_number = (data[5] >> 0) & 15 - return { - 13: pd.littleEndian(data[0:2]), - 121: high_cell_volt_chip_number, - 122: high_cell_volt_cell_number, - 15: pd.littleEndian(data[3:5]), - 123: low_cell_volt_chip_number, - 124: low_cell_volt_cell_number, - 17: pd.littleEndian(data[6:8]) - } - -def decode5(data: List[int]) -> Dict[int, Any]: - decoded_data = pd.defaultDecode(data) - final_data = [fd.temperature(d) for d in decoded_data] - return { - 18: final_data[0], - 19: final_data[1], - 20: final_data[2], - 21: final_data[3] - } - -def decode6(data: List[int]) -> Dict[int, Any]: - decoded_data = pd.defaultDecode(data) - final_data = [fd.temperature(d) for d in decoded_data] - return { - 22: final_data[0], - 23: final_data[1], - 24: final_data[2], - 25: final_data[3] - } - -def decode7(data: List[int]) -> Dict[int, Any]: - decoded_data = pd.defaultDecode(data) - final_data = [fd.temperature(d) for d in decoded_data[:3]] - return { - 26: final_data[0], - 27: final_data[1], - 28: final_data[2], - 29: fd.torque(decoded_data[3]) - } - -# TODO: Fill this method out (complicated with bit shifts) -def decode8(data: List[int]) -> Dict[int, Any]: - return { - 30: 0, - 31: 0, - 32: 0, - 33: 0, - 34: 0, - 35: 0 - } - -def decode9(data: List[int]) -> Dict[int, Any]: - return { - 36: data[0], - 37: data[1], - 38: data[2], - 39: data[3], - 40: data[4], - 41: data[5], - 42: data[6], - 43: data[7] - } - -def decode10(data: List[int]) -> Dict[int, Any]: - decoded_data = pd.defaultDecode(data) - motor_speed = fd.angularVelocity(decoded_data[1]) - vehicle_speed = motor_speed * 0.013048225 - return { - 44: fd.angle(decoded_data[0]), - 45: motor_speed, - 46: fd.frequency(decoded_data[2]), - 47: fd.angle(decoded_data[3]), - 101: vehicle_speed - } - -def decode11(data: List[int]) -> Dict[int, Any]: - decoded_data = pd.defaultDecode(data) - final_data = [fd.current(d) for d in decoded_data] - return { - 48: final_data[0], - 49: final_data[1], - 50: final_data[2], - 51: final_data[3] - } - -def decode12(data: List[int]) -> Dict[int, Any]: - decoded_data = pd.defaultDecode(data) - final_data = [fd.highVoltage(d) for d in decoded_data] - return { - 52: final_data[0], - 53: final_data[1], - 54: final_data[2], - 55: final_data[3] - } - -def decode13(data: List[int]) -> Dict[int, Any]: - decoded_data = pd.defaultDecode(data) - return { - 56: fd.flux(decoded_data[0]), - 57: fd.flux(decoded_data[1]), - 58: fd.current(decoded_data[2]), - 59: fd.current(decoded_data[3]) - } - -def decode14(data: List[int]) -> Dict[int, Any]: - decoded_data = pd.defaultDecode(data) - final_data = [fd.lowVoltage(d) for d in decoded_data] - return { - 60: final_data[0], - 61: final_data[1], - 62: final_data[2], - 63: final_data[3] - } - -def decode15(data: List[int]) -> Dict[int, Any]: - return { - 64: pd.littleEndian(data[0:2]), - 65: data[2], - 66: data[3], - 67: data[4] & 1, - 68: (data[4] >> 5) & 7, - 69: data[5] & 1, - 70: data[6] & 1, - 71: (data[6] >> 7) & 1, - 72: data[7] & 1, - 73: (data[7] >> 1) & 1, - 74: (data[7] >> 2) & 1 - } - -def decode16(data: List[int]) -> Dict[int, Any]: - grouped_data = [pd.littleEndian(d) for d in pd.groupBytes(data)] - return { - 75: grouped_data[0], - 76: grouped_data[1], - 77: grouped_data[2], - 78: grouped_data[3] - } - -def decode17(data: List[int]) -> Dict[int, Any]: - decoded_data = pd.defaultDecode(data[:4]) - timer_data = pd.littleEndian(data[4:]) - return { - 79: fd.torque(decoded_data[0]), - 80: fd.torque(decoded_data[1]), - 81: fd.timer(timer_data) - } - -def decode18(data: List[int]) -> Dict[int, Any]: - decoded_data = pd.defaultDecode(data) - return { - 82: fd.torque(decoded_data[0]), - 83: fd.angularVelocity(decoded_data[1]), - 84: data[4], - 85: data[5] & 1, - 86: (data[5] >> 1) & 1, - 87: (data[5] >> 2) & 1, - 88: fd.torque(decoded_data[3]) - } - -def decode19(data: List[int]) -> Dict[int, Any]: - return { - 89: pd.littleEndian(data[0:2]), - 90: pd.littleEndian(data[2:4]) - } - -def decodeAcceleromterData(data: List[int]) -> Dict[int, Any]: - # The accelerometer is mounted at a 70 degree angle to the horizontal, we need to rotate the data to account for this - decoded_data = pd.defaultDecode(data) - converted_data = [val*0.0029 for val in decoded_data] - matrixData = np.matrix.transpose(np.mat(converted_data[0:3])) - transformMatrix = np.mat([[1, 0, 0], [0, np.cos(np.deg2rad(70)), np.sin(np.deg2rad(70))], [0, -np.sin(np.deg2rad(70)), np.cos(np.deg2rad(70))]]) - transformedData = transformMatrix * matrixData - return { - 91: float(transformedData[0][0]), - 92: float(transformedData[1][0]), - 93: float(transformedData[2][0]) - } - -def decode21(data: List[int]) -> Dict[int, Any]: - temp = pd.littleEndian(data[0:2]) - humid = pd.littleEndian(data[2:4]) - tempF = -49 + (315 * temp / 65535.0) - tempC = -45 + (175 * temp / 65535.0) - relHumid = 100 * humid / 65535.0 - return { - 94: tempC, - 95: tempF, - 96: relHumid - } - -def decode22(data: List[int]) -> Dict[int, Any]: - cell_id = data[0] - instant_voltage = pd.bigEndian(data[1:3]) - internal_resistance = pd.bigEndian(data[3:5]) & 32767 # clear last bit - shunted = (data[3] >> 7) & 1 # get last bit - open_voltage = pd.bigEndian(data[5:7]) - return { - 97: f"{cell_id} {instant_voltage} {open_voltage} {internal_resistance} {shunted}" - } - -def decode29(data: List[int]) -> Dict[int, Any]: - glv_current = pd.twosComp(pd.littleEndian(data), 32) - return { - 98: glv_current / 1000000.0 # undo 10^6 scale factor from car - } - -def decode34(data: List[int]) -> Dict[int, Any]: - voltage1 = pd.twosComp(pd.littleEndian(data[0:4]), 32) - voltage2 = pd.twosComp(pd.littleEndian(data[4:]), 32) - return { - 99: voltage1 / 1000000.0, # undo 10^6 scale factor from car - 100: voltage2 / 1000000.0 - } - -def decode35(data: List[int]) -> Dict[int, Any]: - return { - 102: pd.bigEndian(data[0:2]), - 103: pd.bigEndian(data[2:4]), - 104: data[4] - } - -def decodeMPUDashboardInfo(data: List[int]) -> Dict[int, Any]: - return { - 105: data[0], - 130: data[1], - 131: data[2], - 132: data[3], - 133: data[4], - } - - -def decodeGPS1(data: List[int]) -> Dict[int, Any]: - return { - 108: pd.twosComp(pd.littleEndian(data[0:4]), 32) / 10000000, # Longitude in degrees * 1e-7 (Get rid of multiplier) - 109: pd.twosComp(pd.littleEndian(data[4:8]), 32) / 10000000 # Latitude in degrees * 1e-7 (Get rid of multiplier) - } - -def decodeGPS2(data: List[int]) -> Dict[int, Any]: - return { - 110: pd.twosComp(pd.littleEndian(data[0:4]), 32), - 111: pd.twosComp(pd.littleEndian(data[4:8]), 32) / 1000 # Altitude in mm (transform to m) - } - -def decodeGPS3(data: List[int]) -> Dict[int, Any]: - return { - 112: pd.twosComp(pd.littleEndian(data[0:4]), 32) / 1000, # Ground speed in mm/sec (transform to m/s) - 113: pd.twosComp(pd.littleEndian(data[4:8]), 32) / 100000 # Heading in degrees * 1e-5 (Get rid of multiplier) - } - -def decodeCellTemps(data: List[int]) -> Dict[int, Any]: - high_cell_temp_chip_number = (data[2] >> 4) & 15 - high_cell_temp_cell_number = (data[2] >> 0) & 15 - low_cell_temp_chip_number = (data[5] >> 4) & 15 - low_cell_temp_cell_number = (data[5] >> 0) & 15 - - return { - 114: pd.twosComp(pd.littleEndian(data[0:2]), 16), - 115: high_cell_temp_chip_number, - 116: high_cell_temp_cell_number, - 117: pd.twosComp(pd.littleEndian(data[3:5]), 16), - 118: low_cell_temp_chip_number, - 119: low_cell_temp_cell_number, - 120: pd.twosComp(pd.littleEndian(data[6:8]), 16), - } - -def decodeSegmentTemps(data: List[int]) -> Dict[int, Any]: - return { - 125: pd.twosComp(data[0], 8), - 126: pd.twosComp(data[1], 8), - 127: pd.twosComp(data[2], 8), - 128: pd.twosComp(data[3], 8), - } - -def decodeLoggingStatus(data: List[int]) -> Dict[int, Any]: - return { - 129: data[0] - } - -def decodeLVBattery1(data: List[int]) -> Dict[int, Any]: - return { - 134: pd.littleEndian(data[0:2]), - 135: data[2], - 136: pd.littleEndian(data[3:5]), - 137: data[5], - 138: pd.twosComp(pd.littleEndian(data[6:8]), 16) - } - -def decodeLVBattery2(data: List[int]) -> Dict[int, Any]: - return { - 139: pd.twosComp(pd.littleEndian(data[0:2]), 16) * (192.264 / 1000000) * 4, - 140: pd.twosComp(pd.littleEndian(data[2:4]), 16) * (1.648 / 1000), - 141: pd.twosComp(pd.littleEndian(data[4:6]), 16) * (1.648 / 1000), - 142: pd.twosComp(pd.littleEndian(data[6:8]), 16) * (1.46487 / 1000000) / (0.5 / 1000) - } \ No newline at end of file diff --git a/python/decode_files.py b/python/decode_files.py deleted file mode 100644 index 8205b8c..0000000 --- a/python/decode_files.py +++ /dev/null @@ -1,77 +0,0 @@ -""" -This file specifies methods to decode message fields (timestamp, id, data bytes) from -a line in a log file. -""" - -from enum import Enum -from datetime import datetime - -from python.message import Message - - -class LogFormat(Enum): - TEXTUAL1 = 1 - TEXTUAL1_LEGACY = 2 - TEXTUAL2 = 3 - BINARY = 4 - - -def processLine(line: str, format: LogFormat) -> Message: - """ - Processes a line of textual data according to a given format. - """ - if format == LogFormat.TEXTUAL1: - return _processTextual1(line) - if format == LogFormat.TEXTUAL1_LEGACY: - return _processTextual1Legacy(line) - elif format == LogFormat.TEXTUAL2: - return _processTextual2(line) - elif format == LogFormat.BINARY: - return _processBinary(line) - else: - raise ValueError("Invalid file format.") - - -def _processTextual1(line: str) -> Message: - """ - Processes a line of data in the format "Timestamp id length [data1,data2,...]" - Example line format: 1679511802367 514 8 [54,0,10,0,0,0,0,0] - """ - fields = line.strip().split(" ") - timestamp = datetime.fromtimestamp(float(fields[0]) / 1000) - id = int(fields[1]) - length = int(fields[2]) - data = fields[3][1:-1].split(",") # remove commas and brackets at start and end - int_data = [int(x) for x in data] - return Message(timestamp, id, int_data) - - -def _processTextual1Legacy(line: str) -> Message: - """ - Processes a line of data in the format "Timestamp id length [data1,data2,...]" - Example line format: 2021-01-01T00:00:00.003Z 514 8 [54,0,10,0,0,0,0,0] - """ - fields = line.strip().split(" ") - timestamp = datetime.strptime(fields[0], "%Y-%m-%dT%H:%M:%S.%fZ") - id = int(fields[1]) - length = int(fields[2]) - data = fields[3][1:-1].split(",") # remove commas and brackets at start and end - int_data = [int(x) for x in data] - return Message(timestamp, id, int_data) - - -def _processTextual2(line: str) -> Message: - """ - Processes a line of data in the format "Timestamp id length data1 data2 ..." - Example line format: 1659901910.121 514 8 54 0 10 0 0 0 0 0 - """ - fields = line.strip().split(" ") - timestamp = datetime.fromtimestamp(float(fields[0])) - id = int(fields[1]) - length = int(fields[2]) - data = [int(x) for x in fields[3:3+length]] - return Message(timestamp, id, data) - - -def _processBinary(line: str) -> Message: - raise RuntimeError("Binary files not currently supported.") diff --git a/python/decode_statuses.py b/python/decode_statuses.py deleted file mode 100644 index 7879511..0000000 --- a/python/decode_statuses.py +++ /dev/null @@ -1,188 +0,0 @@ -from typing import Any - -from python.data import Data - - -# Mapping from data IDs to the status bits they encode -# Each data ID contains a dict with keys that are bit names and values that are the indexes -STATUS_MAP = { - # 6: { # Failsafe Statuses - # }, - # 7: { # DTC Status 1 - # }, - # 8: { # DTC Status 2 - # }, - # 9: { # Current Limits Status - # }, - # 12: { # MPE State - # }, - 64: { # VSM State - "VSM Start State": 0, - "Pre-charge Init State": 1, - "Pre-charge Active State": 2, - "Pre-charge Complete State": 3, - "VSM Wait State": 4, - "VSM Ready State": 5, - "Motor Running State": 6, - "Blink Fault Code State": 7 - }, - 65: { # Inverter State - "Power on State": 0, - "Stop State": 1, - "Open Loop State": 2, - "Closed Loop State": 3, - "Wait State": 4, - "Idle Run State": 8, - "Idle Stop State": 9 - }, - 66: { # Relay State - "Relay 1 Status": 0, - "Relay 2 Status": 1, - "Relay 3 Status": 2, - "Relay 4 Status": 3, - "Relay 5 Status": 4, - "Relay 6 Status": 5, - }, - 67: { # Inverter Run Mode - "Inverter Run Mode": 0 - }, - 69: { # Inverter Command Mode - "Inverter Command Mode": 0 - }, - 70: { # Inverter Enable State - "Inverter Enable State": 0 - }, - 71: { # Inverter Enable Lockout - "Inverter Enable Lockout": 0 - }, - 72: { # Direction Command - "Direction Command": 0 - }, - 73: { # BMS Active - "BMS Active": 0 - }, - 74: { # BMS Limiting Torque - "BMS Limiting Torque": 0 - }, - 75: { # POST Fault Lo - "Hardware Gate/Desaturation Fault": 0, - "HW Over-current Fault": 1, - "Accelerator Shorted": 2, - "Accelerator Open": 3, - "Current Sensor Low": 4, - "Current Sensor High": 5, - "Module Temperature Low": 6, - "Module Temperature High": 7, - "Control PCB Temperature Low": 8, - "Control PCB Temperature High": 9, - "Gate Drive PCB Temperature Low": 10, - "Gate Drive PCB Temperature High": 11, - "5V Sense Voltage Low": 12, - "5V Sense Voltage High": 13, - "12V Sense Voltage Low": 14, - "12V Sense Voltage High": 15 - }, - 76: { # POST Fault Hi - "2.5V Sense Voltage Low": 0, - "2.5V Sense Voltage High": 1, - "1.5V Sense Voltage Low": 2, - "1.5V Sense Voltage High": 3, - "DC Bus Voltage High": 4, - "DC Bus Voltage Low": 5, - "Pre-charge Timeout": 6, - "Pre-charge Voltage Failure": 7, - "Brake Shorted": 14, - "Brake Open": 15 - }, - 77: { # Run Fault Lo - "Motor Over-speed Fault": 0, - "Over-current Fault": 1, - "Over-voltage Fault": 2, - "Inverter Over-temperature Fault": 3, - "Accelerator Input Shorted Fault": 4, - "Accelerator Input Open Fault": 5, - "Direction Command Fault": 6, - "Inverter Response Time-out Fault": 7, - "Hardware Gate/Desaturation Fault": 8, - "Hardware Over-current Fault": 9, - "Under-voltage Fault": 10, - "CAN Command Message Lost Fault": 11, - "Motor Over-temperature Fault": 12 - }, - 78: { # Run Fault Hi - "Brake Input Shorted Fault": 0, - "Brake Input Open Fault": 1, - "Module A Over-temperature Fault": 2, - "Module B Over temperature Fault": 3, - "Module C Over-temperature Fault": 4, - "PCB Over-temperature Fault": 5, - "Gate Drive Board 1 Over-temperature Fault": 6, - "Gate Drive Board 2 Over-temperature Fault": 7, - "Gate Drive Board 3 Over-temperature Fault": 8, - "Current Sensor Fault": 9, - "Hardware Over-Voltage Fault": 11, - "Resolver Not Connected": 14, - "Inverter Discharge Active": 15 - }, - 84: { # Direction Command - "Direction Command": 0 - }, - 85: { # Inverter Enable - "Inverter Enable": 0 - }, - 86: { # Inverter Discharge - "Inverter Discharge": 0 - }, - 87: { # Speed Mode Enable - "Speed Mode Enable": 0 - }, - # 97: { # Cell Voltage Info - # } - 107: { # BMS Faults - "Cells Not Balancing": 0, - "Cell Voltage Too High": 1, - "Cell Voltage Too Low": 2, - "Pack Too High": 3, - "Open Wiring Fault": 4, - "Internal Software Fault": 5, - "Internal Thermal Fault": 6, - "Internal Cell Comm Fault": 7, - "Current Sensor Fault": 8, - "Charge Reading Mismatch": 9, - "Low Cell Voltage": 10, - "Weak Pack Fault": 11, - "External Can Fault": 12, - "Discharge Limit Enforcement Fault": 13, - "Charger Safety Relay": 14, - "Battery Can Fault": 15, - "Charger Can Fault": 16, - "Charge Limit Enforcement Fault": 17 - }, -} - - -def getStatus(data_id: int, data_value: Any, name: str) -> int: - """ - Gets the specified status of the given data piece. Returns a bit value. - """ - if data_id not in STATUS_MAP: - raise KeyError("Data ID has no associated status mapping") - bitmap = STATUS_MAP[data_id] - - if name not in bitmap: - raise KeyError("Status name could not be found in the given data point") - index = bitmap[name] - - return (data_value >> index) & 1 - - -def getStatuses(data_id: int, data_value: Any) -> Any: - """ - Gets all the statuses for the given data piece. - """ - if data_id not in STATUS_MAP: - raise KeyError("Data ID has no associated status mapping") - bitmap = STATUS_MAP[data_id] - - # Convert each dict value to the bit value at the index - return {name:(data_value >> index) & 1 for (name, index) in bitmap.items()} \ No newline at end of file diff --git a/python/master_mapping.py b/python/master_mapping.py deleted file mode 100644 index 0090e01..0000000 --- a/python/master_mapping.py +++ /dev/null @@ -1,763 +0,0 @@ -""" -This file specifes the CAN and data ID mappings. IDS: - - External Message ID (actual CAN message id) - - Data ID (id for individual data values contained in the messages) -""" - -from python.decode_data import * - -# Mapping from external message ID to decoding information -MESSAGE_IDS = { - 1: { - "description": "accumulator status", - "decoder": decodeAccumulatorStatus - }, - 2: { - "description": "BMS status", - "decoder": decodeBMSStatus - }, - 3: { - "description": "shutdown control", - "decoder": decode3 - }, - 4: { - "description": "cell data", - "decoder": decodeCellVoltages - }, - 160: { - "description": "temperatures (igbt modules, gate driver board)", - "decoder": decode5 - }, - 161: { - "description": "temperatures (control board)", - "decoder": decode6, - }, - 162: { - "description": "temperatures (motor)", - "decoder": decode7, - }, - 163: { - "description": "analog input voltages", - "decoder": decode8, - }, - 164: { - "description": "digital input status", - "decoder": decode9, - }, - 165: { - "description": "motor position information", - "decoder": decode10, - }, - 166: { - "description": "current information", - "decoder": decode11, - }, - 167: { - "description": "voltage information", - "decoder": decode12, - }, - 168: { - "description": "flux information", - "decoder": decode13, - }, - 169: { - "description": "internal voltages", - "decoder": decode14, - }, - 170: { - "description": "internal states", - "decoder": decode15, - }, - 171: { - "description": "fault codes", - "decoder": decode16, - }, - 172: { - "description": "torque and timer", - "decoder": decode17, - }, - 192: { - "description": "commanded data", - "decoder": decode18, - }, - 514: { - "description": "current limits", - "decoder": decode19, - }, - 768: { - "description": "nerduino accelerometer", - "decoder": decodeAcceleromterData, - }, - 769: { - "description": "nerduino humidity", - "decoder": decode21, - }, - 7: { - "description": "cell voltages", - "decoder": decode22, - }, - 193: { - "description": "unknown 1", - "decoder": decodeMock, - }, - 6: { - "description": "unknown 2", - "decoder": decodeMock, - }, - 194: { - "description": "unknown 3", - "decoder": decodeMock, - }, - 1744: { - "description": "unknown 4", - "decoder": decodeMock, - }, - 1745: { - "description": "unknown 5", - "decoder": decodeMock, - }, - 175: { - "description": "unknown 6", - "decoder": decodeMock, - }, - 770: { - "description": "GLV current", - "decoder": decode29, - }, - 2015: { - "description": "unknown 2015", - "decoder": decodeMock, - }, - 2027: { - "description": "unknown 2027", - "decoder": decodeMock, - }, - 2019: { - "description": "unknown 2019", - "decoder": decodeMock, - }, - 771: { - "description": "strain gauge", - "decoder": decode34, - }, - 1024: { - "description": "wheel state", - "decoder": decode35, - }, - 10: { - "description": "MPU States", - "decoder": decodeMPUDashboardInfo, - }, - 772: { - "description": "GPS Data 1", - "decoder": decodeGPS1, - }, - 773: { - "description": "GPS Data 2", - "decoder": decodeGPS2, - }, - 774: { - "description": "GPS Data 3", - "decoder": decodeGPS3, - }, - 8: { - "description": "Cell Temperatures", - "decoder": decodeCellTemps, - }, - 9: { - "description": "Segment Temperatures", - "decoder": decodeSegmentTemps, - }, - 775: { - "description": "Logging Status", - "decoder": decodeLoggingStatus, - }, - 177: { - "description": "unknown 177", - "decoder": decodeMock - }, - 1025: { - "description": "LV Battery 1", - "decoder": decodeLVBattery1, - }, - 1026: { - "description": "LV Battery 2", - "decoder": decodeLVBattery2, - } -} - -# Mapping from data ids to their description (potentially add format information) -DATA_IDS = { - 0: { - "name": "Mock Data", - "units": "", - }, - 1: { - "name": "Pack Inst Voltage", - "units": "V", - }, - 2: { - "name": "Pack Current", - "units": "A", - }, - 3: { - "name": "Pack Amphours", - "units": "Ah", - }, - 4: { - "name": "Pack SOC", - "units": "%", - }, - 5: { - "name": "Pack Health", - "units": "%", - }, - 6: { - "name": "Failsafe Statuses", - "units": "HEX", - }, - 7: { - "name": "DTC Status 1", - "units": "HEX", - }, - 8: { - "name": "DTC Status 2", - "units": "HEX", - }, - 9: { - "name": "Current Limits Status", - "units": "", - }, - 10: { - "name": "Average Temp", - "units": "C", - }, - 11: { - "name": "Internal Temp", - "units": "C", - }, - 12: { - "name": "MPE State", - "units": "BIN", - }, - 13: { - "name": "High Cell Voltage", - "units": "V", - }, - 14: { - "name": "High Cell Voltage ID", - "units": "", - }, - 15: { - "name": "Low Cell Voltage", - "units": "V", - }, - 16: { - "name": "Low Cell Voltage ID", - "units": "", - }, - 17: { - "name": "Average Cell Voltage", - "units": "V", - }, - 18: { - "name": "Module A Temperature", - "units": "C", - }, - 19: { - "name": "Module B Temperature", - "units": "C", - }, - 20: { - "name": "Module C Temperature", - "units": "C", - }, - 21: { - "name": "Gate Driver Board Temperature", - "units": "C", - }, - 22: { - "name": "Control Board Temperature", - "units": "C", - }, - 23: { - "name": "RTD #1 Temperature", - "units": "C", - }, - 24: { - "name": "RTD #2 Temperature", - "units": "C", - }, - 25: { - "name": "RTD #3 Temperature", - "units": "C", - }, - 26: { - "name": "RTD #4 Temperature", - "units": "C", - }, - 27: { - "name": "RTD #5 Temperature", - "units": "C", - }, - 28: { - "name": "Motor Temperature", - "units": "C", - }, - 29: { - "name": "Torque Shudder", - "units": "N-m", - }, - 30: { - "name": "Analog Input 1", - "units": "V", - }, - 31: { - "name": "Analog Input 2", - "units": "V", - }, - 32: { - "name": "Analog Input 3", - "units": "V", - }, - 33: { - "name": "Analog Input 4", - "units": "V", - }, - 34: { - "name": "Analog Input 5", - "units": "V", - }, - 35: { - "name": "Analog Input 6", - "units": "V", - }, - 36: { - "name": "Digital Input 1", - "units": "BIN", - }, - 37: { - "name": "Digital Input 2", - "units": "BIN", - }, - 38: { - "name": "Digital Input 3", - "units": "BIN", - }, - 39: { - "name": "Digital Input 4", - "units": "BIN", - }, - 40: { - "name": "Digital Input 5", - "units": "BIN", - }, - 41: { - "name": "Digital Input 6", - "units": "BIN", - }, - 42: { - "name": "Digital Input 7", - "units": "BIN", - }, - 43: { - "name": "Digital Input 8", - "units": "BIN", - }, - 44: { - "name": "Motor Angle (Electrical)", - "units": "Deg", - }, - 45: { - "name": "Motor Speed", - "units": "RPM", - }, - 46: { - "name": "Electrical Output Frequency", - "units": "Hz", - }, - 47: { - "name": "Delta Resolver Filtered", - "units": "Deg", - }, - 48: { - "name": "Phase A Current", - "units": "A", - }, - 49: { - "name": "Phase B Current", - "units": "A", - }, - 50: { - "name": "Phase C Current", - "units": "A", - }, - 51: { - "name": "DC Bus Current", - "units": "A", - }, - 52: { - "name": "DC Bus Voltage", - "units": "V", - }, - 53: { - "name": "Output Voltage", - "units": "V", - }, - 54: { - "name": "VAB_Vd Voltage", - "units": "V", - }, - 55: { - "name": "VBC_Vq Voltage", - "units": "V", - }, - 56: { - "name": "Flux Command", - "units": "Wb", - }, - 57: { - "name": "Flux Feedback", - "units": "Wb", - }, - 58: { - "name": "Id Feedback", - "units": "A", - }, - 59: { - "name": "Iq Feedback", - "units": "A", - }, - 60: { - "name": "1.5V Reference Voltage", - "units": "V", - }, - 61: { - "name": "2.5V Reference Voltage", - "units": "V", - }, - 62: { - "name": "5.0V Reference Voltage", - "units": "V", - }, - 63: { - "name": "12V System Voltage", - "units": "V", - }, - 64: { - "name": "VSM State", - "units": "", - }, - 65: { - "name": "Inverter State", - "units": "", - }, - 66: { - "name": "Relay State", - "units": "BIN", - }, - 67: { - "name": "Inverter Run Mode", - "units": "BIN", - }, - 68: { - "name": "Inverter Active Discharge State", - "units": "BIN", - }, - 69: { - "name": "Inverter Command Mode", - "units": "BIN", - }, - 70: { - "name": "Inverter Enable State", - "units": "BIN", - }, - 71: { - "name": "Inverter Enable Lockout", - "units": "BIN", - }, - 72: { - "name": "Direction Command", - "units": "BIN" - }, - 73: { - "name": "BMS Active", - "units": "BIN", - }, - 74: { - "name": "BMS Limiting Torque", - "units": "BIN", - }, - 75: { - "name": "POST Fault Lo", - "units": "BIN", - }, - 76: { - "name": "POST Fault Hi", - "units": "BIN", - }, - 77: { - "name": "Run Fault Lo", - "units": "BIN", - }, - 78: { - "name": "Run Fault Hi", - "units": "BIN", - }, - 79: { - "name": "Commanded Torque", - "units": "N-m", - }, - 80: { - "name": "Torque Feedback", - "units": "N-m", - }, - 81: { - "name": "Power on Timer", - "units": "s", - }, - 82: { - "name": "Torque Command", - "units": "N-m", - }, - 83: { - "name": "Speed Command", - "units": "RPM", - }, - 84: { - "name": "Direction Command", - "units": "BIN", - }, - 85: { - "name": "Inverter Enable", - "units": "BIN", - }, - 86: { - "name": "Inverter Discharge", - "units": "BIN", - }, - 87: { - "name": "Speed Mode Enable", - "units": "BIN", - }, - 88: { - "name": "Commanded Torque Limit", - "units": "N-m", - }, - 89: { - "name": "Pack DCL", - "units": "A", - }, - 90: { - "name": "Pack CCL", - "units": "A", - }, - 91: { - "name": "TCU X-Axis Acceleration", - "units": "g", - }, - 92: { - "name": "TCU Y-Axis Acceleration", - "units": "g", - }, - 93: { - "name": "TCU Z-Axis Acceleration", - "units": "g", - }, - 94: { - "name": "TCU Temperature C", - "units": "C", - }, - 95: { - "name": "TCU Temperature F", - "units": "F", - }, - 96: { - "name": "Relative Humidity", - "units": "%", - }, - 97: { - "name": "Cell Voltage Info", - "units": "", - }, - 98: { - "name": "GLV Current", - "units": "A", - }, - 99: { - "name": "Strain Gauge Voltage 1", - "units": "V", - }, - 100: { - "name": "Strain Gauge Voltage 2", - "units": "V", - }, - 101: { - "name": "Vehicle Speed", - "units": "MPH", - }, - 102: { - "name": "Wheel Knob 1", - "units": "", - }, - 103: { - "name": "Wheel Knob 2", - "units": "", - }, - 104: { - "name": "Wheel Buttons", - "units": "BIN", - }, - 105: { - "name": "MPU Mode State", - "units": "" - }, - 106: { - "name": "BMS State", - "units": "" - }, - 107: { - "name": "BMS Faults", - "units": "HEX" - }, - 108: { - "name": "Latitude", - "units": "Deg" - }, - 109: { - "name": "Longitude", - "units": "Deg" - }, - 110: { - "name": "GPS Fix Status", - "units": "" - }, - 111: { - "name": "Altitude", - "units": "m" - }, - 112: { - "name": "Ground Speed", - "units": "m/s" - }, - 113: { - "name": "Heading Direction", - "units": "Deg" - }, - 114: { - "name": "High Cell Temp", - "units": "C" - }, - 115: { - "name": "High Cell Temp Chip Number", - "units": "" - }, - 116: { - "name": "High Cell Temp Cell Number", - "units": "" - }, - 117: { - "name": "Low Cell Temp", - "units": "C" - }, - 118: { - "name": "Low Cell Temp Chip Number", - "units": "" - }, - 119: { - "name": "Low Cell Temp Cell Number", - "units": "" - }, - 120: { - "name": "Average Cell Temp", - "units": "C" - }, - 121: { - "name": "High Cell Voltage Chip Number", - "units": "" - }, - 122: { - "name": "High Cell Voltage Cell Number", - "units": "" - }, - 123: { - "name": "Low Cell Voltage Chip Number", - "units": "" - }, - 124: { - "name": "Low Cell Voltage Cell Number", - "units": "" - }, - 125: { - "name": "Segment 1 Average Temperature", - "units": "C" - }, - 126: { - "name": "Segment 2 Average Temperature", - "units": "C" - }, - 127: { - "name": "Segment 3 Average Temperature", - "units": "C" - }, - 128: { - "name": "Segment 4 Average Temperature", - "units": "C" - }, - 129: { - "name": "Logging Status", - "units": "" - }, - 130: { - "name": "Accumulator Fan Percentage", - "units": "%" - }, - 131: { - "name": "Motor Fan Percentage", - "units": "%" - }, - 132: { - "name": "Torque Limit Percentage", - "units": "%" - }, - 133: { - "name": "Regen Strength Value", - "units": "" - }, - 134: { - "name": "Charger State", - "units": "" - }, - 135: { - "name": "Measurement System Valid", - "units": "" - }, - 136: { - "name": "System Status", - "units": "" - }, - 137: { - "name": "Charge Status", - "units": "" - }, - 138: { - "name": "ibat", - "units": "A" - }, - 139: { - "name": "vbat", - "units": "V" - }, - 140: { - "name": "vin", - "units": "V" - }, - 141: { - "name": "vsys", - "units": "V" - }, - 142: { - "name": "iin", - "units": "A" - } -} diff --git a/python/message.py b/python/message.py deleted file mode 100644 index 081d8e8..0000000 --- a/python/message.py +++ /dev/null @@ -1,49 +0,0 @@ -from typing import List, Dict, Any -from datetime import datetime - -from python.data import Data -from python.master_mapping import MESSAGE_IDS - - -class MessageFormatException(Exception): - """ - A class to represent exceptions related to invalid message formats. - """ - - def __init__(self, message: str): - self.message = message - - -class Message: - """ - Wrapper class for an individual message. - """ - - def __init__(self, timestamp: datetime, id: int, data: List[int]): - self.timestamp = timestamp - self.id = id - self.data = data - - def __str__(self): - """ - Overrides the string representation of the class. - """ - return f"[{self.timestamp.strftime('%Y-%m-%dT%H:%M:%S.%fZ')}] {self.id} - {self.data}" - - def decode(self) -> List[Data]: - """ - Processes this message's data into a list of data points. - """ - return self.decodeMessage(self.timestamp, self.id, self.data) - - @staticmethod - def decodeMessage(timestamp: datetime, id: int, data: List[int]) -> List[Data]: - """ - Decodes the given message fields into their data points - """ - try: - decoded_data: Dict[int, Any] = MESSAGE_IDS[id]["decoder"](data) - except: - raise MessageFormatException(f"Invalid data format for can id {id}") - - return [Data(timestamp, data_id, decoded_data[data_id]) for data_id in decoded_data] \ No newline at end of file diff --git a/python/thread.py b/python/thread.py deleted file mode 100644 index c0d61aa..0000000 --- a/python/thread.py +++ /dev/null @@ -1,9 +0,0 @@ -from python.decode_files import LogFormat, processLine -from python.message import Message - -FORMAT = LogFormat.TEXTUAL1 - - -def thread(line): - message: Message = processLine(line, FORMAT) - return message.decode() \ No newline at end of file diff --git a/src/data.rs b/src/data.rs index f13f818..058b524 100644 --- a/src/data.rs +++ b/src/data.rs @@ -6,7 +6,7 @@ use std::fmt; pub struct Data { pub value: f32, pub topic: String, - pub unit: String + pub unit: String, } /** @@ -16,7 +16,11 @@ impl fmt::Display for Data { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { // Overrides the string representation of the class. - write!(f, "topic: {}, value: {}, unit: {}", self.topic, self.value, self.unit) + write!( + f, + "topic: {}, value: {}, unit: {}", + self.topic, self.value, self.unit + ) } } @@ -34,12 +38,12 @@ impl Data { Self { value, topic: topic.to_string(), - unit: unit.to_string() + unit: unit.to_string(), } } pub fn to_json(&self) -> String { - format!("{{\"topic\": \"{}\", \"value\": {}, \"unit\": \"{}\"}}", self.topic, self.value, self.unit) + format!("{{\"value\": {}, \"unit\": \"{}\"}}", self.value, self.unit) } } @@ -89,7 +93,7 @@ impl ProcessData { */ pub fn half(byte: u8, bits: u8) -> u32 { (byte >> bits & 15) as u32 - } + } } /** @@ -98,55 +102,33 @@ impl ProcessData { pub struct FormatData {} impl FormatData { + /* Temperatures are divided by 10 for 1 decimal point precision in C */ pub fn temperature(value: f32) -> f32 { value / 10.0 } - pub fn low_voltage(value: f32) -> f32 { - value / 100.0 - } - + /* Torque values are divided by 10 for one decimal point precision in N-m */ pub fn torque(value: f32) -> f32 { value / 10.0 } - pub fn high_voltage(value: f32) -> f32 { - value / 10.0 - } - + /* Current values are divided by 10 for one decimal point precision in A */ pub fn current(value: f32) -> f32 { value / 10.0 } - pub fn angle(value: f32) -> f32 { - value / 10.0 - } - - pub fn angular_velocity(value: f32) -> f32 { - -value - } - - pub fn frequency(value: f32) -> f32 { - value / 10.0 - } - - pub fn power(value: f32) -> f32 { - value / 10.0 - } - - pub fn timer(value: f32) -> f32 { - value * 0.003 - } - - pub fn flux(value: f32) -> f32 { - value / 1000.0 - } - + /* Cell Voltages are recorded on a 10000x multiplier for V, must be divided by 10000 to get accurate number */ pub fn cell_voltage(value: f32) -> f32 { value / 10000.0 } + /* Acceleration values must be offset by 0.0029 according to datasheet */ pub fn acceleration(value: f32) -> f32 { value * 0.0029 } + + /* High Voltage values are divided by 100 for one decimal point precision in V, high voltage is in regards to average voltage from the accumulator pack */ + pub fn high_voltage(value: f32) -> f32 { + value / 100.0 + } } diff --git a/src/mqtt.rs b/src/mqtt.rs index 393fe69..7ebe686 100644 --- a/src/mqtt.rs +++ b/src/mqtt.rs @@ -25,7 +25,7 @@ impl Client for MqttClient { * param data: The data object to format and send. */ fn publish(&mut self, data: &Data) { - let topic = "/Calypso".to_string(); + let topic = data.topic.to_string(); let payload = data.to_json(); /* If the client is initialized, publish the data. */ From 18f477224eb13bcba24842b2672bd6c3312459d9 Mon Sep 17 00:00:00 2001 From: Peyton-McKee Date: Sat, 13 Jan 2024 14:25:19 -0500 Subject: [PATCH 40/41] #20 Adjust can message topic name --- oxy/can-messages/bms.yaml | 4 ++-- src/decode_data.rs | 6 +++--- src/master_mapping.rs | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/oxy/can-messages/bms.yaml b/oxy/can-messages/bms.yaml index 87ced71..cb95642 100644 --- a/oxy/can-messages/bms.yaml +++ b/oxy/can-messages/bms.yaml @@ -135,7 +135,7 @@ msgs: - !Half bits: 0 - !CANField - name: "BMS/Cells/Volts/Ave/Value" + name: "BMS/Cells/Volts/Avg/Value" size: 2 index: 6 unit: "V" @@ -199,7 +199,7 @@ msgs: - !Half bits: 0 - !CANField - name: "BMS/Cells/Temp/Ave/Value" + name: "BMS/Cells/Temp/Avg/Value" unit: "C" size: 2 index: 6 diff --git a/src/decode_data.rs b/src/decode_data.rs index 7d76103..b283149 100644 --- a/src/decode_data.rs +++ b/src/decode_data.rs @@ -44,7 +44,7 @@ pub fn decode_cell_data(data: &[u8]) -> Vec:: { Data::new(fd::cell_voltage(pd::little_endian(&data[4..6] as &[u8], 8) as f32), "BMS/Cells/Volts/Low/Value", "V"), Data::new(pd::half(data[6] as u8, 4) as f32, "BMS/Cells/Volts/Low/Chip", ""), Data::new(pd::half(data[7] as u8, 0) as f32, "BMS/Cells/Volts/Low/Cell", ""), - Data::new(fd::cell_voltage(pd::little_endian(&data[8..10] as &[u8], 8) as f32), "BMS/Cells/Volts/Ave/Value", "V"), + Data::new(fd::cell_voltage(pd::little_endian(&data[8..10] as &[u8], 8) as f32), "BMS/Cells/Volts/avg/Value", "V"), ]; result } @@ -57,7 +57,7 @@ pub fn decode_cell_temperatures(data: &[u8]) -> Vec:: { Data::new(pd::twos_comp(pd::little_endian(&data[4..6] as &[u8], 8) as u32, 16) as f32, "BMS/Cells/Temp/Low/Value", "C"), Data::new(pd::half(data[6] as u8, 4) as f32, "BMS/Cells/Temp/Low/Cell", ""), Data::new(pd::half(data[7] as u8, 0) as f32, "BMS/Cells/Temp/Low/Chip", ""), - Data::new(pd::twos_comp(pd::little_endian(&data[8..10] as &[u8], 8) as u32, 16) as f32, "BMS/Cells/Temp/Ave/Value", "C"), + Data::new(pd::twos_comp(pd::little_endian(&data[8..10] as &[u8], 8) as u32, 16) as f32, "BMS/Cells/Temp/avg/Value", "C"), ]; result } @@ -72,7 +72,7 @@ pub fn decode_segment_temperatures(data: &[u8]) -> Vec:: { result } -pub fn decode_nerduino_acceleromter(data: &[u8]) -> Vec:: { +pub fn decode_mpu_acceleromter(data: &[u8]) -> Vec:: { let result = vec![ Data::new(fd::acceleration(pd::big_endian(&data[0..2] as &[u8], 8) as f32), "MPU/Accel/X", "g"), Data::new(fd::acceleration(pd::big_endian(&data[2..4] as &[u8], 8) as f32), "MPU/Accel/Y", "g"), diff --git a/src/master_mapping.rs b/src/master_mapping.rs index 95a5b7a..8cb2016 100644 --- a/src/master_mapping.rs +++ b/src/master_mapping.rs @@ -19,7 +19,7 @@ pub fn get_message_info(id: &u32) -> MessageInfo { 0x83 => MessageInfo::new(decode_cell_data), 0x84 => MessageInfo::new(decode_cell_temperatures), 0x85 => MessageInfo::new(decode_segment_temperatures), - 0x500 => MessageInfo::new(decode_nerduino_acceleromter), + 0x500 => MessageInfo::new(decode_mpu_acceleromter), 0x501 => MessageInfo::new(decode_mpu_status), 0x680 => MessageInfo::new(decode_wheel_state), _ => MessageInfo::new(decode_mock), From 9159e1141d1053dea407d3953293da884cadae70 Mon Sep 17 00:00:00 2001 From: Jack Rubacha Date: Sat, 13 Jan 2024 14:58:52 -0500 Subject: [PATCH 41/41] Add can_interface specifier and can configure skip (#27) * add can_interface specifier and can configure skip * Update readme with can interface * use clippy suggestions * update minimum argument number checking * make can0 optional --- .gitignore | 1 + src/main.rs | 44 +++++++++++++++++++++++++++++--------------- 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index 15f2f6f..e22ff85 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ # misc things .DS_Store .gitignore +*.nix # python things pyrightconfig.json diff --git a/src/main.rs b/src/main.rs index cf414e4..d776278 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,10 +6,10 @@ use std::{ use calypso::{client::Client, message::Message, mqtt::MqttClient}; use socketcan::CANSocket; -fn configure_can() { +fn configure_can(can_interface: &str) { let mut down_command = Command::new("sudo") .arg("ifconfig") - .arg("can0") + .arg(can_interface) .arg("down") .spawn() .expect("down command did not work"); @@ -20,7 +20,7 @@ fn configure_can() { .arg("ip") .arg("link") .arg("set") - .arg("can0") + .arg(can_interface) .arg("type") .arg("can") .arg("bitrate") @@ -32,7 +32,7 @@ fn configure_can() { .expect("Fail while waiting for bit rate"); let mut up_command = Command::new("sudo") .arg("ifconfig") - .arg("can0") + .arg(can_interface) .arg("up") .spawn() .expect("up command did nto work"); @@ -44,10 +44,9 @@ fn configure_can() { /** * Reads the can socket and publishes the data to the given client. */ -fn read_can(mut publisher: Box) { - //open can socket channel at name can0 - const CAN_CHANNEL: &str = "can0"; - let socket = CANSocket::open(CAN_CHANNEL); +fn read_can(mut publisher: Box, can_interface: &str) { + //open can socket channel at name can_interface + let socket = CANSocket::open(can_interface); let socket = match socket { Ok(socket) => socket, Err(err) => { @@ -76,23 +75,31 @@ fn read_can(mut publisher: Box) { * Parses the command line arguments. * Returns the client type and the path to connect to. */ -fn parse_args() -> (String, Box) { +fn parse_args() -> (String, Box, String, bool) { let args: Vec = env::args().collect(); println!("{:?}", args); - if args.len() < 2 { - println!("Please provide a client type"); + if args.len() < 3 { + println!("Not enough arguments!"); + println!("Client type and client path are required."); process::exit(1); } let client_type = &args[1]; let path = &args[2]; + let can_interface = if args.len() > 3 { &args[3] } else { "can0" }; + + let skip_can_config = args.len() > 4 && args[4] == "skip_can_configure"; println!("Client type: {}", client_type); println!("Path: {}", path); + println!("Can interface: {}", can_interface); + println!("Skip can configuration: {}", skip_can_config); match client_type.as_str() { "mqtt" => ( String::from(path), Box::new(MqttClient::new()) as Box, + String::from(can_interface), + skip_can_config, ), _ => { println!("Please provide a valid client type"); @@ -103,13 +110,20 @@ fn parse_args() -> (String, Box) { /** * Main Function - * Configures the can network, retrieves the client based on the command line arguments, connects the client and then reads the can socket. + * Configures the can network, retrieves the client based on the command line arguments, + * connects the client and then reads the can socket from specified interface. * Sample Calls for IPC "/home/ner/Desktop/Calypso/target/release/calypso ipc /tmp/ipc.sock &" * Sample Call for Mqtt "/home/ner/Desktop/Calypso/target/release/calypso mqtt localhost:1883 &" + * + * 3rd argument: if a can interface is passed the program will use it instead of the default can0 + * 4th argument: if skip_can_configure is passed the program will not call can interface setup commands + * Ex: "/home/ner/Desktop/Calypso/target/release/calypso mqtt localhost:1883 can0 skip_can_configure &" */ fn main() { - configure_can(); - let (path, mut client) = parse_args(); + let (path, mut client, can_interface, skip_can_configure) = parse_args(); + if !skip_can_configure { + configure_can(&can_interface) + } client.connect(&path); - read_can(client); + read_can(client, &can_interface); }