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

Dependents:   UAVCAN UAVCAN_Subscriber

Embed: (wiki syntax)

« Back to documentation index

FirmwareUpdateTrigger Class Reference

FirmwareUpdateTrigger Class Reference

This class subscribes to updates from NodeInfoRetriever in order to detect nodes that need firmware updates. More...

#include <firmware_update_trigger.hpp>

Inherits uavcan::INodeInfoListener, and uavcan::TimerBase.

Public Member Functions

int start (NodeInfoRetriever &node_info_retriever, const FirmwareFilePath &arg_common_path_prefix=FirmwareFilePath(), const TransferPriority priority=TransferPriority::OneHigherThanLowest)
 Starts the object.
MonotonicDuration getRequestInterval () const
 Interval at which uavcan.protocol.file.BeginFirmwareUpdate requests are being sent.
bool isTimerRunning () const
 This method is mostly needed for testing.
virtual void handleNodeStatusMessage (const ReceivedDataStructure< protocol::NodeStatus > &msg)
 This call is routed directly from NodeStatusMonitor.

Private Member Functions

void startOneShotWithDeadline (MonotonicTime deadline)
 Various ways to start the timer - periodically or once.
MonotonicDuration getPeriod () const
 Returns period if the timer is in periodic mode.

Detailed Description

This class subscribes to updates from NodeInfoRetriever in order to detect nodes that need firmware updates.

The decision process of whether a firmware update is needed is relayed to the application via IFirmwareVersionChecker. If the application confirms that the update is needed, this class will begin sending uavcan.protocol.file.BeginFirmwareUpdate periodically (period is configurable) to every node that needs an update in a round-robin fashion. There are the following termination conditions for the periodical sending process:

  • The node responds with confirmation. In this case the class will forget about the node on the assumption that its job is done here. Confirmation will be reported to the application via the interface.
  • The node responds with an error, and the error code is not ERROR_IN_PROGRESS. In this case the class will request the application via the interface mentioned above about its further actions - either give up or retry, possibly with a different firmware.
  • The node responds with error ERROR_IN_PROGRESS. In this case the class behaves exactly in the same way as if response was successful (because the firmware is alredy being updated, so the goal is fulfilled). Confirmation will be reported to the application via the interface.
  • The node goes offline or restarts. In this case the node will be immediately forgotten, and the process will repeat again later because the node info retriever re-queries GetNodeInfo every time when a node restarts.

Since the target node (i.e. node that is being updated) will try to retrieve the specified firmware file using the file services (uavcan.protocol.file.*), the provided firmware path must be reachable for the file server (FileServer, BasicFileServer). Normally, an application that serves as UAVCAN firmware update server will include at least the following components:

  • this firmware update trigger;
  • dynamic node ID allocation server;
  • file server.

Implementation details: the class uses memory pool to keep the list of nodes that have not responded yet, which limits the maximum length of the path to the firmware file, which is covered in IFirmwareVersionChecker. To somewhat relieve the maximum path length limitation, the class can be supplied with a common prefix that will be prepended to firmware pathes before sending requests. Interval at which requests are being sent is configurable, but the default value should cover the needs of virtually all use cases (as always).

Definition at line 136 of file firmware_update_trigger.hpp.


Member Function Documentation

MonotonicDuration getRequestInterval (  ) const

Interval at which uavcan.protocol.file.BeginFirmwareUpdate requests are being sent.

Note that default value should be OK for any use case.

Definition at line 442 of file firmware_update_trigger.hpp.

virtual void handleNodeStatusMessage ( const ReceivedDataStructure< protocol::NodeStatus > &  msg ) [virtual, inherited]

This call is routed directly from NodeStatusMonitor.

Default implementation does nothing.

Parameters:
msgNode status message

Definition at line 53 of file node_info_retriever.hpp.

bool isTimerRunning (  ) const

This method is mostly needed for testing.

When triggering is not in progress, the class consumes zero CPU time.

Definition at line 463 of file firmware_update_trigger.hpp.

int start ( NodeInfoRetriever node_info_retriever,
const FirmwareFilePath arg_common_path_prefix = FirmwareFilePath(),
const TransferPriority  priority = TransferPriority::OneHigherThanLowest 
)

Starts the object.

Once started, it can't be stopped unless destroyed.

Parameters:
node_info_retrieverThe object will register itself against this retriever. When the destructor is called, the object will unregister itself.
common_path_prefixIf set, this path will be prefixed to all firmware pathes provided by the application interface. The prefix does not need to end with path separator; the last trailing one will be removed (so use '//' if you need '/'). By default the prefix is empty.
Returns:
Negative error code.

Definition at line 397 of file firmware_update_trigger.hpp.