split up crate and create workspace

This commit is contained in:
Robin Müller 2022-06-16 15:45:22 +02:00
parent 31bf8ecdd9
commit 9b8c3b7f86
18 changed files with 220 additions and 58 deletions

174
Cargo.lock generated
View File

@ -65,6 +65,18 @@ version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "bitvec"
version = "0.22.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5237f00a8c86130a0cc317830e558b966dd7850d48a953d998c813f01a41b527"
dependencies = [
"funty",
"radium",
"tap",
"wyz",
]
[[package]] [[package]]
name = "bus" name = "bus"
version = "2.2.3" version = "2.2.3"
@ -164,6 +176,64 @@ dependencies = [
"lazy_static", "lazy_static",
] ]
[[package]]
name = "darling"
version = "0.14.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4529658bdda7fd6769b8614be250cdcfc3aeb0ee72fe66f9e41e5e5eb73eac02"
dependencies = [
"darling_core",
"darling_macro",
]
[[package]]
name = "darling_core"
version = "0.14.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "649c91bc01e8b1eac09fb91e8dbc7d517684ca6be8ebc75bb9cafc894f9fdb6f"
dependencies = [
"fnv",
"ident_case",
"proc-macro2",
"quote",
"strsim",
"syn",
]
[[package]]
name = "darling_macro"
version = "0.14.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ddfc69c5bfcbd2fc09a0f38451d2daf0e372e367986a83906d1b0dbc88134fb5"
dependencies = [
"darling_core",
"quote",
"syn",
]
[[package]]
name = "deku"
version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "868ccf23869582b2d79279e402db457fe341da24a0c5a8927c6154a5b4733dc3"
dependencies = [
"bitvec",
"deku_derive",
]
[[package]]
name = "deku_derive"
version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4dfb4274ccd1c87a598e98b398b4b630aecb2e8a32fd7c88ffa190fb73870f72"
dependencies = [
"darling",
"proc-macro-crate",
"proc-macro2",
"quote",
"syn",
]
[[package]] [[package]]
name = "embedded-hal" name = "embedded-hal"
version = "0.2.7" version = "0.2.7"
@ -174,6 +244,32 @@ dependencies = [
"void", "void",
] ]
[[package]]
name = "fnv"
version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
[[package]]
name = "fsrc-core"
version = "0.1.0"
dependencies = [
"bus",
"deku",
"heapless",
"num",
"postcard",
"serde",
"thiserror",
"zerocopy",
]
[[package]]
name = "funty"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1847abb9cb65d566acd5942e94aea9c8f547ad02c98e1649326fc0e8910b8b1e"
[[package]] [[package]]
name = "hash32" name = "hash32"
version = "0.2.1" version = "0.2.1"
@ -185,9 +281,9 @@ dependencies = [
[[package]] [[package]]
name = "heapless" name = "heapless"
version = "0.7.13" version = "0.7.14"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a08e755adbc0ad283725b29f4a4883deee15336f372d5f61fae59efec40f983" checksum = "065681e99f9ef7e0e813702a0326aedbcbbde7db5e55f097aedd1bf50b9dca43"
dependencies = [ dependencies = [
"atomic-polyfill", "atomic-polyfill",
"hash32", "hash32",
@ -207,18 +303,10 @@ dependencies = [
] ]
[[package]] [[package]]
name = "launchpad" name = "ident_case"
version = "0.1.0" version = "1.0.1"
dependencies = [ source = "registry+https://github.com/rust-lang/crates.io-index"
"bus", checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
"crc",
"heapless",
"num",
"postcard",
"serde",
"thiserror",
"zerocopy",
]
[[package]] [[package]]
name = "lazy_static" name = "lazy_static"
@ -386,6 +474,16 @@ version = "0.1.5-pre"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7c68cb38ed13fd7bc9dd5db8f165b7c8d9c1a315104083a2b10f11354c2af97f" checksum = "7c68cb38ed13fd7bc9dd5db8f165b7c8d9c1a315104083a2b10f11354c2af97f"
[[package]]
name = "proc-macro-crate"
version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e17d47ce914bf4de440332250b0edd23ce48c005f59fab39d3335866b114f11a"
dependencies = [
"thiserror",
"toml",
]
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.39" version = "1.0.39"
@ -404,6 +502,12 @@ dependencies = [
"proc-macro2", "proc-macro2",
] ]
[[package]]
name = "radium"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "643f8f41a8ebc4c5dc4515c82bb8abd397b527fc20fd681b7c011c2aee5d44fb"
[[package]] [[package]]
name = "redox_syscall" name = "redox_syscall"
version = "0.1.57" version = "0.1.57"
@ -519,6 +623,18 @@ version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83" checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83"
[[package]]
name = "spacepackets"
version = "0.1.0"
dependencies = [
"crc",
"deku",
"num",
"postcard",
"serde",
"zerocopy",
]
[[package]] [[package]]
name = "spin" name = "spin"
version = "0.9.3" version = "0.9.3"
@ -534,6 +650,12 @@ version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
[[package]]
name = "strsim"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
[[package]] [[package]]
name = "syn" name = "syn"
version = "1.0.96" version = "1.0.96"
@ -557,6 +679,12 @@ dependencies = [
"unicode-xid", "unicode-xid",
] ]
[[package]]
name = "tap"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369"
[[package]] [[package]]
name = "thiserror" name = "thiserror"
version = "1.0.31" version = "1.0.31"
@ -577,6 +705,15 @@ dependencies = [
"syn", "syn",
] ]
[[package]]
name = "toml"
version = "0.5.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7"
dependencies = [
"serde",
]
[[package]] [[package]]
name = "unicode-ident" name = "unicode-ident"
version = "1.0.1" version = "1.0.1"
@ -632,6 +769,15 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "wyz"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "129e027ad65ce1453680623c3fb5163cbf7107bfe1aa32257e7d0e63f9ced188"
dependencies = [
"tap",
]
[[package]] [[package]]
name = "zerocopy" name = "zerocopy"
version = "0.6.1" version = "0.6.1"

View File

@ -1,16 +1,6 @@
[package] [workspace]
name = "launchpad"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html members = [
"fsrc-core",
[dependencies] "spacepackets",
thiserror = "1.0" ]
bus = "2.2.3"
num = "0.4"
heapless = "0.7.13"
postcard = { version = "0.7.3", features = ["use-std"] }
serde = "1.0.137"
zerocopy = "0.6.1"
crc = "3.0.0"

16
fsrc-core/Cargo.toml Normal file
View File

@ -0,0 +1,16 @@
[package]
name = "fsrc-core"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
thiserror = "1.0"
bus = "2.2.3"
num = "0.4"
heapless = "0.7.13"
postcard = { version = "0.7.3", features = ["use-std"] }
serde = "1.0.137"
deku = "0.13"
zerocopy = "0.6.1"

View File

@ -1,5 +1,5 @@
//! [Event][crate::core::events::Event] management and forwarding //! [Event][crate::core::events::Event] management and forwarding
use crate::core::events::{Event, EventRaw, GroupId}; use crate::events::{Event, EventRaw, GroupId};
use std::collections::HashMap; use std::collections::HashMap;
#[derive(PartialEq, Eq, Hash, Copy, Clone)] #[derive(PartialEq, Eq, Hash, Copy, Clone)]
@ -115,8 +115,8 @@ impl<E> EventManager<E> {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::{EventListener, HandlerResult, ReceivesAllEvent}; use super::{EventListener, HandlerResult, ReceivesAllEvent};
use crate::core::event_man::EventManager; use crate::event_man::EventManager;
use crate::core::events::{Event, Severity}; use crate::events::{Event, Severity};
use std::sync::mpsc::{channel, Receiver, SendError, Sender}; use std::sync::mpsc::{channel, Receiver, SendError, Sender};
use std::thread; use std::thread;
use std::time::Duration; use std::time::Duration;

View File

@ -95,7 +95,7 @@ impl TryFrom<EventRaw> for Event {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::Event; use super::Event;
use crate::core::events::Severity; use crate::events::Severity;
#[test] #[test]
fn test_events() { fn test_events() {

View File

@ -10,7 +10,7 @@
//! ``` //! ```
//! use std::any::Any; //! use std::any::Any;
//! use std::error::Error; //! use std::error::Error;
//! use launchpad::core::objects::{ManagedSystemObject, ObjectId, ObjectManager, SystemObject}; //! use fsrc_core::objects::{ManagedSystemObject, ObjectId, ObjectManager, SystemObject};
//! //!
//! struct ExampleSysObj { //! struct ExampleSysObj {
//! id: ObjectId, //! id: ObjectId,
@ -125,7 +125,7 @@ impl ObjectManager {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::core::objects::{ManagedSystemObject, ObjectId, ObjectManager, SystemObject}; use crate::objects::{ManagedSystemObject, ObjectId, ObjectManager, SystemObject};
use std::any::Any; use std::any::Any;
use std::error::Error; use std::error::Error;
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};

View File

@ -13,7 +13,7 @@
//! # Example //! # Example
//! //!
//! ``` //! ```
//! use launchpad::core::pool::{LocalPool, PoolCfg}; //! use fsrc_core::pool::{LocalPool, PoolCfg};
//! //!
//! // 4 buckets of 4 bytes, 2 of 8 bytes and 1 of 16 bytes //! // 4 buckets of 4 bytes, 2 of 8 bytes and 1 of 16 bytes
//! let pool_cfg = PoolCfg::new(vec![(4, 4), (2, 8), (1, 16)]); //! let pool_cfg = PoolCfg::new(vec![(4, 4), (2, 8), (1, 16)]);
@ -308,7 +308,7 @@ impl LocalPool {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::core::pool::{LocalPool, PoolCfg, StoreAddr, StoreError, StoreIdError}; use crate::pool::{LocalPool, PoolCfg, StoreAddr, StoreError, StoreIdError};
#[test] #[test]
fn test_cfg() { fn test_cfg() {

14
spacepackets/Cargo.toml Normal file
View File

@ -0,0 +1,14 @@
[package]
name = "spacepackets"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
num = "0.4"
postcard = { version = "0.7.3", features = ["use-std"] }
serde = "1.0.137"
deku = "0.13"
zerocopy = "0.6.1"
crc = "3.0.0"

View File

@ -1,4 +1,4 @@
use crate::sp::CcsdsPacket; use crate::CcsdsPacket;
pub trait PusPacket: CcsdsPacket { pub trait PusPacket: CcsdsPacket {
fn service(&self) -> u8; fn service(&self) -> u8;

View File

@ -234,8 +234,8 @@ pub trait CcsdsPrimaryHeader {
} }
pub mod srd { pub mod srd {
use crate::sp::{ use crate::{
self, CcsdsPacket, CcsdsPrimaryHeader, PacketId, PacketSequenceCtrl, PacketType, CcsdsPacket, CcsdsPrimaryHeader, PacketId, PacketSequenceCtrl, PacketType,
SequenceFlags, SequenceFlags,
}; };
@ -327,12 +327,12 @@ pub mod srd {
} }
} }
sph_from_other!(SpHeader, sp::zc::SpHeader); sph_from_other!(SpHeader, crate::zc::SpHeader);
} }
pub mod zc { pub mod zc {
use crate::sp::{ use crate::{
self, CcsdsPacket, CcsdsPrimaryHeader, PacketId, PacketSequenceCtrl, VERSION_MASK, CcsdsPacket, CcsdsPrimaryHeader, PacketId, PacketSequenceCtrl, VERSION_MASK,
}; };
use zerocopy::byteorder::NetworkEndian; use zerocopy::byteorder::NetworkEndian;
use zerocopy::{AsBytes, FromBytes, Unaligned, U16}; use zerocopy::{AsBytes, FromBytes, Unaligned, U16};
@ -410,14 +410,13 @@ pub mod zc {
} }
} }
sph_from_other!(SpHeader, sp::srd::SpHeader); sph_from_other!(SpHeader, crate::srd::SpHeader);
} }
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::sp; use crate::srd::SpHeader;
use crate::sp::srd::SpHeader; use crate::{zc, CcsdsPacket, PacketId, PacketSequenceCtrl, PacketType, SequenceFlags};
use crate::sp::{zc, CcsdsPacket, PacketId, PacketSequenceCtrl, PacketType, SequenceFlags};
use postcard::{from_bytes, to_stdvec}; use postcard::{from_bytes, to_stdvec};
#[test] #[test]
@ -495,7 +494,7 @@ mod tests {
let sp_header = SpHeader::tc(0x7FF, num::pow(2, 14) - 1).expect("Error creating SP header"); let sp_header = SpHeader::tc(0x7FF, num::pow(2, 14) - 1).expect("Error creating SP header");
assert_eq!(sp_header.packet_id.ptype, PacketType::Tc); assert_eq!(sp_header.packet_id.ptype, PacketType::Tc);
assert!(sp_header.is_tc()); assert!(sp_header.is_tc());
let sp_header_zc = sp::zc::SpHeader::from(sp_header); let sp_header_zc = zc::SpHeader::from(sp_header);
let slice = sp_header_zc.as_bytes(); let slice = sp_header_zc.as_bytes();
assert_eq!(slice.len(), 6); assert_eq!(slice.len(), 6);
assert_eq!(slice[0], 0x1F); assert_eq!(slice[0], 0x1F);

View File

@ -25,11 +25,10 @@ pub mod zc {
} }
pub mod srd { pub mod srd {
use crate::sp; use crate::ecss::PusPacket;
use crate::sp::ecss::PusPacket; use crate::srd::SpHeader;
use crate::sp::srd::SpHeader; use crate::tc::{PusVersion, CRC_CCITT_FALSE};
use crate::sp::tc::{PusVersion, CRC_CCITT_FALSE}; use crate::{CcsdsPacket, PacketError, PacketId, PacketSequenceCtrl, PacketType};
use crate::sp::{CcsdsPacket, PacketError, PacketId, PacketSequenceCtrl, PacketType};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(PartialEq, Copy, Clone, Serialize, Deserialize)] #[derive(PartialEq, Copy, Clone, Serialize, Deserialize)]
@ -80,7 +79,7 @@ pub mod srd {
} }
pub fn write(&mut self, mut slice: impl AsMut<[u8]>) -> Result<(), PacketError> { pub fn write(&mut self, mut slice: impl AsMut<[u8]>) -> Result<(), PacketError> {
let sph_zc = sp::zc::SpHeader::from(self.sph); let sph_zc = crate::zc::SpHeader::from(self.sph);
if slice.as_mut().len() < 6 { if slice.as_mut().len() < 6 {
return Err(PacketError::ToBytesSliceTooSmall(6)); return Err(PacketError::ToBytesSliceTooSmall(6));
} }
@ -150,8 +149,8 @@ pub mod srd {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::sp::srd::SpHeader; use crate::srd::SpHeader;
use crate::sp::tc::srd::PusTc; use crate::tc::srd::PusTc;
use postcard::to_stdvec; use postcard::to_stdvec;
#[test] #[test]

View File

@ -1,2 +0,0 @@
pub mod core;
pub mod sp;