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,
impl<N> BasicNode<N>where N: Node,
sourcepub 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>>
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 aCoreNode
)node_info
: The information that should be returned when handling node information requests
sourcepub fn run_per_second_tasks(
&mut self
) -> Result<(), <N::Transmitter as Transmitter<N::Clock>>::Error>
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
sourcepub fn set_mode(&mut self, mode: Mode)
pub fn set_mode(&mut self, mode: Mode)
Sets the operating mode that will be reported in the heartbeat messages
sourcepub fn set_health(&mut self, health: Health)
pub fn set_health(&mut self, health: Health)
Sets the health status that will be reported in the heartbeat messages
sourcepub fn set_status_code(&mut self, status: u8)
pub fn set_status_code(&mut self, status: u8)
Sets the vendor-specific status code that will be reported in the heartbeat messages
Trait Implementations§
source§impl<N> Node for BasicNode<N>where
N: Node,
impl<N> Node for BasicNode<N>where N: Node,
§type Transmitter = <N as Node>::Transmitter
type Transmitter = <N as Node>::Transmitter
The transmitter 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>,
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,
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,
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,
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,
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,
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,
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,
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,
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>
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>
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,
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>
fn flush( &mut self ) -> Result<(), <N::Transmitter as Transmitter<N::Clock>>::Error>
Attempts to flush all outgoing frames
source§fn transmitter(&self) -> &Self::Transmitter
fn transmitter(&self) -> &Self::Transmitter
Returns a reference to the transport transmitter
source§fn transmitter_mut(&mut self) -> &mut Self::Transmitter
fn transmitter_mut(&mut self) -> &mut Self::Transmitter
Returns a mutable reference to the transport transmitter
source§fn receiver_mut(&mut self) -> &mut Self::Receiver
fn receiver_mut(&mut self) -> &mut Self::Receiver
Returns a mutable reference to the transport receiver
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more