Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev/queuing overflow #36

Merged
merged 2 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "a653rs"
version = "0.4.1"
version = "0.5.0"
edition = "2021"
authors = ["Sven Friedrich <[email protected]>"]
license = "MIT OR Apache-2.0"
Expand Down
2 changes: 1 addition & 1 deletion examples/deps/dummy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl ApexQueuingPortP4 for DummyHypervisor {
_queuing_port_id: QueuingPortId,
_time_out: ApexSystemTime,
_message: &mut [ApexByte],
) -> Result<MessageSize, ErrorReturnCode> {
) -> Result<(MessageSize, QueueOverflow), ErrorReturnCode> {
todo!()
}

Expand Down
21 changes: 14 additions & 7 deletions src/apex/queuing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ pub mod basic {
/// The implementing Hypervisor may cast this to 32-bit if needed
pub type QueuingPortId = ApexLongInteger;

/// The queue overflowed on the sender side
pub type QueueOverflow = bool;

/// ARINC 653P1-5 3.6.2.2.3 states that [ErrorReturnCode::InvalidConfig] signals that the queue overflowed on the sender side
#[cfg_attr(not(feature = "bindings"), allow(dead_code))]
pub const QUEUE_OVERFLOW_ERROR: ErrorReturnCode = ErrorReturnCode::InvalidConfig;

#[derive(Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct QueuingPortStatus {
Expand Down Expand Up @@ -43,7 +50,7 @@ pub mod basic {
queuing_port_id: QueuingPortId,
time_out: ApexSystemTime,
message: &mut [ApexByte],
) -> Result<MessageSize, ErrorReturnCode>;
) -> Result<(MessageSize, QueueOverflow), ErrorReturnCode>;

fn get_queuing_port_status(
queuing_port_id: QueuingPortId,
Expand All @@ -66,7 +73,7 @@ pub mod abstraction {

use super::basic::{ApexQueuingPortP1, ApexQueuingPortP4};
// Reexport important basic-types for downstream-user
pub use super::basic::{QueuingPortId, QueuingPortStatus};
pub use super::basic::{QueueOverflow, QueuingPortId, QueuingPortStatus};
use crate::apex::types::basic::PortDirection;
use crate::prelude::*;

Expand Down Expand Up @@ -126,7 +133,7 @@ pub mod abstraction {
id: QueuingPortId,
timeout: SystemTime,
buffer: &mut [ApexByte],
) -> Result<&[ApexByte], Error>;
) -> Result<(&[ApexByte], QueueOverflow), Error>;
}

pub trait ApexQueuingPortP1Ext: ApexQueuingPortP1 + Sized {
Expand Down Expand Up @@ -159,9 +166,9 @@ pub mod abstraction {
id: QueuingPortId,
timeout: SystemTime,
buffer: &mut [ApexByte],
) -> Result<&[ApexByte], Error> {
let len = Q::receive_queuing_message(id, timeout.into(), buffer)? as usize;
Ok(&buffer[..len])
) -> Result<(&[ApexByte], QueueOverflow), Error> {
let (len, overflow) = Q::receive_queuing_message(id, timeout.into(), buffer)?;
Ok((&buffer[..(len as usize)], overflow))
}
}

Expand Down Expand Up @@ -283,7 +290,7 @@ pub mod abstraction {
&self,
buffer: &'a mut [ApexByte],
timeout: SystemTime,
) -> Result<&'a [ApexByte], Error> {
) -> Result<(&'a [ApexByte], QueueOverflow), Error> {
buffer.validate_read(MSG_SIZE)?;
unsafe { Q::queueing_port_receive_unchecked(self.id, timeout, buffer) }
}
Expand Down
Loading