Skip to content

Commit d726369

Browse files
authored
Merge pull request #11 from wcampbell0x2a/use-deku
Use deku library
2 parents 650835e + 90ceffc commit d726369

6 files changed

Lines changed: 211 additions & 274 deletions

File tree

Cargo.lock

Lines changed: 111 additions & 74 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ccsds_spacepacket"
3-
version = "0.1.0"
3+
version = "0.2.0"
44
authors = ["Adrian Edwards <17362949+MoralCode@users.noreply.github.com>"]
55
edition = "2018"
66
license = "Apache-2.0"
@@ -17,5 +17,4 @@ exclude = [
1717
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1818

1919
[dependencies]
20-
byteorder = "1.2.7"
21-
failure = "0.1.3"
20+
deku = "0.12"

README.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,32 @@ The Secondary Header and Payload make up the "User Data Field" and at least one
2121
## What this library does
2222
This library attempts to implement a general-purpose parser for Space Packets that can interperet both the generic aspects of the space packet protocol (i.e. the Primary Header) in addition to any custom fields supplied within the Secondary Headers.
2323

24-
This Secondary Header parsing is accomplished by allowing users of the library to pass in a parser that can interperet the Secondary Header as specified by their project or organisation.
24+
This Secondary Header parsing is accomplished by allowing users of the library to pass in a parser that can interperet the Secondary Header as specified by their project or organisation.
25+
26+
27+
## Current status
28+
Currently this library just implements Primary Header parsing, but expanding it to be able to deal with a complete, generic spacepacket (think of generics in programming) with user defined custom secondary headers is one of the projects main goals.
29+
30+
31+
## Usage
32+
33+
```rust
34+
// say you have some bytes you want to turn into a PrimaryHeader
35+
let raw = b"\x00\x00\xc0\x00\x00\x40\xff\xff";
36+
37+
let expected = PrimaryHeader {
38+
version: 0,
39+
packet_type: types::PacketType::Data,
40+
sec_header_flag: types::SecondaryHeaderFlag::NotPresent,
41+
app_proc_id: 0,
42+
sequence_flags: types::SeqFlag::Unsegmented,
43+
sequence_count: 0,
44+
data_length: 64,
45+
};
46+
47+
// do the parsing and save the parsed header and any remaining bytes
48+
let (rest, parsed) = PrimaryHeader::from_bytes((raw, 0)).expect("failed to parse header");
49+
50+
assert_eq!(parsed, expected);
51+
assert_eq!(rest.0, [255,255])
52+
```

src/lib.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,3 @@
2020
mod primaryheader;
2121
pub use primaryheader::PrimaryHeader;
2222
pub mod types;
23-
24-
use failure::Error;
25-
26-
pub type ParseResult<T> = Result<T, Error>;

0 commit comments

Comments
 (0)