-
Notifications
You must be signed in to change notification settings - Fork 5
Feat/rewrite scaffold recordings #130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
6d9ce33
d46c988
93186a6
72cb691
942f5f8
42be0ae
0dee755
ccd8cf8
c50c34a
a25c51a
6333788
657fdf3
580aae6
3694192
b0acbc8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -134,3 +134,4 @@ dmypy.json | |
|
|
||
| # Misc | ||
| .idea/ | ||
| recordings | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,4 +20,4 @@ | |
| "VA3EHJ": "Elias Hawa", | ||
| "VA3ZAJ": "Angus Jull" | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,6 @@ | |
| import uvicorn | ||
| import asyncio | ||
| import json | ||
| from src.ground_station_v2.replay import Replay | ||
| from src.ground_station_v2.record import Record | ||
| from typing import Any | ||
| import logging | ||
|
|
@@ -14,16 +13,25 @@ | |
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
| recorder = Record() | ||
|
|
||
| connected_clients: dict[str, WebSocket] = {} | ||
|
|
||
| async def broadcast_radio_packets(): | ||
| logger.info("Starting broadcast_radio_packets") | ||
| config = load_config("config.json") | ||
|
|
||
| try: | ||
| async for packet in get_radio_packet(): | ||
| recorder.init_mission("recordings") | ||
| recorder.start() | ||
|
|
||
| async for packet in get_radio_packet(True): | ||
| packet_hex = packet.hex() | ||
| parsed = parse_rn2483_transmission(packet_hex, config) | ||
|
|
||
| if (recorder.recording): | ||
| logger.info("Writing") | ||
incogiscool marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| recorder.write(packet_hex, parsed) | ||
|
|
||
| if not parsed: | ||
| logger.warning(f"Failed to parse packet: {packet_hex}") | ||
|
|
@@ -45,8 +53,14 @@ async def broadcast_radio_packets(): | |
|
|
||
| for client_id in disconnected: | ||
| connected_clients.pop(client_id, None) | ||
|
|
||
| recorder.stop() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. would this
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems like the loop from the packets doesn't end. I think its good to have just in case anything abnormal from the packet function. |
||
| recorder.close_mission() | ||
| except Exception as e: | ||
| recorder.stop() | ||
| recorder.close_mission() | ||
incogiscool marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| logger.error(f"Error in broadcast_radio_packets: {e}", exc_info=True) | ||
|
|
||
|
|
||
|
|
||
| # handles the lifespan of the app, creates and destroys async tasks | ||
|
|
@@ -103,12 +117,14 @@ async def replay_goto(x_client_id: str = Header(alias="X-Client-ID")): | |
| @app.post("/record_start") | ||
| async def record_start(x_client_id: str = Header(alias="X-Client-ID")): | ||
|
|
||
| recorder.start() | ||
| logger.info(f"Record start for client {x_client_id}") | ||
| return {"status": "ok"} | ||
|
|
||
| @app.post("/record_stop") | ||
| async def record_stop(x_client_id: str = Header(alias="X-Client-ID")): | ||
|
|
||
| recorder.stop() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure about this one but maybe stopping the recording should also just close the mission, what do you think
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe can call the stop function inside of the close mission function, but not completely take away the stop function? |
||
| logger.info(f"Record stop for client {x_client_id}") | ||
| return {"status": "ok"} | ||
|
|
||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You shouldn't import by path, look at the readme installation all the way to the bottom, you may have skipped the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix this pattern everywhere in your files plz |
Uh oh!
There was an error while loading. Please reload this page.