Skip to content

Commit

Permalink
fixing flushing and closing of files
Browse files Browse the repository at this point in the history
  • Loading branch information
RCMast3r committed Mar 17, 2024
1 parent 522a82c commit 2b2a320
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,8 @@ flowchart TD

kvaser u100 pinout:
![Alt text](image.png)


get files from the car:

```rsync -azP nixos@192.168.40.1:/home/nixos/recordings ~/hytech_mcaps```
3 changes: 2 additions & 1 deletion py_data_acq/py_data_acq/mcap_writer/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@ def __exit__(self, exc_, exc_type_, tb_):
def __aenter__(self):
return self
async def __aexit__(self, exc_type: Any, exc_val: Any, traceback: Any):
super().finish()
self.writing_file.close()
return super().finish()

async def write_msg(self, msg):

super().write_message(topic=msg.DESCRIPTOR.name+"_data", message=msg, log_time=int(time.time_ns()), publish_time=int(time.time_ns()))
self.writing_file.flush()
return True

async def write_data(self, queue):
Expand Down
2 changes: 1 addition & 1 deletion py_data_acq/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ async def run(logger):
path_to_mcap = "/home/nixos/recordings"

mcap_writer = HTPBMcapWriter(path_to_mcap, list_of_msg_names, True)
mcap_server = MCAPServer(mcap_writer=mcap_writer, path=path_to_mcap, )
mcap_server = MCAPServer(mcap_writer=mcap_writer, path=path_to_mcap)
receiver_task = asyncio.create_task(continuous_can_receiver(db, msg_pb_classes, queue, queue2, bus))
fx_task = asyncio.create_task(fxglv_websocket_consume_data(queue, fx_s))
mcap_task = asyncio.create_task(write_data_to_mcap(queue2, mcap_writer))
Expand Down
10 changes: 10 additions & 0 deletions test_mcap.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import sys

from mcap_protobuf.reader import read_protobuf_messages

def main():
for msg in read_protobuf_messages("/home/ben/hytech_mcaps/recordings/03_17_2024_01_34_00_fixed.mcap", log_time_order=False):
print(f"{msg.topic}: {msg.proto_msg}")

if __name__ == "__main__":
main()

0 comments on commit 2b2a320

Please sign in to comment.