Giter Club home page Giter Club logo

asterix-rs's Introduction

Asterix Encode/Decode Library

github crates.io docs.rs build status Codecov

Currently supported:

  • CAT048
  • CAT034

Usage

Compiler support: requires rustc 1.70+

Add the following to your Cargo.toml file:

[dependencies]
asterix = "v0.4.0"

Changelog

See CHANGELOG.md

asterix-rs's People

Contributors

dependabot[bot] avatar eskorzeny avatar karnotxo avatar step-security-bot avatar wcampbell0x2a avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

asterix-rs's Issues

Don't panic on "custom" CAT48/030 data

Currently, if you try to parse a Cat48 message which contains a Data Item I048/030, (Warning/Error Conditions and Target Classification) with a code higher than 31, the library panics.

This is unfortunate since the Standard defines the codes up to 36, reserves the space up to code 63 and specifically allows custom Codes between 64 and 127:
Values 0-63 are allocated by the AMG, values 64 to 127 are available for allocation by manufacturers and shall be described in the corresponding ICD

It would be great if the library wouldn't crash on those values and even better if you could extract them somehow for further processing.

Trying to use a more recent Deku: weird issue

I'm trying to use Deku 0.15 and I get all these weird errors, did they really change the order of parameters in BitSlice?

    Checking asterix v0.2.6 (/Users/roberto/Src/Rust/src/asterix-rs)
error[E0277]: the trait bound `deku::bitvec::Msb0: BitStore` is not satisfied
  --> src/custom_read_write.rs:29:16
   |
29 |         rest: &BitSlice<Msb0, u8>,
   |                ^^^^^^^^^^^^^^^^^^ the trait `BitStore` is not implemented for `deku::bitvec::Msb0`
   |
   = help: the following other types implement trait `BitStore`:
             AtomicU16
             AtomicU32
             AtomicU64
             AtomicU8
             AtomicUsize
             Cell<u16>
             Cell<u32>
             Cell<u64>
           and 12 others
note: required by a bound in `deku::bitvec::BitSlice`
  --> /Users/roberto/.cargo/registry/src/github.com-1ecc6299db9ec823/bitvec-1.0.1/src/slice.rs:62:5
   |
62 |     T: BitStore,
   |        ^^^^^^^^ required by this bound in `deku::bitvec::BitSlice`

error[E0277]: the trait bound `u8: BitOrder` is not satisfied
  --> src/custom_read_write.rs:29:16
   |
29 |         rest: &BitSlice<Msb0, u8>,
   |                ^^^^^^^^^^^^^^^^^^ the trait `BitOrder` is not implemented for `u8`
   |
   = help: the following other types implement trait `BitOrder`:
             LocalBits
             deku::bitvec::Msb0

whereas Deku use

crate_::bitvec::BitVec<u8, ::#crate_::bitvec::Msb0>

Any idea?

ci: Replace current coverage with new style

name: Coverage

on: [pull_request, push]

jobs:
  coverage:
    runs-on: ubuntu-latest
    env:
      CARGO_TERM_COLOR: always
    steps:
      - uses: actions/checkout@v3
      - name: Install Rust
        run: rustup update stable
      - name: Install cargo-llvm-cov
        uses: taiki-e/install-action@cargo-llvm-cov
      - name: Generate code coverage
        run: cargo llvm-cov --workspace --codecov --output-path codecov.json
      - name: Upload coverage to Codecov
        uses: codecov/codecov-action@v3
        with:
          files: codecov.json
          fail_ci_if_error: true

CAT48 decoding fails for warning_error_con_target_class >37

Hi,
since #32 was merged (thanks for the quick update!), I should be able to decode packets with warning_error_con_target_class- Codes up to 127. However, as the following example shows, this still fails:

use asterix::{AsterixMessage, AsterixPacket};
use deku::prelude::*;

fn main() {
	for num in 1..=127 {
		print!("{num}: ");
		let packet_bytes: [u8; 38] = [
			0x30, 0x00, 0x26, 0xf1, 0x57, 0xc9, 0x00, 0x00,
			0x00, 0x00, 0x00, 0x33, 0x20, 0x00, 0xce, 0xce,
			0xac, 0xc6, 0x08, 0x20, 0x82, 0x08, 0x20, 0x00,
			0x01, 0x00, 0xb1, 0x4d, 0x4a, 0x01, 0x00, 0x5c,
			0x5c, 0x49, 0xb8, num * 2, 0x00, 0x56,
		];

		match AsterixPacket::from_bytes((&packet_bytes, 0)) {
			Ok((_, packet)) => {
				if let AsterixMessage::Cat48(ref cat48) = packet.messages[0] {
					println!(
						"{:?}",
						cat48
							.warning_error_con_target_class
							.as_ref()
							.expect("code can be unwrapped")
							.codefxs[0]
							.code
					);
				}
			}
			Err(e) => println!("failed to decode: {e:?}"),
		}
	}
}

This outputs:

1: MultipathReply
2: ReplySidelobeInterrogationReception
3: SplitPlot
4: SecondTimeAroundReply
5: Angel
6: SlowMovingTarget
7: FixedPSRPlot
8: SlowPSRPlot
9: LowQualityPSRPlot
10: PhantomSSRPlot
11: NonMatchingMode3ACode
12: ModeCCodeModeSAbnormal
13: TargetInClutter
14: MaximumDopplerREsponseInZeroFilter
15: TransponderAnomalyDetected
16: DuplicatedOrIllegalModeSAircraftAddress
17: ModeSErrorCorrectionApplied
18: UndecodableModeCSCode
19: Birds
20: FlockOfBirds
21: Mode1PresentOriginalReply
22: Mode2PresentOriginalReply
23: PlotCausedByWindTurbine
24: Helicopter
25: MaxiumumNumberInterrogationsSurveillance
26: MaxiumumNumberInterrogationsBDS
27: BDSOverlayIncoherence
28: PotentialBDSSwapDetected
29: TrackUpdateZenithalGap
30: ModeSTrackReAquired
31: DuplicatedMode5PairNoPinDetected
32: WrongDFReplyFormatDetected
33: TransponderAnomalyMs
34: TransponderAnomalySI
35: PotentialICConflict
36: ICConflictDetectionPossible
37: failed to decode: Incomplete(NeedSize { bits: 14 })
38: failed to decode: Incomplete(NeedSize { bits: 14 })
39: failed to decode: Incomplete(NeedSize { bits: 14 })
40: failed to decode: Incomplete(NeedSize { bits: 14 })
41: failed to decode: Incomplete(NeedSize { bits: 14 })
42: failed to decode: Incomplete(NeedSize { bits: 14 })
43: failed to decode: Incomplete(NeedSize { bits: 14 })
44: failed to decode: Incomplete(NeedSize { bits: 14 })
45: failed to decode: Incomplete(NeedSize { bits: 14 })
46: failed to decode: Incomplete(NeedSize { bits: 14 })
47: failed to decode: Incomplete(NeedSize { bits: 14 })
48: failed to decode: Incomplete(NeedSize { bits: 14 })
49: failed to decode: Incomplete(NeedSize { bits: 14 })
50: failed to decode: Incomplete(NeedSize { bits: 14 })
51: failed to decode: Incomplete(NeedSize { bits: 14 })
52: failed to decode: Incomplete(NeedSize { bits: 14 })
53: failed to decode: Incomplete(NeedSize { bits: 14 })
54: failed to decode: Incomplete(NeedSize { bits: 14 })
55: failed to decode: Incomplete(NeedSize { bits: 14 })
56: failed to decode: Incomplete(NeedSize { bits: 14 })
57: failed to decode: Incomplete(NeedSize { bits: 14 })
58: failed to decode: Incomplete(NeedSize { bits: 14 })
59: failed to decode: Incomplete(NeedSize { bits: 14 })
60: failed to decode: Incomplete(NeedSize { bits: 14 })
61: failed to decode: Incomplete(NeedSize { bits: 14 })
62: failed to decode: Incomplete(NeedSize { bits: 14 })
63: failed to decode: Incomplete(NeedSize { bits: 14 })
64: failed to decode: Incomplete(NeedSize { bits: 14 })
65: failed to decode: Incomplete(NeedSize { bits: 14 })
66: failed to decode: Incomplete(NeedSize { bits: 14 })
67: failed to decode: Incomplete(NeedSize { bits: 14 })
68: failed to decode: Incomplete(NeedSize { bits: 14 })
69: failed to decode: Incomplete(NeedSize { bits: 14 })
70: failed to decode: Incomplete(NeedSize { bits: 14 })
71: failed to decode: Incomplete(NeedSize { bits: 14 })
72: failed to decode: Incomplete(NeedSize { bits: 14 })
73: failed to decode: Incomplete(NeedSize { bits: 14 })
74: failed to decode: Incomplete(NeedSize { bits: 14 })
75: failed to decode: Incomplete(NeedSize { bits: 14 })
76: failed to decode: Incomplete(NeedSize { bits: 14 })
77: failed to decode: Incomplete(NeedSize { bits: 14 })
78: failed to decode: Incomplete(NeedSize { bits: 14 })
79: failed to decode: Incomplete(NeedSize { bits: 14 })
80: failed to decode: Incomplete(NeedSize { bits: 14 })
81: failed to decode: Incomplete(NeedSize { bits: 14 })
82: failed to decode: Incomplete(NeedSize { bits: 14 })
83: failed to decode: Incomplete(NeedSize { bits: 14 })
84: failed to decode: Incomplete(NeedSize { bits: 14 })
85: failed to decode: Incomplete(NeedSize { bits: 14 })
86: failed to decode: Incomplete(NeedSize { bits: 14 })
87: failed to decode: Incomplete(NeedSize { bits: 14 })
88: failed to decode: Incomplete(NeedSize { bits: 14 })
89: failed to decode: Incomplete(NeedSize { bits: 14 })
90: failed to decode: Incomplete(NeedSize { bits: 14 })
91: failed to decode: Incomplete(NeedSize { bits: 14 })
92: failed to decode: Incomplete(NeedSize { bits: 14 })
93: failed to decode: Incomplete(NeedSize { bits: 14 })
94: failed to decode: Incomplete(NeedSize { bits: 14 })
95: failed to decode: Incomplete(NeedSize { bits: 14 })
96: failed to decode: Incomplete(NeedSize { bits: 14 })
97: failed to decode: Incomplete(NeedSize { bits: 14 })
98: failed to decode: Incomplete(NeedSize { bits: 14 })
99: failed to decode: Incomplete(NeedSize { bits: 14 })
100: failed to decode: Incomplete(NeedSize { bits: 14 })
101: failed to decode: Incomplete(NeedSize { bits: 14 })
102: failed to decode: Incomplete(NeedSize { bits: 14 })
103: failed to decode: Incomplete(NeedSize { bits: 14 })
104: failed to decode: Incomplete(NeedSize { bits: 14 })
105: failed to decode: Incomplete(NeedSize { bits: 14 })
106: failed to decode: Incomplete(NeedSize { bits: 14 })
107: failed to decode: Incomplete(NeedSize { bits: 14 })
108: failed to decode: Incomplete(NeedSize { bits: 14 })
109: failed to decode: Incomplete(NeedSize { bits: 14 })
110: failed to decode: Incomplete(NeedSize { bits: 14 })
111: failed to decode: Incomplete(NeedSize { bits: 14 })
112: failed to decode: Incomplete(NeedSize { bits: 14 })
113: failed to decode: Incomplete(NeedSize { bits: 14 })
114: failed to decode: Incomplete(NeedSize { bits: 14 })
115: failed to decode: Incomplete(NeedSize { bits: 14 })
116: failed to decode: Incomplete(NeedSize { bits: 14 })
117: failed to decode: Incomplete(NeedSize { bits: 14 })
118: failed to decode: Incomplete(NeedSize { bits: 14 })
119: failed to decode: Incomplete(NeedSize { bits: 14 })
120: failed to decode: Incomplete(NeedSize { bits: 14 })
121: failed to decode: Incomplete(NeedSize { bits: 14 })
122: failed to decode: Incomplete(NeedSize { bits: 14 })
123: failed to decode: Incomplete(NeedSize { bits: 14 })
124: failed to decode: Incomplete(NeedSize { bits: 14 })
125: failed to decode: Incomplete(NeedSize { bits: 14 })
126: failed to decode: Incomplete(NeedSize { bits: 14 })
127: failed to decode: Incomplete(NeedSize { bits: 14 })

I'm totally unsure which field requires 14 bits and if I'm doing something horribly wrong, but wireshark can decode those packets just fine so I think the issue lies somewhere else.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.