make spacepackets no_std

This commit is contained in:
Robin Müller 2022-06-18 21:50:22 +02:00
parent ac7a295c37
commit b938eff9cf
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
9 changed files with 60 additions and 160 deletions

View File

@ -0,0 +1,18 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Examples" type="CargoCommandRunConfiguration" factoryName="Cargo Command">
<option name="command" value="run --example test" />
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
<option name="channel" value="DEFAULT" />
<option name="requiredFeatures" value="true" />
<option name="allFeatures" value="false" />
<option name="emulateTerminal" value="false" />
<option name="withSudo" value="false" />
<option name="backtrace" value="SHORT" />
<envs />
<option name="isRedirectInput" value="false" />
<option name="redirectInputPath" value="" />
<method v="2">
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
</method>
</configuration>
</component>

View File

@ -7,7 +7,6 @@
<option name="allFeatures" value="false" />
<option name="emulateTerminal" value="false" />
<option name="withSudo" value="false" />
<option name="buildTarget" value="REMOTE" />
<option name="backtrace" value="SHORT" />
<envs />
<option name="isRedirectInput" value="false" />

140
Cargo.lock generated
View File

@ -65,18 +65,6 @@ version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
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]]
name = "bus"
version = "2.2.3"
@ -176,64 +164,6 @@ dependencies = [
"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]]
name = "delegate"
version = "0.7.0"
@ -255,32 +185,15 @@ dependencies = [
"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]]
name = "hash32"
version = "0.2.1"
@ -313,12 +226,6 @@ dependencies = [
"libc",
]
[[package]]
name = "ident_case"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
[[package]]
name = "lazy_static"
version = "1.4.0"
@ -485,16 +392,6 @@ version = "0.1.5-pre"
source = "registry+https://github.com/rust-lang/crates.io-index"
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]]
name = "proc-macro2"
version = "1.0.39"
@ -513,12 +410,6 @@ dependencies = [
"proc-macro2",
]
[[package]]
name = "radium"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "643f8f41a8ebc4c5dc4515c82bb8abd397b527fc20fd681b7c011c2aee5d44fb"
[[package]]
name = "redox_syscall"
version = "0.1.57"
@ -640,6 +531,7 @@ version = "0.1.0"
dependencies = [
"crc",
"delegate",
"heapless",
"num",
"postcard",
"serde",
@ -661,12 +553,6 @@ version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
[[package]]
name = "strsim"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
[[package]]
name = "syn"
version = "1.0.96"
@ -690,12 +576,6 @@ dependencies = [
"unicode-xid",
]
[[package]]
name = "tap"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369"
[[package]]
name = "thiserror"
version = "1.0.31"
@ -716,15 +596,6 @@ dependencies = [
"syn",
]
[[package]]
name = "toml"
version = "0.5.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7"
dependencies = [
"serde",
]
[[package]]
name = "unicode-ident"
version = "1.0.1"
@ -780,15 +651,6 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "wyz"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "129e027ad65ce1453680623c3fb5163cbf7107bfe1aa32257e7d0e63f9ced188"
dependencies = [
"tap",
]
[[package]]
name = "zerocopy"
version = "0.6.1"

View File

@ -9,8 +9,3 @@ edition = "2021"
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

@ -2,13 +2,33 @@
name = "spacepackets"
version = "0.1.0"
edition = "2021"
authors = ["Robin Mueller <muellerr@irs.uni-stuttgart.de>"]
description = "Generic implementations for various CCSDS and ECSS packet standards"
homepage = "https://egit.irs.uni-stuttgart.de/rust/spacepackets"
repository = "https://egit.irs.uni-stuttgart.de/rust/spacepackets"
license = "Apache-2.0"
keywords = ["no-std", "space", "packets", "ccsds", "ecss"]
categories = ["aerospace", "aerospace::space-protocols", "no-std", "hardware-support", "embedded"]
# 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"
zerocopy = "0.6.1"
crc = "3.0.0"
delegate = "0.7.0"
[dependencies.heapless]
version = "0.7.14"
optional = true
[dev-dependencies]
[dev-dependencies.postcard]
version = "0.7.3"
features = ["use-std"]
[features]
default = ["heapless", "alloc"]
alloc = ["serde/alloc"]

View File

@ -1,7 +1,7 @@
use crate::{CcsdsPacket, PacketError};
use crc::{Crc, CRC_16_IBM_3740};
use serde::{Deserialize, Serialize};
use std::mem::size_of;
use core::mem::size_of;
/// CRC algorithm used by the PUS standard
pub const CRC_CCITT_FALSE: Crc<u16> = Crc::<u16>::new(&CRC_16_IBM_3740);

View File

@ -1,4 +1,7 @@
//! # Space related components including CCSDS and ECSS packet standards
#![no_std]
extern crate alloc;
use crate::ecss::CCSDS_HEADER_LEN;
use serde::{Deserialize, Serialize};
@ -237,7 +240,7 @@ pub trait CcsdsPrimaryHeader {
) -> Self;
}
pub mod srd {
pub mod ser {
use crate::{
CcsdsPacket, CcsdsPrimaryHeader, PacketId, PacketSequenceCtrl, PacketType, SequenceFlags,
};
@ -412,12 +415,13 @@ pub mod zc {
}
}
sph_from_other!(SpHeader, crate::srd::SpHeader);
sph_from_other!(SpHeader, crate::ser::SpHeader);
}
#[cfg(test)]
mod tests {
use crate::srd::SpHeader;
use alloc::vec;
use crate::ser::SpHeader;
use crate::{
packet_type_in_raw_packet_id, zc, CcsdsPacket, CcsdsPrimaryHeader, PacketId,
PacketSequenceCtrl, PacketType, SequenceFlags,

View File

@ -1,6 +1,6 @@
use crate::ecss::PusVersion;
use crate::CCSDS_HEADER_LEN;
use std::mem::size_of;
use core::mem::size_of;
type CrcType = u16;
@ -32,7 +32,7 @@ pub trait PusTcSecondaryHeader {
pub mod zc {
use crate::ecss::{PusError, PusVersion};
use crate::tc::{srd, PusTcSecondaryHeader};
use crate::tc::{ser, PusTcSecondaryHeader};
use zerocopy::{AsBytes, FromBytes, NetworkEndian, Unaligned, U16};
#[derive(FromBytes, AsBytes, Unaligned)]
@ -44,9 +44,9 @@ pub mod zc {
source_id: U16<NetworkEndian>,
}
impl TryFrom<srd::PusTcDataFieldHeader> for PusTcDataFieldHeader {
impl TryFrom<ser::PusTcDataFieldHeader> for PusTcDataFieldHeader {
type Error = PusError;
fn try_from(value: srd::PusTcDataFieldHeader) -> Result<Self, Self::Error> {
fn try_from(value: ser::PusTcDataFieldHeader) -> Result<Self, Self::Error> {
if value.version != PusVersion::PusC {
return Err(PusError::VersionNotSupported(value.version));
}
@ -88,9 +88,10 @@ pub mod zc {
}
}
pub mod srd {
pub mod ser {
use alloc::vec::Vec;
use crate::ecss::{PusError, PusPacket, PusVersion, CRC_CCITT_FALSE};
use crate::srd::SpHeader;
use crate::ser::SpHeader;
use crate::tc::{
PusTcSecondaryHeader, ACK_ALL, PUC_TC_SECONDARY_HEADER_LEN,
PUS_TC_MIN_LEN_WITHOUT_APP_DATA, PUS_VERSION,
@ -98,7 +99,7 @@ pub mod srd {
use crate::{zc, CcsdsPacket, PacketError, PacketId, PacketSequenceCtrl, PacketType};
use delegate::delegate;
use serde::{Deserialize, Serialize};
use std::mem::size_of;
use core::mem::size_of;
use zerocopy::AsBytes;
#[derive(PartialEq, Copy, Clone, Serialize, Deserialize)]
@ -392,9 +393,10 @@ pub mod srd {
#[cfg(test)]
mod tests {
use alloc::vec::Vec;
use crate::ecss::PusPacket;
use crate::srd::SpHeader;
use crate::tc::srd::PusTc;
use crate::ser::SpHeader;
use crate::tc::ser::PusTc;
use crate::tc::PusTcSecondaryHeader;
use crate::tc::ACK_ALL;
use crate::{CcsdsPacket, PacketType};