Руслан Урядинский / libuavcan

Dependents:   UAVCAN UAVCAN_Subscriber

Embed: (wiki syntax)

« Back to documentation index

Node Class Reference

Node Class Reference

Wrapper for uavcan::Node with some additional convenience functions. More...

#include <helpers.hpp>

Inherits NodeBase< uavcan::Node< NodeMemPoolSize > >.

Public Member Functions

 Node (uavcan::ICanDriver &can_driver, uavcan::ISystemClock &clock)
 Simple forwarding constructor, compatible with uavcan::Node.
 Node (DriverPackPtr driver_pack)
 Takes ownership of the driver container via the shared pointer.
SubscriberPtr< DataType > makeSubscriber (const typename uavcan::Subscriber< DataType >::Callback &cb)
 Allocates uavcan::Subscriber in the heap using shared pointer.
PublisherPtr< DataType > makePublisher (uavcan::MonotonicDuration tx_timeout=uavcan::Publisher< DataType >::getDefaultTxTimeout())
 Allocates uavcan::Publisher in the heap using shared pointer.
ServiceServerPtr< DataType > makeServiceServer (const typename uavcan::ServiceServer< DataType >::Callback &cb)
 Allocates uavcan::ServiceServer in the heap using shared pointer.
ServiceClientPtr< DataType > makeServiceClient (const typename uavcan::ServiceClient< DataType >::Callback &cb)
 Allocates uavcan::ServiceClient in the heap using shared pointer.
BlockingServiceClientPtr
< DataType > 
makeBlockingServiceClient ()
 Allocates uavcan_linux::BlockingServiceClient in the heap using shared pointer.
TimerPtr makeTimer (uavcan::MonotonicTime deadline, const typename uavcan::Timer::Callback &cb)
 Allocates uavcan::Timer in the heap using shared pointer.
TimerPtr makeTimer (uavcan::MonotonicDuration period, const typename uavcan::Timer::Callback &cb)
 Allocates uavcan::Timer in the heap using shared pointer.
int spin (MonotonicTime deadline)
 Same as spin(MonotonicDuration), but the deadline is specified as an absolute time value rather than duration.
int spin (MonotonicDuration duration)
 Runs the node.
int spinOnce ()
 This method is designed for non-blocking applications.
int start (const TransferPriority node_status_transfer_priority=TransferPriority::Default)
 Starts the node and publishes uavcan.protocol.NodeStatus immediately.
const
NodeStatusProvider::NodeName & 
getName () const
 Gets/sets the node name, e.g.
void setHealthOk ()
 Node health code helpers.
void setModeOperational ()
 Node mode code helpers.
void setVendorSpecificStatusCode (NodeStatusProvider::VendorSpecificStatusCode code)
 Updates the vendor-specific status code.
void setSoftwareVersion (const protocol::SoftwareVersion &version)
 Gets/sets the node version information.
void setRestartRequestHandler (IRestartRequestHandler *handler)
 Restart handler can be installed to handle external node restart requests (highly recommended).
Logger & getLogger ()
 Use this method to configure logging.
NodeID getNodeID () const
 Returns the Node ID of this node.
bool setNodeID (NodeID nid)
 Sets the Node ID of this node.
bool isPassiveMode () const
 Whether the node is in passive mode, i.e.
int injectTxFrame (const CanFrame &frame, MonotonicTime tx_deadline, uint8_t iface_mask, CanTxQueue::Qos qos=CanTxQueue::Volatile, CanIOFlags flags=0)
 This method allows to directly transmit a raw CAN frame circumventing the whole UAVCAN stack.
void removeRxFrameListener ()
 The IRxFrameListener interface allows one to monitor all incoming CAN frames.
void logDebug (const char *source, const char *format, Args...args)
 Node logging.

Detailed Description

Wrapper for uavcan::Node with some additional convenience functions.

Note that this wrapper adds stderr log sink to uavcan::Logger, which can be removed if needed. Do not instantiate this class directly; instead use the factory functions defined below.

Definition at line 308 of file drivers/linux/include/uavcan_linux/helpers.hpp.


Constructor & Destructor Documentation

Node ( uavcan::ICanDriver can_driver,
uavcan::ISystemClock clock 
)

Simple forwarding constructor, compatible with uavcan::Node.

Reimplemented from Node< NodeMemPoolSize >.

Definition at line 318 of file drivers/linux/include/uavcan_linux/helpers.hpp.

Node ( DriverPackPtr  driver_pack ) [explicit]

Takes ownership of the driver container via the shared pointer.

Definition at line 327 of file drivers/linux/include/uavcan_linux/helpers.hpp.


Member Function Documentation

Logger& getLogger (  ) [inherited]

Use this method to configure logging.

Definition at line 266 of file node.hpp.

const NodeStatusProvider::NodeName& getName (  ) const [inherited]

Gets/sets the node name, e.g.

"com.example.product_name". The node name can be set only once. The name must be set before the node is started, otherwise the node will refuse to start up.

Definition at line 166 of file node.hpp.

NodeID getNodeID (  ) const [inherited]

Returns the Node ID of this node.

If Node ID was not set yet, an invalid value will be returned.

Definition at line 39 of file abstract_node.hpp.

int injectTxFrame ( const CanFrame frame,
MonotonicTime  tx_deadline,
uint8_t  iface_mask,
CanTxQueue::Qos  qos = CanTxQueue::Volatile,
CanIOFlags  flags = 0 
) [inherited]

This method allows to directly transmit a raw CAN frame circumventing the whole UAVCAN stack.

Mandatory parameters:

Parameters:
frameCAN frame to be transmitted.
tx_deadlineThe frame will be discarded if it could not be transmitted by this time.
iface_maskThis bitmask allows to select what CAN interfaces this frame should go into. Example:

  • 1 - the frame will be sent only to iface 0.
  • 4 - the frame will be sent only to iface 2.
  • 3 - the frame will be sent to ifaces 0 and 1.

Optional parameters:

Parameters:
qosQuality of service. Please refer to the CAN IO manager for details.
flagsCAN IO flags. Please refer to the CAN driver API for details.

Definition at line 111 of file abstract_node.hpp.

bool isPassiveMode (  ) const [inherited]

Whether the node is in passive mode, i.e.

can't transmit anything to the bus. Please read the specs to learn more.

Definition at line 57 of file abstract_node.hpp.

void logDebug ( const char *  source,
const char *  format,
Args...  args 
) [inherited]

Node logging.

Logging calls are passed directly into the Logger instance. Type safe log formatting is supported only in C++11 mode.

Definition at line 228 of file node.hpp.

BlockingServiceClientPtr<DataType> makeBlockingServiceClient (  ) [inherited]

Allocates uavcan_linux::BlockingServiceClient in the heap using shared pointer.

The service client will be initialized immediately.

Exceptions:
uavcan_linux::Exception.

Definition at line 268 of file drivers/linux/include/uavcan_linux/helpers.hpp.

PublisherPtr<DataType> makePublisher ( uavcan::MonotonicDuration  tx_timeout = uavcan::Publisher<DataType>::getDefaultTxTimeout() ) [inherited]

Allocates uavcan::Publisher in the heap using shared pointer.

The publisher will be initialized immediately.

Exceptions:
uavcan_linux::Exception.

Definition at line 226 of file drivers/linux/include/uavcan_linux/helpers.hpp.

ServiceClientPtr<DataType> makeServiceClient ( const typename uavcan::ServiceClient< DataType >::Callback &  cb ) [inherited]

Allocates uavcan::ServiceClient in the heap using shared pointer.

The service client will be initialized immediately.

Exceptions:
uavcan_linux::Exception.

Definition at line 254 of file drivers/linux/include/uavcan_linux/helpers.hpp.

ServiceServerPtr<DataType> makeServiceServer ( const typename uavcan::ServiceServer< DataType >::Callback &  cb ) [inherited]

Allocates uavcan::ServiceServer in the heap using shared pointer.

The server will be started immediately.

Exceptions:
uavcan_linux::Exception.

Definition at line 241 of file drivers/linux/include/uavcan_linux/helpers.hpp.

SubscriberPtr<DataType> makeSubscriber ( const typename uavcan::Subscriber< DataType >::Callback &  cb ) [inherited]

Allocates uavcan::Subscriber in the heap using shared pointer.

The subscriber will be started immediately.

Exceptions:
uavcan_linux::Exception.

Definition at line 213 of file drivers/linux/include/uavcan_linux/helpers.hpp.

TimerPtr makeTimer ( uavcan::MonotonicTime  deadline,
const typename uavcan::Timer::Callback &  cb 
) [inherited]

Allocates uavcan::Timer in the heap using shared pointer.

The timer will be started immediately in one-shot mode.

Definition at line 279 of file drivers/linux/include/uavcan_linux/helpers.hpp.

TimerPtr makeTimer ( uavcan::MonotonicDuration  period,
const typename uavcan::Timer::Callback &  cb 
) [inherited]

Allocates uavcan::Timer in the heap using shared pointer.

The timer will be started immediately in periodic mode.

Definition at line 291 of file drivers/linux/include/uavcan_linux/helpers.hpp.

void removeRxFrameListener (  ) [inherited]

The IRxFrameListener interface allows one to monitor all incoming CAN frames.

This feature can be used to implement multithreaded nodes, or to add secondary protocol support.

Definition at line 123 of file abstract_node.hpp.

void setHealthOk (  ) [inherited]

Node health code helpers.

Definition at line 172 of file node.hpp.

void setModeOperational (  ) [inherited]

Node mode code helpers.

Note that INITIALIZATION is the default mode; the application has to manually set it to OPERATIONAL.

Definition at line 181 of file node.hpp.

bool setNodeID ( NodeID  nid ) [inherited]

Sets the Node ID of this node.

Node ID can be assigned only once. This method returns true if the Node ID was successfully assigned, otherwise it returns false. As long as a valid Node ID is not set, the node will remain in passive mode. Using a non-unicast Node ID puts the node into passive mode (as default).

Definition at line 48 of file abstract_node.hpp.

void setRestartRequestHandler ( IRestartRequestHandler handler ) [inherited]

Restart handler can be installed to handle external node restart requests (highly recommended).

Definition at line 215 of file node.hpp.

void setSoftwareVersion ( const protocol::SoftwareVersion &  version ) [inherited]

Gets/sets the node version information.

Definition at line 203 of file node.hpp.

void setVendorSpecificStatusCode ( NodeStatusProvider::VendorSpecificStatusCode  code ) [inherited]

Updates the vendor-specific status code.

Definition at line 195 of file node.hpp.

int spin ( MonotonicDuration  duration ) [inherited]

Runs the node.

Normally your application should not block anywhere else. Block inside this method forever or call it periodically. This method returns 0 if no errors occurred, or a negative error code if something failed (see error.hpp).

Reimplemented from INode.

Definition at line 129 of file node.hpp.

int spin ( MonotonicTime  deadline ) [inherited]

Same as spin(MonotonicDuration), but the deadline is specified as an absolute time value rather than duration.

Reimplemented from INode.

Definition at line 120 of file node.hpp.

int spinOnce (  ) [inherited]

This method is designed for non-blocking applications.

Instead of blocking, it returns immediately once all available CAN frames and timer events are processed. Note that this is unlike plain spin(), which will strictly return when the deadline is reached, even if there still are unprocessed events. This method returns 0 if no errors occurred, or a negative error code if something failed (see error.hpp).

Reimplemented from INode.

Definition at line 138 of file node.hpp.

int start ( const TransferPriority  node_status_transfer_priority = TransferPriority::Default ) [inherited]

Starts the node and publishes uavcan.protocol.NodeStatus immediately.

Does not so anything if the node is already started. Once started, the node can't stop. If the node failed to start up, it's recommended to destroy the current node instance and start over. Returns negative error code.

Parameters:
node_status_transfer_priorityTransfer priority that will be used for outgoing NodeStatus messages. Normal priority is used by default.