Skip to content

Conversation

@ccostes
Copy link

@ccostes ccostes commented Aug 2, 2025

Intent

Enable realtime message processing by creating a stateful RealtimeDecoder class which maintains aircraft state across decode calls to for position decoding. The RealtimeDecoder decode() method matches the API and behavior of the existing rs1090.decode().

Running the new example script should return something like the following

 % python realtime_decoder.py
Realtime vs Batch Processing Comparison
==================================================
Loading data from: ../../crates/rs1090/data/short_flights.csv
Loaded 486 ADS-B messages

============================================================
SUMMARY
============================================================
Messages processed: 486
Messages decoded: 486
Position messages: 163
Aircraft tracked: 9

Batch processing:    0.004s (128438 msg/s)
Realtime processing: 0.003s (176091 msg/s)
Performance: 27.1% faster

Context

I wanted to use rs1090 in python to do live decoding, particularly of aircraft position, which currently does not seem practical (if possible at all).

Notes

  • I added a short_flights.csv recording with a minute's worth of messages, containing 486 total messages with 163 positions from 9 different aircraft.

- Add RealtimeDecoder struct for stateful real-time message processing
- Add Python bindings with full type hints and PyO3 integration
- Refactor CPR decoding code to eliminate duplication between batch and real-time processing
- Update version to 0.4.14
- Maintain backward compatibility with existing APIs
@ccostes ccostes force-pushed the feature/realtime-decoder branch from 50a129d to 8e38f5a Compare August 2, 2025 01:35
if timestamps is None:
# Use current time for all messages
current_time = time.time()
timestamps = [current_time] * len(messages)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not totally sure this is the best idea.

@xoolive
Copy link
Owner

xoolive commented Aug 4, 2025

Thank you I will be able to have a look in the coming days 👍

Just a minor comment I have as I check from the phone, I will probably revert the version change in your commit 😅

@ccostes
Copy link
Author

ccostes commented Aug 4, 2025 via email

@xoolive
Copy link
Owner

xoolive commented Aug 11, 2025

Sorry I didn't have time to look at it yet, and the days off don't help :)

Another question about what you have in mind: for the moment, all the real-time decoding is taken care of by the jet1090 executable (in the same workspace, documentation https://mode-s.org/jet1090/).

So what's the use case?

Do you think wrapping the process_single_message for Python and providing the RealtimeDecoder class in pure Python would be enough?

@ccostes
Copy link
Author

ccostes commented Aug 26, 2025

Good question! Since they are organized as separate crates and the python bindings are only for rs1090 I thought it made sense to implement this functionality there to keep that self-contained. This would enable rs1090 to handle all the low-level decoding while jet1090 just handles the higher-level/UI functionality.

Functionally it seems like exposing the jet1090 processing should work, I just didn't get deep enough in that code to know how to do it. Totally up to you!

@xoolive
Copy link
Owner

xoolive commented Aug 26, 2025

Thank you for the update.
I will consider this all a bit later, probably after implementing the pure Rust rtlsdr though 😉

Maybe I will reimplement things by moving code from crate to crate rather than using your PR, but will definitely keep your suggestions open and credit for the idea.

Let's leave this open for now 👍

@ccostes
Copy link
Author

ccostes commented Aug 26, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants