Struct canadensis::node::BasicNode

source ·
pub struct BasicNode<N>where
    N: Node,{ /* private fields */ }
Expand description

A node that provides all basic application-layer functionality

This node performs the following functions:

  • Sending a uavcan.node.Heartbeat every second
  • Responding to uavcan.node.GetInfo requests
  • Sending a uavcan.node.port.List message every 10 seconds

A BasicNode uses up two publisher slots in the underlying node.

The underlying node type N is usually a CoreNode.

Implementations§

source§

impl<N> BasicNode<N>where N: Node,

source

pub fn new( node: N, node_info: GetInfoResponse ) -> Result<Self, NodeError<StartSendError<<N::Transmitter as Transmitter<N::Clock>>::Error>, <N::Receiver as Receiver<N::Clock>>::Error>>

Creates a new basic node

  • node: The underlying node (this is usually a CoreNode)
  • node_info: The information that should be returned when handling node information requests
source

pub fn run_per_second_tasks( &mut self ) -> Result<(), <N::Transmitter as Transmitter<N::Clock>>::Error>

This function must be called once per second to send heartbeat and port list messages

source

pub fn set_mode(&mut self, mode: Mode)

Sets the operating mode that will be reported in the heartbeat messages

source

pub fn set_health(&mut self, health: Health)

Sets the health status that will be reported in the heartbeat messages

source

pub fn set_status_code(&mut self, status: u8)

Sets the vendor-specific status code that will be reported in the heartbeat messages

source

pub fn node(&self) -> &N

Returns a reference to the enclosed node

source

pub fn node_mut(&mut self) -> &mut N

Returns a mutable reference to the enclosed node

Trait Implementations§

source§

impl<N> Node for BasicNode<N>where N: Node,

§

type Clock = <N as Node>::Clock

The clock that this node uses
§

type Instant = <N as Node>::Instant

The instant that this node’s clock produces
§

type Transport = <N as Node>::Transport

The transport that this node uses
§

type Transmitter = <N as Node>::Transmitter

The transmitter that this node uses
§

type Receiver = <N as Node>::Receiver

The receiver that this node uses
source§

fn receive<H>( &mut self, handler: &mut H ) -> Result<(), <N::Receiver as Receiver<N::Clock>>::Error>where H: TransferHandler<Self::Instant, Self::Transport>,

Receives any available incoming frames and attempts ot reassemble them into a transfer Read more
source§

fn start_publishing<T>( &mut self, subject: SubjectId, timeout: <<N::Clock as Clock>::Instant as Instant>::Duration, priority: <Self::Transport as Transport>::Priority ) -> Result<PublishToken<T>, StartSendError<<N::Transmitter as Transmitter<N::Clock>>::Error>>where T: Message,

Starts publishing messages on subject Read more
source§

fn stop_publishing<T>(&mut self, token: PublishToken<T>)where T: Message,

Stops publishing messages on a subject
source§

fn publish<T>( &mut self, token: &PublishToken<T>, payload: &T ) -> Result<(), <N::Transmitter as Transmitter<N::Clock>>::Error>where T: Message + Serialize,

Publishes a message Read more
source§

fn publish_loopback<T>( &mut self, token: &PublishToken<T>, payload: &T ) -> Result<(), <Self::Transmitter as Transmitter<Self::Clock>>::Error>where T: Message + Serialize,

Publishes a message with the loopback flag set to true Read more
source§

fn start_sending_requests<T>( &mut self, service: ServiceId, receive_timeout: <<N::Clock as Clock>::Instant as Instant>::Duration, response_payload_size_max: usize, priority: <Self::Transport as Transport>::Priority ) -> Result<ServiceToken<T>, StartSendError<<N::Receiver as Receiver<N::Clock>>::Error>>where T: Request,

Sets up to send requests for a service Read more
source§

fn stop_sending_requests<T>(&mut self, token: ServiceToken<T>)where T: Request,

Stops sending requests for a service
source§

fn send_request<T>( &mut self, token: &ServiceToken<T>, payload: &T, destination: <Self::Transport as Transport>::NodeId ) -> Result<<Self::Transport as Transport>::TransferId, <N::Transmitter as Transmitter<N::Clock>>::Error>where T: Request + Serialize,

Sends a service request to another node Read more
source§

fn send_request_loopback<T>( &mut self, token: &ServiceToken<T>, payload: &T, destination: <Self::Transport as Transport>::NodeId ) -> Result<<Self::Transport as Transport>::TransferId, <Self::Transmitter as Transmitter<Self::Clock>>::Error>where T: Request + Serialize,

Sends a service request to another node, with the loopback flag set to true Read more
source§

fn subscribe_message( &mut self, subject: SubjectId, payload_size_max: usize, timeout: <<N::Clock as Clock>::Instant as Instant>::Duration ) -> Result<(), <N::Receiver as Receiver<N::Clock>>::Error>

Subscribes to messages on a topic
source§

fn subscribe_request( &mut self, service: ServiceId, payload_size_max: usize, timeout: <<N::Clock as Clock>::Instant as Instant>::Duration ) -> Result<(), <N::Receiver as Receiver<N::Clock>>::Error>

Subscribes to requests for a service
source§

fn send_response<T>( &mut self, token: ResponseToken<Self::Transport>, timeout: <<N::Clock as Clock>::Instant as Instant>::Duration, payload: &T ) -> Result<(), <N::Transmitter as Transmitter<N::Clock>>::Error>where T: Response + Serialize,

Responds to a service request Read more
source§

fn flush( &mut self ) -> Result<(), <N::Transmitter as Transmitter<N::Clock>>::Error>

Attempts to flush all outgoing frames
source§

fn clock(&self) -> &Self::Clock

Returns a reference to the enclosed clock
source§

fn clock_mut(&mut self) -> &mut Self::Clock

Returns a mutable reference to the enclosed clock
source§

fn transmitter(&self) -> &Self::Transmitter

Returns a reference to the transport transmitter
source§

fn transmitter_mut(&mut self) -> &mut Self::Transmitter

Returns a mutable reference to the transport transmitter
source§

fn receiver(&self) -> &Self::Receiver

Returns a reference to the transport receiver
source§

fn receiver_mut(&mut self) -> &mut Self::Receiver

Returns a mutable reference to the transport receiver
source§

fn node_id(&self) -> <Self::Transport as Transport>::NodeId

Returns the identifier of this node

Auto Trait Implementations§

§

impl<N> RefUnwindSafe for BasicNode<N>where N: RefUnwindSafe,

§

impl<N> Send for BasicNode<N>where N: Send,

§

impl<N> Sync for BasicNode<N>where N: Sync,

§

impl<N> Unpin for BasicNode<N>where N: Unpin,

§

impl<N> UnwindSafe for BasicNode<N>where N: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.