1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
//! MISB KLV metadata, the telemetry carried next to the video in STANAG 4609
//! full motion video from drones and other airborne sensors.
//!
//! | Standard | Module | What it is |
//! |---|---|---|
//! | SMPTE ST 336, MISB ST 0107 | [`klv`] | Keys, BER lengths, BER-OID tags, local sets, splitting a byte stream into packets |
//! | MISB ST 0601 | [`st0601`] | UAS Datalink Local Set: platform, sensor and frame-center position, footprint, timestamps, 143 tags |
//! | MISB ST 0102 | [`st0102`] | Security Local Set (classification markings), nested in ST 0601 tag 48 |
//! | MISB ST 0903 | [`st0903`] | Video Moving Target Indicator (VMTI): detections in the frame, nested in tag 74 or standalone |
//! | MISB ST 1201 | [`imapb`] | IMAPB floating point to integer mapping used by the newer tags |
//!
//! Decoding is zero-copy and does not allocate: a [`st0601::Packet`] borrows
//! the input and hands out typed values on demand. The checksum is verified
//! by [`st0601::Packet::parse`]; lengths are bounded by the input, so
//! corrupt or hostile data returns an [`Error`] instead of panicking.
//! Encoding (the `Builder`s) needs the `alloc` feature, which `std` (the
//! default) turns on.
//!
//! ```
//! # fn main() -> Result<(), misb::Error> {
//! use misb::st0601::{Builder, Packet, Tag};
//!
//! // Build a packet the way a payload computer would ...
//! let mut b = Builder::new(1_700_000_000_000_000);
//! b.text(Tag::MissionId, "TRAINING 4")?
//! .float(Tag::SensorLatitude, 38.8895)?
//! .float(Tag::SensorLongitude, -77.0353)?
//! .float(Tag::SensorTrueAltitude, 450.0)?
//! .float(Tag::PlatformHeadingAngle, 92.5)?;
//! let bytes = b.finish();
//!
//! // ... and read it back the way a ground station would.
//! let (packet, used) = Packet::parse(&bytes)?;
//! assert_eq!(used, bytes.len());
//! let pos = packet.sensor_position().unwrap();
//! assert!((pos.lat - 38.8895).abs() < 1e-6);
//! assert_eq!(packet.text(Tag::MissionId), Some("TRAINING 4"));
//! # Ok(()) }
//! ```
//!
//! Items that describe weapons (ST 0601 tags 60, 61, 62 and 140) are passed
//! through as raw bytes and never interpreted. This crate covers metadata
//! for situational awareness and interoperability only.
extern crate alloc;
extern crate std;
use fmt;
/// Everything that can go wrong while decoding or encoding.
/// A WGS84 position: latitude and longitude in degrees, height in metres
/// (above mean sea level or the ellipsoid, as the source tag says).