Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
openlcb::BootloaderClient Class Reference

StateFlow performing the bootloading process. More...

#include <BootloaderClient.hxx>

Inheritance diagram for openlcb::BootloaderClient:
StateFlow< Buffer< BootloaderRequest >, QList< 1 > > TypedStateFlow< MessageType, Base > FlowInterface< MessageType >

Classes

class  WriteResponseHandler
 Datagram handler that listens to the incoming memoryconfig datagram for the write stream response message. More...
 

Public Member Functions

 BootloaderClient (Node *node, DatagramService *if_datagram_service, IfCan *if_can)
 
Action entry () override
 Entry into the StateFlow activity.
 
DatagramServicedatagram_service ()
 
Nodenode ()
 
const NodeHandledst ()
 
const BootloaderRequestrequest ()
 
void response_datagram_arrived (Buffer< IncomingDatagram > *datagram)
 
- Public Member Functions inherited from StateFlow< Buffer< BootloaderRequest >, QList< 1 > >
 StateFlow (Service *service)
 Constructor.
 
- Public Member Functions inherited from TypedStateFlow< MessageType, Base >
 TypedStateFlow (Service *service)
 Constructor.
 
virtual ~TypedStateFlow ()
 Destructor.
 
void send (MessageType *msg, unsigned priority=UINT_MAX) OVERRIDE
 Sends a message to the state flow for processing.
 
- Public Member Functions inherited from FlowInterface< MessageType >
virtual Poolpool ()
 
virtual MessageType * type_helper ()
 This function is never user in the code, but GDB can use it to infer the correct message types.
 
MessageType * alloc ()
 Synchronously allocates a message buffer from the pool of this flow.
 
void alloc_async (Executable *target)
 Asynchronously allocates a message buffer from the pool of this flow.
 

Private Member Functions

Action got_dg_client ()
 
Action reboot_dg_done ()
 
Action send_pip_request ()
 
Action pip_response ()
 
Action bootload_using_stream ()
 
Action write_request_sent ()
 
Action wait_for_response_dg ()
 
uint8_t allocate_local_stream_id ()
 
Action return_error (uint16_t error_code, const string &error_details)
 
void register_write_response_handler ()
 
void unregister_write_response_handler ()
 
Action initiate_stream ()
 
Action send_init_stream ()
 
void stream_initiate_replied (Buffer< GenMessage > *message)
 
Action received_init_stream ()
 
Action send_stream_data ()
 
Action fill_outgoing_stream_frame ()
 
Action wait_for_stream_proceed ()
 
void stream_proceed_received (Buffer< GenMessage > *message)
 
Action stream_proceed_timeout ()
 
Action close_stream ()
 
Action send_close_stream ()
 
Action send_reboot_request ()
 
Action bootload_using_datagrams ()
 
Action next_dg_write_datagram ()
 
Action dg_write_request_sent ()
 
Action reboot_dg_client ()
 
Action reboot_with_dg_client ()
 
Action finish ()
 

Private Attributes

Nodenode_
 
DatagramServicedatagramService_
 
IfCanifCan_
 
DatagramClientdgClient_ = nullptr
 
Buffer< IncomingDatagram > * responseDatagram_ = nullptr
 
uint8_t localStreamId_
 
uint8_t remoteStreamId_
 
uint16_t maxBufferSize_
 
uint8_t streamFlags_
 
uint8_t streamAdditionalFlags_
 
uint32_t availableBufferSize_
 
size_t bufferOffset_
 
Ewma speedAvg_
 
float speed_
 
size_t lastMeasurementOffset_
 
long long lastMeasurementTimeNsec_
 
long long sleepStartTimeNsec_
 
WriteResponseHandler writeResponseHandler_ {this}
 
bool writeResponseRegistered_ = false
 
MessageHandler::GenericHandler streamInitiateReplyHandler_
 
MessageHandler::GenericHandler streamProceedHandler_
 
StateFlowTimer timer_ {this}
 
bool sleeping_ = false
 
BarrierNotifiable n_
 
PIPClient pipClient_ {ifCan_}
 

Additional Inherited Members

- Public Types inherited from TypedStateFlow< MessageType, Base >
typedef Base::Action Action
 Allows using Action without having StateFlowBase:: prefix in front of it.
 
- Public Types inherited from FlowInterface< MessageType >
typedef MessageType message_type
 Stores the message template type for external reference.
 
- Static Public Member Functions inherited from FlowInterface< MessageType >
static MessageType * cast_alloc (QMember *entry)
 Down casts and initializes an asynchronous allocation result to the appropriate flow's buffer type.
 
- Protected Member Functions inherited from TypedStateFlow< MessageType, Base >
void release () OVERRIDE
 Unrefs the current buffer.
 
void return_buffer ()
 For state flows that are operated using invoke_subflow_and_wait this is a way to hand back the buffer to the caller.
 
MessageType * message ()
 
MessageType * transfer_message ()
 Releases ownership of the current message.
 

Detailed Description

StateFlow performing the bootloading process.

1) allocates a datagram handler 2) sends a stream write request datagram to the target node 3) waits for the write stream response 4) sends the data using a manual implementaiton of the stream protocol (stream initiate; data send; wait for proceeds; stream close) 5) reboots the target node.

This stateflow needs to get one message of type BootloaderRequest to perform the bootloading process on a single target.

Definition at line 102 of file BootloaderClient.hxx.

Constructor & Destructor Documentation

◆ BootloaderClient()

openlcb::BootloaderClient::BootloaderClient ( Node node,
DatagramService if_datagram_service,
IfCan if_can 
)
inline

Definition at line 105 of file BootloaderClient.hxx.

Member Function Documentation

◆ allocate_local_stream_id()

uint8_t openlcb::BootloaderClient::allocate_local_stream_id ( )
inlineprivate

Definition at line 366 of file BootloaderClient.hxx.

◆ bootload_using_datagrams()

Action openlcb::BootloaderClient::bootload_using_datagrams ( )
inlineprivate

Definition at line 645 of file BootloaderClient.hxx.

◆ bootload_using_stream()

Action openlcb::BootloaderClient::bootload_using_stream ( )
inlineprivate

Definition at line 214 of file BootloaderClient.hxx.

◆ close_stream()

Action openlcb::BootloaderClient::close_stream ( )
inlineprivate

Definition at line 613 of file BootloaderClient.hxx.

◆ datagram_service()

DatagramService * openlcb::BootloaderClient::datagram_service ( )
inline

Definition at line 120 of file BootloaderClient.hxx.

◆ dg_write_request_sent()

Action openlcb::BootloaderClient::dg_write_request_sent ( )
inlineprivate

Definition at line 671 of file BootloaderClient.hxx.

◆ dst()

const NodeHandle & openlcb::BootloaderClient::dst ( )
inline

Definition at line 130 of file BootloaderClient.hxx.

◆ entry()

Action openlcb::BootloaderClient::entry ( )
inlineoverridevirtual

Entry into the StateFlow activity.

Pure virtual which must be defined by derived class.

Returns
function pointer to next state

Implements TypedStateFlow< MessageType, Base >.

Definition at line 114 of file BootloaderClient.hxx.

◆ fill_outgoing_stream_frame()

Action openlcb::BootloaderClient::fill_outgoing_stream_frame ( )
inlineprivate

Definition at line 499 of file BootloaderClient.hxx.

◆ finish()

Action openlcb::BootloaderClient::finish ( )
inlineprivate

Definition at line 733 of file BootloaderClient.hxx.

◆ got_dg_client()

Action openlcb::BootloaderClient::got_dg_client ( )
inlineprivate

@TODO (balazs.racz): register a message handler that will wait for a node initialization complete message to come in and cancel the datagram send timeout.

Definition at line 156 of file BootloaderClient.hxx.

◆ initiate_stream()

Action openlcb::BootloaderClient::initiate_stream ( )
inlineprivate

Definition at line 401 of file BootloaderClient.hxx.

◆ next_dg_write_datagram()

Action openlcb::BootloaderClient::next_dg_write_datagram ( )
inlineprivate

@TODO (balazs.racz) we have to expect write response datagrams too.

Definition at line 652 of file BootloaderClient.hxx.

◆ node()

Node * openlcb::BootloaderClient::node ( )
inline

Definition at line 125 of file BootloaderClient.hxx.

◆ pip_response()

Action openlcb::BootloaderClient::pip_response ( )
inlineprivate

Definition at line 197 of file BootloaderClient.hxx.

◆ reboot_dg_client()

Action openlcb::BootloaderClient::reboot_dg_client ( )
inlineprivate

Definition at line 711 of file BootloaderClient.hxx.

◆ reboot_dg_done()

Action openlcb::BootloaderClient::reboot_dg_done ( )
inlineprivate

Definition at line 180 of file BootloaderClient.hxx.

◆ reboot_with_dg_client()

Action openlcb::BootloaderClient::reboot_with_dg_client ( )
inlineprivate

Definition at line 718 of file BootloaderClient.hxx.

◆ received_init_stream()

Action openlcb::BootloaderClient::received_init_stream ( )
inlineprivate

Definition at line 452 of file BootloaderClient.hxx.

◆ register_write_response_handler()

void openlcb::BootloaderClient::register_write_response_handler ( )
inlineprivate

Definition at line 384 of file BootloaderClient.hxx.

◆ request()

const BootloaderRequest * openlcb::BootloaderClient::request ( )
inline

Definition at line 135 of file BootloaderClient.hxx.

◆ response_datagram_arrived()

void openlcb::BootloaderClient::response_datagram_arrived ( Buffer< IncomingDatagram > *  datagram)
inline

Definition at line 140 of file BootloaderClient.hxx.

◆ return_error()

Action openlcb::BootloaderClient::return_error ( uint16_t  error_code,
const string &  error_details 
)
inlineprivate

Definition at line 371 of file BootloaderClient.hxx.

◆ send_close_stream()

Action openlcb::BootloaderClient::send_close_stream ( )
inlineprivate

Definition at line 622 of file BootloaderClient.hxx.

◆ send_init_stream()

Action openlcb::BootloaderClient::send_init_stream ( )
inlineprivate

Definition at line 408 of file BootloaderClient.hxx.

◆ send_pip_request()

Action openlcb::BootloaderClient::send_pip_request ( )
inlineprivate

Definition at line 187 of file BootloaderClient.hxx.

◆ send_reboot_request()

Action openlcb::BootloaderClient::send_reboot_request ( )
inlineprivate

Definition at line 635 of file BootloaderClient.hxx.

◆ send_stream_data()

Action openlcb::BootloaderClient::send_stream_data ( )
inlineprivate

Definition at line 489 of file BootloaderClient.hxx.

◆ stream_initiate_replied()

void openlcb::BootloaderClient::stream_initiate_replied ( Buffer< GenMessage > *  message)
inlineprivate

Definition at line 425 of file BootloaderClient.hxx.

◆ stream_proceed_received()

void openlcb::BootloaderClient::stream_proceed_received ( Buffer< GenMessage > *  message)
inlineprivate

Definition at line 548 of file BootloaderClient.hxx.

◆ stream_proceed_timeout()

Action openlcb::BootloaderClient::stream_proceed_timeout ( )
inlineprivate

@TODO(balazs.racz) somehow merge these two actions: remember that we timed out and close the stream.

Definition at line 599 of file BootloaderClient.hxx.

◆ unregister_write_response_handler()

void openlcb::BootloaderClient::unregister_write_response_handler ( )
inlineprivate

Definition at line 391 of file BootloaderClient.hxx.

◆ wait_for_response_dg()

Action openlcb::BootloaderClient::wait_for_response_dg ( )
inlineprivate

Definition at line 321 of file BootloaderClient.hxx.

◆ wait_for_stream_proceed()

Action openlcb::BootloaderClient::wait_for_stream_proceed ( )
inlineprivate

Definition at line 535 of file BootloaderClient.hxx.

◆ write_request_sent()

Action openlcb::BootloaderClient::write_request_sent ( )
inlineprivate

Definition at line 278 of file BootloaderClient.hxx.

Member Data Documentation

◆ availableBufferSize_

uint32_t openlcb::BootloaderClient::availableBufferSize_
private

Definition at line 785 of file BootloaderClient.hxx.

◆ bufferOffset_

size_t openlcb::BootloaderClient::bufferOffset_
private

Definition at line 787 of file BootloaderClient.hxx.

◆ datagramService_

DatagramService* openlcb::BootloaderClient::datagramService_
private

Definition at line 770 of file BootloaderClient.hxx.

◆ dgClient_

DatagramClient* openlcb::BootloaderClient::dgClient_ = nullptr
private

Definition at line 772 of file BootloaderClient.hxx.

◆ ifCan_

IfCan* openlcb::BootloaderClient::ifCan_
private

Definition at line 771 of file BootloaderClient.hxx.

◆ lastMeasurementOffset_

size_t openlcb::BootloaderClient::lastMeasurementOffset_
private

Definition at line 793 of file BootloaderClient.hxx.

◆ lastMeasurementTimeNsec_

long long openlcb::BootloaderClient::lastMeasurementTimeNsec_
private

Definition at line 795 of file BootloaderClient.hxx.

◆ localStreamId_

uint8_t openlcb::BootloaderClient::localStreamId_
private

Definition at line 774 of file BootloaderClient.hxx.

◆ maxBufferSize_

uint16_t openlcb::BootloaderClient::maxBufferSize_
private

Definition at line 777 of file BootloaderClient.hxx.

◆ n_

BarrierNotifiable openlcb::BootloaderClient::n_
private

Definition at line 810 of file BootloaderClient.hxx.

◆ node_

Node* openlcb::BootloaderClient::node_
private

Definition at line 769 of file BootloaderClient.hxx.

◆ pipClient_

PIPClient openlcb::BootloaderClient::pipClient_ {ifCan_}
private

Definition at line 811 of file BootloaderClient.hxx.

◆ remoteStreamId_

uint8_t openlcb::BootloaderClient::remoteStreamId_
private

Definition at line 775 of file BootloaderClient.hxx.

◆ responseDatagram_

Buffer<IncomingDatagram>* openlcb::BootloaderClient::responseDatagram_ = nullptr
private

Definition at line 773 of file BootloaderClient.hxx.

◆ sleeping_

bool openlcb::BootloaderClient::sleeping_ = false
private

Definition at line 809 of file BootloaderClient.hxx.

◆ sleepStartTimeNsec_

long long openlcb::BootloaderClient::sleepStartTimeNsec_
private

Definition at line 798 of file BootloaderClient.hxx.

◆ speed_

float openlcb::BootloaderClient::speed_
private

Definition at line 791 of file BootloaderClient.hxx.

◆ speedAvg_

Ewma openlcb::BootloaderClient::speedAvg_
private

Definition at line 789 of file BootloaderClient.hxx.

◆ streamAdditionalFlags_

uint8_t openlcb::BootloaderClient::streamAdditionalFlags_
private

Definition at line 781 of file BootloaderClient.hxx.

◆ streamFlags_

uint8_t openlcb::BootloaderClient::streamFlags_
private

Definition at line 779 of file BootloaderClient.hxx.

◆ streamInitiateReplyHandler_

MessageHandler::GenericHandler openlcb::BootloaderClient::streamInitiateReplyHandler_
private
Initial value:
{
this, &BootloaderClient::stream_initiate_replied}

Definition at line 802 of file BootloaderClient.hxx.

◆ streamProceedHandler_

MessageHandler::GenericHandler openlcb::BootloaderClient::streamProceedHandler_
private
Initial value:
{
this, &BootloaderClient::stream_proceed_received}

Definition at line 804 of file BootloaderClient.hxx.

◆ timer_

StateFlowTimer openlcb::BootloaderClient::timer_ {this}
private

Definition at line 806 of file BootloaderClient.hxx.

◆ writeResponseHandler_

WriteResponseHandler openlcb::BootloaderClient::writeResponseHandler_ {this}
private

Definition at line 800 of file BootloaderClient.hxx.

◆ writeResponseRegistered_

bool openlcb::BootloaderClient::writeResponseRegistered_ = false
private

Definition at line 801 of file BootloaderClient.hxx.


The documentation for this class was generated from the following file: