Skip to content

Commit a3305b4

Browse files
Adds support for some locomotive logs Issue #44
Signed-off-by: Cole Gentry <peapod2007@gmail.com>
1 parent 54cc78e commit a3305b4

9 files changed

Lines changed: 2403 additions & 4 deletions

File tree

.claude/settings.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@
2828
"Bash(cargo check:*)",
2929
"Bash(while read line)",
3030
"Bash(do echo \"=== $line ===\")",
31-
"Bash(done)"
31+
"Bash(done)",
32+
"Bash(awk:*)",
33+
"Bash(cargo add:*)"
3234
]
3335
}
34-
}
36+
}

Cargo.lock

Lines changed: 101 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ tracing-subscriber = "0.3"
7878

7979
# UUID generation for anonymous user IDs
8080
uuid = { version = "1.0", features = ["v4"] }
81+
chrono = { version = "0.4.43", features = ["serde"] }
8182

8283
# Windows-specific: embed icon and manifest
8384
[target.'cfg(windows)'.build-dependencies]

exampleLogs/locomotive/115292475.csv

Lines changed: 1973 additions & 0 deletions
Large diffs are not rendered by default.

src/app.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use crate::analytics;
1717
use crate::computed::{ComputedChannel, ComputedChannelLibrary, FormulaEditorState};
1818
use crate::i18n::Language;
1919
use crate::parsers::{
20-
Aim, EcuMaster, EcuType, Emerald, Haltech, Link, Parseable, RomRaider, Speeduino,
20+
Aim, EcuMaster, EcuType, Emerald, Haltech, Link, Locomotive, Parseable, RomRaider, Speeduino,
2121
};
2222
use crate::settings::UserSettings;
2323
use crate::state::{
@@ -480,6 +480,16 @@ impl UltraLogApp {
480480
e
481481
))),
482482
}
483+
} else if Locomotive::detect(contents) {
484+
// Locomotive format detected
485+
let parser = Locomotive;
486+
match parser.parse(contents) {
487+
Ok(l) => Ok((l, EcuType::Locomotive)),
488+
Err(e) => Err(LoadResult::Error(format!(
489+
"Failed to parse Locomotive file: {}",
490+
e
491+
))),
492+
}
483493
} else {
484494
// Default to Haltech format
485495
let parser = Haltech;

src/bin/test_parser.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ use std::fs;
33
use std::path::Path;
44

55
// Import from the library
6-
use ultralog::parsers::{EcuMaster, EcuType, Emerald, Haltech, Link, Parseable, Speeduino};
6+
use ultralog::parsers::{
7+
EcuMaster, EcuType, Emerald, Haltech, Link, Locomotive, Parseable, Speeduino,
8+
};
79

810
fn main() {
911
// Get file path from command line or use default
@@ -67,6 +69,17 @@ fn main() {
6769
std::process::exit(1);
6870
}
6971
}
72+
} else if Locomotive::detect(&contents) {
73+
println!("\nDetected: Locomotive format");
74+
println!("Parsing Locomotive log...");
75+
let parser = Locomotive;
76+
match parser.parse(&contents) {
77+
Ok(log) => (EcuType::Locomotive, log),
78+
Err(e) => {
79+
eprintln!("Parse error: {}", e);
80+
std::process::exit(1);
81+
}
82+
}
7083
} else {
7184
println!("\nDetected: Haltech format");
7285
println!("Parsing Haltech log...");

0 commit comments

Comments
 (0)