-
Notifications
You must be signed in to change notification settings - Fork 18
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
Feature Request: load from byte array for live parsing #83
Comments
Hi @scandey , This is an interesting idea, and I think it's a more simple to do than we might think. I think we could make this work by modifying
Do you have a use case in mind for your project? It would cool to actually prove this works end-to-end.
Right now a number of functions will issue a warning if bytes are missing at the end of the stream to complete the length stated in the last packet ( |
I'm working on internal calibration for the electric fields instrument on the TRACERS spacecraft (project/SOC at UIowa, instrument at UC Berkeley). I have lots of relatively simple CCSDS packets streaming in that I currently chunk into files of few minutes at a time to look at with CCSDSpy. I currently split the files by APID into new files and read with CCSDSpy, but it would be nice to iterate over packets, grab the ones I want into byte arrays by APID using I agree that number of extra bytes is better than missing bytes, even better if there's an option to return the bytes themselves (so they can be easily tacked on to the top of the next array/file as desired). All of this still assumes that the packets are generally well formed and that eventually well-formed packets are guaranteed to arrive (so no state machines needed). |
Thanks for explaining @scandey ! Does the solution I posted above with |
That's close to what I'd like to do in practice, but I already have a Python-based command and telemetry system that provides bytearrays of raw ccsds packets and it would be nice to drop those into |
Thanks @scandey . Can you be more specific as how these byte arrays are represented in your system and how they stream in? Does a file just grow on disk, or something else? I might have been premature in assuming it was streamed over a socket |
Sorry for confusing things! There are two very similar use-cases I'm working with at the moment. One of them is indeed a socket-based version for real-time analysis. I'm currently using an internal python-based command/data handling system which could easily dump well-formed CCSDS packets over a socket for real time analysis. The other use-case is mostly an extension of the first: I have plain CCSDS packets (no frame/sync info) going into a file (all the data from that same socket concept, but saved to a fresh file every 10 minutes). Packets are guaranteed to not split across file boundaries and I'm pretty confident that a half-saved file will also have all well-formed CCSDS packets (assuming I am handling the flush operations correctly). For either/both of these cases, I'd like to harness the nice packet definition system of CCSDSpy to quickly inspect and collect packets one at a time in the style of The big benefit to me is that I can go straight from a mixed-APID file to data analysis in one step, rather than having to save out a file for each APID and then load that file back in. Pseudo-python logic for the chunked file as I imagine it:
EDIT:
I'm not sure the BytesIO from EDIT2: I went ahead and forked and adjusted the load/_load parameters (quick and messy change) to allow for passing numpy byte arrays directly, seems to work okay on first glance, though the BytesIO objects cannot be resized later (not sure how to get rid of the view provided by |
Hey Scott, just got back from vacation. It should be easier to use I'm not sure why you are using Does this solve your issue? |
I guess I was making it massively overcomplicated, that seems to work. I'm not sure now how I got stuck on that idea of passing buffers around as opposed to BytesIO objects... maybe the issue that prompted that choice will turn up again but for now I'll close this massively overly-complicated issue. Thank you for taking the time to walk me through the logic! (I'll split out the network / live feed idea into a separate issue and the extra bytes not missing bytes into another separate issue, since this one is quite... overloaded by my confusion from last week). |
It seems like CCSDSpy would be viable for live plotting of telemetry if I could pass in a byte string/array of chunks of mixed binary data and process a second's worth of data at a time.
Absolutely reasonable to say this is out of scope, but it feels close to being viable with the existing structure. I see that _load wants a numpy array of bytes and I wish I could just dump that array in directly rather than saving to file first. For my particular data stream, I can guarantee even splits between packets so hopefully it'd be relatively clean.
In the longer term, allowing such a thing might benefit from a little bit of overhead to handle the case of missing bytes or extra bytes (if a packet is split across a chunk boundary). Both cases would preferably (to me) still return the successful packets up to that point and then return the incomplete packets or extra bytes for handling at a higher level.
The text was updated successfully, but these errors were encountered: