Skip to content
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

Decode ASTERIX string message #195

Open
marius190 opened this issue Feb 8, 2022 · 1 comment
Open

Decode ASTERIX string message #195

marius190 opened this issue Feb 8, 2022 · 1 comment

Comments

@marius190
Copy link

Hello everyone,

I have a resource problem when decoding an .ast file. Since the file contain 4h of ADS-B data when I use parse the computer run out of ram memory:

file="file directory.ast"
data = file.read()
parsed = asterix.parse(data) # No memory

The .ast file has about 52 MB.

If I read let's say, data[0:500] it works fine and decodes the first messages. So I had an idea and is to use parse on pieces of data: piece=data[k:k+500]

The problem I get when doing this is that parse does give incorrect decoding since (I suspect) I can not break data into equally sized pieces, because then I break the first and/or the last message in two pieces, and parse does not interpret correctly when a message starts and finish, giving 0's CRC check.

Questions:

  1. How can I know when a message ends, before using parse (using just data)?
  2. Also, I have another possibility. I have the data in a .txt file where each row is an asterix message. How can I decode one-by-one the messages. For example,
msg="150058F71B7B6BC3A614D70101000D92011D3ACFFE1D0E0E9D6778FF0E871D44A8A238409C3840A716BC51D501B00A0E46057800000007A6887D3840C42811B6C0A820030808C501F78359400303070602020302022A0306"
# asterix.parse( msg ? ) 
@dsalantic
Copy link
Contributor

dsalantic commented Feb 9, 2022

Use the following algorithm to read packet by packet from file:

  1. Read 1 byte from the file (this is an ASTERIX category)
  2. Read next 2 bytes from the file and create unsigned short number from it (take care of byte ordering). This number represents the size (N) of the packet (including first 3 bytes).
  3. Read following N-3 bytes from the file and send those data (including first 3 bytes) to the parser
  4. Repeat from step 1. until the end of file

If you want to send string data directly to parser you need to convert it to byte array like in this example:
`asterix_packet = bytearray(
[0x30, 0x00, 0x30, 0xfd, 0xf7, 0x02, 0x19, 0xc9, 0x35, 0x6d, 0x4d, 0xa0, 0xc5, 0xaf, 0xf1, 0xe0,
0x02, 0x00, 0x05, 0x28, 0x3c, 0x66, 0x0c, 0x10, 0xc2, 0x36, 0xd4, 0x18, 0x20, 0x01, 0xc0, 0x78,
0x00, 0x31, 0xbc, 0x00, 0x00, 0x40, 0x0d, 0xeb, 0x07, 0xb9, 0x58, 0x2e, 0x41, 0x00, 0x20, 0xf5])

parsed = asterix.parse(asterix_packet)
`

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

No branches or pull requests

2 participants