Skip to content

Commit

Permalink
March Launch 2024 Flight Code (#40)
Browse files Browse the repository at this point in the history
* Added initial pyro thread structs and declared thread

* forgot ;

* [AV-1057] Midas Voltage Thread (#11)

* Added voltage sensor

* removed struct initializer

* Finished implementation and set sensor to 50hz read

* fixed noob python error (added ;)

* Removed .vscode and added define for voltage pin

* third time's the charm -- added .vscode to gitignore again

* Av 1059/magnotometer (#3)

* implemented magnetometer

* commented magnetometer

* fix spelling

* renaming

---------

Co-authored-by: Nicholas Phillips <[email protected]>

* Av 1069 architecture md (#12)

* architecture page

* did some cleaning up

* typos

* change url

* added better wording for things

* Expanded ARCHITECTURE.md

Signed-off-by: redindelible <[email protected]>

---------

Signed-off-by: redindelible <[email protected]>
Co-authored-by: redindelible <[email protected]>

* Av 1052 high g accelerometer implementation (#4)

* implement high g sensor

* why not more comment

* mroe comments??

* make it actually work

* init list return

* update sampling rate

* actual refresh rate

* change error name

* make actually init

* Pin

* real fast odr

* resolved merge conflicts

---------

Co-authored-by: redindelible <[email protected]>
Co-authored-by: Aidan Costello <[email protected]>
Co-authored-by: aidancostello <[email protected]>

* AV 1056 implement gas sensor (#10)

* implement gas sensor

* actually initialize the gas sensor

* fix stuff so it actually works

* put back pin

* init list

* update sleep

* update sleep to not be fractional

* init sensor and make compile

* rename pin

* fix pin

* add optional instead of -1

* explaining comment

* Errors

* comments

---------

Co-authored-by: redindelible <[email protected]>
Co-authored-by: Nicholas Phillips <[email protected]>
Co-authored-by: aidancostello <[email protected]>

* Av 1050 barometer implementation (#2)

* add barometer functionality

* more comments per comment

* implement barometer with following TARS framework

* update thread function with data logging functinality

* remove const

* add todo for pin

* move lib into correct place

* put back pin

* make it actually compile (but need to revisit)

* init list return

* updated delay

* make it compile

* pin

* add todo update

* update library and sampling rate

---------

Co-authored-by: redindelible <[email protected]>
Co-authored-by: Nicholas Phillips <[email protected]>

* reverted to old ms5611 library

* Av 1051 ADXL LowG Sensor (#15)

* initial

* Add sensor lib

* Add lowg sensor read

* Add comments

* Change data rates

* Clean up merge

* Fix sensor initialization

---------

Co-authored-by: Ankith Madadi <[email protected]>
Co-authored-by: aidancostello <[email protected]>

* defined pins, gas sensor is gone

* set up i2c channel

* updated sensor prints

* updated mag error code

* fsm base layer

* rejiggered fsm

* balls

* added base pyro stuff

* added altitude to barometer

* Av 1058 continuity (#19)

* Add continuity stuff

* Add prep work for ADS7138-Q1 driver and continuity sensor

* Add changes that aidan suggested

* Add verification when initing continuity sensor

* AV-1067 + AV-1062 (SILSIM + Data Logging) (#18)

* everything except queues

* silsim FreeRTOS emulation compiles now

* The Big Mistake of '23.

* Fixed The Big Mistake of '23.

* Fixed my bad idea again, added timestamps to SensorState

Signed-off-by: redindelible <[email protected]>

* this time with 100% more logging

Signed-off-by: redindelible <[email protected]>

* 200% more logging

Signed-off-by: redindelible <[email protected]>

* data logging logs times

* tiny delete

* made log parser

* added checksum checking

Signed-off-by: redindelible <[email protected]>

* added generated checksum file as a quick reference when browsing git (it's never actually used as is so this is fine)

Signed-off-by: redindelible <[email protected]>

* added serial to emulation, added a "poor" silsim

* millis + new scheduling strategy

* better core emulation

* silsim + datalogging

* staging silsim

* staging support more thorough

* improving code

* it's merged

* fix compilation failures from merging

Signed-off-by: redindelible <[email protected]>

* log_checksum.h now links to source

Signed-off-by: redindelible <[email protected]>

* on second thought that was a bad idea

Signed-off-by: redindelible <[email protected]>

* millis uint32

* minor changes

* rename gyro to lowglsm

* added lowg_lsm to datalogging

* mac makecontext fix

* mac fix 2

* mac fix 3

* imma say that I fixed my log parser

* Fixed error in log_format.h

Signed-off-by: redindelible <[email protected]>

---------

Signed-off-by: redindelible <[email protected]>
Co-authored-by: Nicholas Phillips <[email protected]>
Co-authored-by: Aidan Costello <[email protected]>
Co-authored-by: aidancostello <[email protected]>

* changed acceleration naming

* preliminary pyro thread

* pyro fsm integration

* added .h and telem  stuff

* added telem stuff

* added some telem stuff
Co-authored-by: SuragNuthulapaty <[email protected]>

* added telem ready for pr

* remove globals

* AV-1053 GPS Abstraction Layer (#23)

* Branch for GPS

* Added allegedly Arduino compatible library

* GPS data related struct

* Created a skeleton for GPS driver

* Got speed from GPRMC message

* Branch builds

* Explicit int sizing

* Removed unnecessary auto usage

* Actually returns an error code

* Commented init to remember to use GPIO expander

* Forbid DS store from repo

* Adjusted GPS stuff to updated file structure

* buzz buzz mf (#22)

* buzz buzz mf

* buzzer will now work more often, up nearly 200000% from before

---------

Co-authored-by: aidancostello <[email protected]>

* added changes to telem for the PR

* added telemetry.h and systems.h to git

* actually make telem thread

* merged mvp-sensor-integration in

* merged mvp-sensor-integration in

* actually pass in struct

* added pyro and continuity telem

* fixed telemetry macro enable

* fixed pins

* renamed gpio expander

* changed name but real

* fix compilation

* updated readability

* rearchitected telem so it can be used with SILSIM (the silsim part isn't done yet)

* Av 1054 orientation (#29)

* did everything but temp and pressure

* finished temp and pressure for orientation

* pressure and temp for orientation

* return sensor reading, small naming changes

* added silsim support

---------

Co-authored-by: Caroline Montella <[email protected]>
Co-authored-by: redindelible <[email protected]>

* moved bno pins to pins.h

* i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i do git commit messages have a maximum length? hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++ i hate c++

* me when implicitly deleted copy constructor

* length check

* buffering

* minor fix

* Displacement Kalman Filter (#32)

* fsm base layer

* rejiggered fsm

* history buffer by any other name

* minor example kf changes

* minor example kf changes

* setup tick function for kf thread

* small error fix

* small changes

* added initilize stuff

* priv var update function

* small error fix

* small changes

* added initilize stuff

* priv var update function

* changing some stuff

* Initialize displacement kf

* fixed the fsm being deleted

* Format code

* Note to future gnc person o7

* Remove old todo

* Init correct kf

* Add kalman data to rocket data

* Convert ticks to secs

* Convert ticks to secs

* Remove this->

* Remove fsm remnants

---------

Co-authored-by: Aidan Costello <[email protected]>
Co-authored-by: redindelible <[email protected]>
Co-authored-by: Ethan Pereira <[email protected]>
Co-authored-by: sh1shir <[email protected]>

* added some comments

* added orientation check to upper stage

* added better orientation check, + code style changes

* address pr comments

* betrayal.

* ADC and GPIO drivers (#34)

* drivers

* make name more clear

* fix overflow bug

* add error codes instead of prints in tcal, change names to not overload arduino

* constexpr constructor of gpio address

* add error codes to adc

* fix incorrect error

* converted double to float to remove warning

* cursed manual merge

* remove extra files

* Av 1108 error code led (#35)

* change systems to return error on init

* error codes

* some more documentation

* final docs

* fixed requested stuff

* turned pins to octal and added documentation

* code style fixes

* pin and math changes

* merged stuffs

* Check pyro gpio initialization

* addr pr issues

* consolidated tick functions

* fixes

* fixed include

* Av 1060 pyros (#30)

* Added initial pyro thread structs and declared thread

* forgot ;

* fsm base layer

* rejiggered fsm

* balls

* added base pyro stuff

* preliminary pyro thread

* pyro fsm integration

* renamed gpio expander

* changed name but real

* fix compilation

* updated readability

* minor fix

* added some comments

* added orientation check to upper stage

* added better orientation check, + code style changes

* address pr comments

* betrayal.

* cursed manual merge

* remove extra files

* pin and math changes

* Check pyro gpio initialization

* addr pr issues

* consolidated tick functions

* fixes

* fixed include

---------

Co-authored-by: Michael Karpov <[email protected]>
Co-authored-by: redindelible <[email protected]>

* added build targets for booster and sustainer

* telem transmits pyros and fsm

* fix ifdef check

* Av 1115 emmc thread (#37)

* base emmc code

* remove library

* Initial Emmc

* emmc init and pins

* refafctor to use datalogging code

* inheriting

* no longer idiot

* finish doing emmc stuff

* got around queues dropping all data

* compiles under silsim

* newlines

* Av 1060 pyros (#30)

* Added initial pyro thread structs and declared thread

* forgot ;

* fsm base layer

* rejiggered fsm

* balls

* added base pyro stuff

* preliminary pyro thread

* pyro fsm integration

* renamed gpio expander

* changed name but real

* fix compilation

* updated readability

* minor fix

* added some comments

* added orientation check to upper stage

* added better orientation check, + code style changes

* address pr comments

* betrayal.

* cursed manual merge

* remove extra files

* pin and math changes

* Check pyro gpio initialization

* addr pr issues

* consolidated tick functions

* fixes

* fixed include

---------

Co-authored-by: Michael Karpov <[email protected]>
Co-authored-by: redindelible <[email protected]>

* added build targets for booster and sustainer

* base emmc code

* remove library

* Initial Emmc

* emmc init and pins

* refafctor to use datalogging code

* inheriting

* no longer idiot

* finish doing emmc stuff

* got around queues dropping all data

* compiles under silsim

* newlines

* update checksum and rebase

---------

Co-authored-by: Humza Zohair <[email protected]>
Co-authored-by: redindelible <[email protected]>
Co-authored-by: aidancostello <[email protected]>
Co-authored-by: Michael Karpov <[email protected]>
Co-authored-by: Aidan Costello <[email protected]>

* added call sign fixes and feather code

* added telem fixes

* add telem stuff and remove radiohead

* removed old radiohead

* Driver fixes (#38)

* fixes to drivers

* Add GPS fixes

* push the new pins

* fixed pins

---------

Co-authored-by: redindelible <[email protected]>
Co-authored-by: Zyun Lam <[email protected]>
Co-authored-by: Aadityavoru <[email protected]>

* Av 995 staging fsm (#31)

* fsm base layer

* rejiggered fsm

* history buffer by any other name

* FSM in progress

* working on averages

* second stage FSM done

* Added a FSM state
Added/adjusted thresholds and FSM state checks
Added altitude average function
Started tick_fsm function for first stage (wip)

Co-authored-by: azorah16 <[email protected]>

* compiling issues fixed

* most compliling issued fixed

* FSM complete

* FSM commented and complete

* PR changes made

* More PR changes

* more PR changes

* Made state derivative functions more accurate

Signed-off-by: redindelible <[email protected]>

* merge conflicts my beloved

Signed-off-by: redindelible <[email protected]>

---------

Signed-off-by: redindelible <[email protected]>
Co-authored-by: Aidan Costello <[email protected]>
Co-authored-by: redindelible <[email protected]>
Co-authored-by: yalkh3 <yalkh3>
Co-authored-by: azorah16 <[email protected]>

* merges

* Why, FreeRTOS

* remove prints

* barometer works i suppose

* more things

* no bueno

* emmc fixes

* emmc works

* emmc works even more

* telem hacky fix

* added radiohead

* added fixes

* disable locks

* sussy wussy

* wip

* fixup ms driver

* errors and stuff

* push ig

* double integrate

* the dram is stored in the *****

* fixes or something

* fixes but fr fr this time

* actually merged

* added ground

* updated telemetry

* updated voltage (mcu_sustainer is broken)

* added freebird

* play freebird😎

* Fixed sustainer (pre Free Bird era)

* updated freebird tempo

* fixed notes

* rearranged

* corrected measures 1-13

* comma

* added breaks between notes, free bird sound mid atm

* Blue when telem and ~Fixed~ changed voltage

* reduced GPS delay, moved free bird, removed ADXL (lowg) from Booster

* fixed booster

* remove pyros from booster

* logger

* logger

* Various improvements

* 1 G = 9.8 m/s/s

* decrease buzzer to 11 notes, 4 sec approx

* commented in buzzer startup

* fixeder

* move to one thread (#39)

* changed 3 characters cause rbhog didnt want to

* properly remove gravity

* telem buffering frequency decreased

* added leds
deleted files (I'm sure it'll be fine)

* less buffer overflows

* updated voltage dividers and callsigns

* added sense_pyro, yessir, booster led blink

* removed emmc, changed to 4 bit write

* using SD

* it's fine if sd doesn't sd

---------

Signed-off-by: redindelible <[email protected]>
Co-authored-by: Michael Karpov <[email protected]>
Co-authored-by: mpkarpov-ui <[email protected]>
Co-authored-by: Adesh Kumar <[email protected]>
Co-authored-by: Nicholas Phillips <[email protected]>
Co-authored-by: SuragNuthulapaty <[email protected]>
Co-authored-by: redindelible <[email protected]>
Co-authored-by: Ankith Madadi <[email protected]>
Co-authored-by: Ankith Madadi <[email protected]>
Co-authored-by: zyunlam <[email protected]>
Co-authored-by: Magilan Sendhil <[email protected]>
Co-authored-by: Aadityavoru <[email protected]>
Co-authored-by: Gautam Dayal <[email protected]>
Co-authored-by: jwu246 <[email protected]>
Co-authored-by: Caroline Montella <[email protected]>
Co-authored-by: Rithvik Bhogavilli <[email protected]>
Co-authored-by: Ethan Pereira <[email protected]>
Co-authored-by: sh1shir <[email protected]>
Co-authored-by: Nicholas Phillips <[email protected]>
Co-authored-by: Humza Zohair <[email protected]>
Co-authored-by: Zyun Lam <[email protected]>
Co-authored-by: Satyams2 <[email protected]>
Co-authored-by: azorah16 <[email protected]>
Co-authored-by: ashleysawa <[email protected]>
  • Loading branch information
24 people authored Apr 2, 2024
1 parent 4f438e0 commit 6119745
Show file tree
Hide file tree
Showing 580 changed files with 113,130 additions and 347 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.DS_Store
.vscode/
104 changes: 104 additions & 0 deletions LogParser/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import json
import pathlib
import struct
import zlib
from argparse import ArgumentParser
from sys import stderr

from LogParser.cpp_parser import Context, parse_file, Type, Struct, Enum, Integer, Union


def construct_values_mapping(ctxt: Context) -> dict[int, tuple[str, Type]]:
if "LoggedReading" not in ctxt.types:
raise Exception("'LoggedReading' not found")

format_struct = ctxt.types["LoggedReading"]
if not isinstance(format_struct, Struct):
raise Exception("'LoggedReading' is not a struct")

for field in ("discriminant", "timestamp_ms", "data"):
if field not in format_struct.members:
raise Exception(f"'LoggedReading' is missing field '{field}'")

discriminant_type = format_struct.members["discriminant"]
if not isinstance(discriminant_type, Enum):
raise Exception("'LoggedReading.discriminant' is not a enum")

timestamp_type = format_struct.members["timestamp_ms"]
if not isinstance(timestamp_type, Integer):
raise Exception("'LoggedReading.timestamp_ms' is not a uint32_t")

if timestamp_type.signed or timestamp_type.size != 4:
raise Exception("'LoggedReading.timestamp_ms' is not a uint32_t")

variants_type = format_struct.members["data"]
if not isinstance(variants_type, Union):
raise Exception("'LoggedReading.data' is not a union")

discriminants_normalized = {d_value: d_name.lower().removeprefix("id_") for d_value, d_name in discriminant_type.variants.items()}
variants_normalized = {v_name.lower().replace("_", ""): v_type for v_name, v_type in variants_type.variants.items()}

discriminant_set = set(discriminants_normalized.values())
variant_set = set(variants_normalized.keys())

diff = variant_set ^ discriminant_set
if len(diff) > 0:
raise Exception(f"Some items not matched between discriminant enum and variants union: {', '.join(diff)}")

variants: dict[int, tuple[str, Type]] = {}
for d_value, d_name in discriminants_normalized.items():
variants[d_value] = (d_name, variants_normalized[d_name])

return variants


def calculate_checksum() -> int:
src = pathlib.Path(__file__).parent.parent / "MIDAS" / "src"
text = (src / "log_format.h").read_text(errors="replace") + (src / "sensor_data.h").read_text(errors="replace")
expected_checksum = zlib.crc32(text.encode("utf-8"))
return expected_checksum


def main():
parser = ArgumentParser()
parser.add_argument("raw", type=pathlib.Path)
parser.add_argument("-o", "--out", type=pathlib.Path)
args = parser.parse_args()
if args.out is None:
args.out = args.raw.with_suffix(".json")

format_file = pathlib.Path(__file__).parent.parent / "MIDAS" / "src" / "log_format.h"

expected_checksum = calculate_checksum()

ctxt: Context = parse_file(format_file)

mapping = construct_values_mapping(ctxt)

json_out = []
with open(args.raw, "rb") as data_file:
found_checksum = int.from_bytes(data_file.read(4), byteorder="little")
if found_checksum != expected_checksum:
print(f"Warning: Trying to parse file with checksum {expected_checksum}, found file with checksum {found_checksum}", file=stderr)

while True:
disc_bytes = data_file.read(4)
if len(disc_bytes) == 0:
break
discriminant = int.from_bytes(disc_bytes, byteorder='little')
timestamp_ms = int.from_bytes(data_file.read(4), byteorder="little")
data_name, data_type = mapping[discriminant]
try:
data = data_type.parse(data_file.read(data_type.size))
except struct.error:
break
json_out.append({"type": data_name, "timestamp": timestamp_ms, "data": data})

data_file.read()

with open(args.out, "w") as out_file:
json.dump(json_out, out_file)


if __name__ == '__main__':
main()
Loading

0 comments on commit 6119745

Please sign in to comment.