Expand description
One entry point for every format HPR Sim reads: give read a file’s bytes, and it
recognizes the layout from the content, never the file’s name, and reads it into the record
every reader fills (FlightLog).
The layouts it recognizes, the GPS logs by their own marks, the rest by the first line that isn’t blank:
| Format | Recognized by |
|---|---|
| KML | its root element is kml, after any XML declaration and comments |
| NMEA 0183 | at least 3 of its first 50 lines that aren’t blank open with a sentence whose checksum checks out, such as $GPGGA,…*hh |
| Featherweight GPS CSV | the first line opens UTCTIME,UNIXTIME, or TRACKER,DATE,TIME, and names the latitude and longitude |
PerfectFlite .pf2 | names PerfectFlite, such as PerfectFlite Pnut, in a file with no **!!Data: line (a .pfa’s) |
| PerfectFlite CSV and text | Time, Altitude and more of an export’s names, by commas or tabs |
| AltOS CSV | starts #version,, or opens with # comments before a #version, or version,serial, header |
| Raven FIP CSV | opens with a time column and holds the Raven’s Axial Accel (Gs) channel |
| Blue Raven CSV | opens Year,Month,Day,Time,Flight_Time_(s),Sync, |
| RRC3 CSV | Time, Altitude, Pressure, Velocity, then any of Temperature, Events, Voltages |
| Eggtimer CSV | T,Alt, and more of Eggtimer’s column names |
Text is read as UTF-8, or as UTF-16 after its byte-order mark (decode), with any byte-order
mark dropped; a byte that isn’t UTF-8 becomes U+FFFD, as a .pf2’s comments may be in another
encoding and no reader uses them.
use hpr_flightdata::{import, log::LogFormat};
let text = "Time,Altitude,Velocity\n0.00,0,0\n0.05,1,8\n0.10,3,30\n";
assert_eq!(import::detect(text.as_bytes()), Some(LogFormat::PerfectFliteCsv));
let log = import::read(text.as_bytes())?;
assert_eq!(log.channels.len(), 2); // the altitude and the velocity; the time is their clockConstants§
Functions§
- decode
- A file’s bytes as text: UTF-8, or UTF-16 if the file opens with UTF-16’s byte-order mark, as Debrief’s notes say some mDACS exports of an RRC3’s flight are (none of the project’s sample files is); any byte-order mark dropped, and a byte, or a pair of them, that isn’t a character replaced by U+FFFD.
- detect
- The format of a log, recognized from its first line that isn’t blank;
Nonefor a layout HPR Sim doesn’t read. - read
- Reads a flight log in any format HPR Sim reads.