Helper class for sending stream data to a CAN interface.
More...
#include <StreamSender.hxx>
|
| static constexpr size_t | STREAM_PROCEED_TIMEOUT_SEC = 20 |
| | How many seconds for waiting for a stream proceed before we give up with a timeout.
|
| |
| static constexpr size_t | STREAM_INIT_TIMEOUT_SEC = 20 |
| | How many seconds for waiting for a stream init before we give up with a timeout.
|
| |
| static constexpr size_t | MAX_BYTES_PAYLOAD_PER_CAN_FRAME = 7 |
| | How many bytes payload we can copy into a single CAN frame.
|
| |
| static constexpr size_t | MAX_FRAMES_IN_FLIGHT = 4 |
| | How many CAN frames should we allocate at a given time.
|
| |
| static constexpr size_t | CAN_FRAME_ALLOC_SIZE |
| | How many bytes the allocation of a single CAN frame should be.
|
| |
Helper class for sending stream data to a CAN interface.
- Todo:
- add progress report API.
Definition at line 81 of file StreamSender.hxx.
◆ StreamSenderCan()
| openlcb::StreamSenderCan::StreamSenderCan |
( |
Service * |
service, |
|
|
IfCan * |
iface |
|
) |
| |
|
inline |
◆ advance()
| void openlcb::StreamSenderCan::advance |
( |
size_t |
num_bytes | ) |
|
|
inlineprivate |
Consumes a certain number of bytes from the beginning of the data to send.
- Parameters
-
| num_bytes | how much data to consume. |
Definition at line 517 of file StreamSender.hxx.
◆ allocate_can_buffer()
| Action openlcb::StreamSenderCan::allocate_can_buffer |
( |
| ) |
|
|
inlineprivate |
Allocates a buffer for a CAN frame (for payload send).
Definition at line 389 of file StreamSender.hxx.
◆ clear()
| void openlcb::StreamSenderCan::clear |
( |
| ) |
|
|
inline |
Sets the stream sender to be available for reuse after a stream has been closed or reached error.
Definition at line 167 of file StreamSender.hxx.
◆ close_stream()
| void openlcb::StreamSenderCan::close_stream |
( |
uint16_t |
error_code = 0 | ) |
|
|
inline |
Closes the stream when all the bytes are transferred.
- Parameters
-
| error_code | 0 upon success. This code is intended to be transferred in the stream close message, but that is not yet implemented, because the draft protocol does not have provisions for an error code at close. |
Definition at line 133 of file StreamSender.hxx.
◆ compute_next_can_length()
| size_t openlcb::StreamSenderCan::compute_next_can_length |
( |
| ) |
|
|
inlineprivate |
- Returns
- how many bytes of data we can put into the next CAN frame.
Definition at line 486 of file StreamSender.hxx.
◆ do_close_stream()
| Action openlcb::StreamSenderCan::do_close_stream |
( |
| ) |
|
|
inlineprivate |
◆ entry()
| Action openlcb::StreamSenderCan::entry |
( |
| ) |
|
|
inlineoverridevirtual |
◆ get_dst_stream_id()
| uint8_t openlcb::StreamSenderCan::get_dst_stream_id |
( |
| ) |
|
|
inline |
- Returns
- the stream DID (identifier on the receiving node).
Definition at line 209 of file StreamSender.hxx.
◆ get_error()
| uint16_t openlcb::StreamSenderCan::get_error |
( |
| ) |
|
|
inline |
- Returns
- the error code if we got a rejection from the remote node.
Definition at line 197 of file StreamSender.hxx.
◆ get_src_stream_id()
| uint8_t openlcb::StreamSenderCan::get_src_stream_id |
( |
| ) |
|
|
inline |
- Returns
- the stream SID (identifier on this node).
Definition at line 203 of file StreamSender.hxx.
◆ get_state()
◆ got_frame()
| Action openlcb::StreamSenderCan::got_frame |
( |
| ) |
|
|
inlineprivate |
Got a buffer for an output frame (payload send).
Definition at line 396 of file StreamSender.hxx.
◆ initiate_stream()
| Action openlcb::StreamSenderCan::initiate_stream |
( |
| ) |
|
|
inlineprivate |
◆ payload()
| uint8_t * openlcb::StreamSenderCan::payload |
( |
| ) |
|
|
inlineprivate |
- Returns
- pointer to the beginning of the data to send.
Definition at line 509 of file StreamSender.hxx.
◆ received_init_stream()
| Action openlcb::StreamSenderCan::received_init_stream |
( |
| ) |
|
|
inlineprivate |
State executed after wakeup from the stream initiate reply received handler.
Definition at line 330 of file StreamSender.hxx.
◆ remaining()
| size_t openlcb::StreamSenderCan::remaining |
( |
| ) |
|
|
inlineprivate |
- Returns
- the number of bytes available in the current chunk.
Definition at line 503 of file StreamSender.hxx.
◆ return_error()
| Action openlcb::StreamSenderCan::return_error |
( |
uint32_t |
code, |
|
|
string |
message |
|
) |
| |
|
inlineprivate |
◆ send_close_stream()
| Action openlcb::StreamSenderCan::send_close_stream |
( |
| ) |
|
|
inlineprivate |
◆ send_init_stream()
| Action openlcb::StreamSenderCan::send_init_stream |
( |
| ) |
|
|
inlineprivate |
◆ set_proposed_window_size()
| StreamSenderCan & openlcb::StreamSenderCan::set_proposed_window_size |
( |
uint16_t |
window_size | ) |
|
|
inline |
Specifies what the source should propose as window size to the destination.
May be called only after start_stream.
- Parameters
-
| window_size | in bytes, what should we propose in the stream initiate call |
Definition at line 145 of file StreamSender.hxx.
◆ set_stream_uid()
Specifies the Stream UID to send in the stream initiate request.
May be called only after start_stream. This function must be used if opening an unannounced stream to a destination.
- Parameters
-
| stream_uid | a valid 6-byte stream identifier. |
- Todo:
- implement opening unannounced streams.
Definition at line 158 of file StreamSender.hxx.
◆ start_stream()
Initiates using the stream sender.
May be called only on idle stream senders.
- Parameters
-
| src | Source virtual node on the local interface. |
| dst | Destination node ID to send the stream to. |
| source_stream_id | 8-bit stream ID to use on the this (the source) side. |
| dst_stream_id | 8-bit stream ID to use on the remote side (the destination). |
- Returns
- *this for calling optional settings API commands.
Definition at line 105 of file StreamSender.hxx.
◆ stream_initiate_replied()
| void openlcb::StreamSenderCan::stream_initiate_replied |
( |
Buffer< GenMessage > * |
message | ) |
|
|
inlineprivate |
Callback from GenHandler when a stream initiate reply message arrives at the local interface.
Definition at line 289 of file StreamSender.hxx.
◆ stream_proceed_received()
| void openlcb::StreamSenderCan::stream_proceed_received |
( |
Buffer< GenMessage > * |
message | ) |
|
|
inlineprivate |
◆ stream_proceed_timeout()
| Action openlcb::StreamSenderCan::stream_proceed_timeout |
( |
| ) |
|
|
inlineprivate |
- Todo:
- (balazs.racz) somehow merge these two actions: remember that we timed out and close the stream.
Definition at line 470 of file StreamSender.hxx.
◆ trigger()
| void openlcb::StreamSenderCan::trigger |
( |
| ) |
|
|
inlineprivate |
Sends an empty message to *this, thereby waking up the state machine.
Definition at line 249 of file StreamSender.hxx.
◆ wait_for_stream_proceed()
| Action openlcb::StreamSenderCan::wait_for_stream_proceed |
( |
| ) |
|
|
inlineprivate |
Starts sleeping until a proceed message arrives.
Run this state when streamWindowRemaining_ == 0.
Definition at line 429 of file StreamSender.hxx.
◆ CAN_FRAME_ALLOC_SIZE
| constexpr size_t openlcb::StreamSenderCan::CAN_FRAME_ALLOC_SIZE |
|
staticconstexprprivate |
Initial value:=
Buffer< CanHubData > message_type
Stores the message template type for external reference.
How many bytes the allocation of a single CAN frame should be.
Definition at line 547 of file StreamSender.hxx.
◆ canFramePool_
Source of buffers for outgoing CAN frames.
Limtedpool is allocating and releasing to the mainBufferPool, but blocks when we exceed a certain number of allocations until some buffers get freed.
Definition at line 595 of file StreamSender.hxx.
◆ dst_
Destination node that we are sending to.
It is important that the alias is filled in here.
Definition at line 564 of file StreamSender.hxx.
◆ dstStreamId_
◆ errorCode_
| uint32_t openlcb::StreamSenderCan::errorCode_ {0} |
|
private |
When the stream process fails, this variable contains an error code.
Definition at line 591 of file StreamSender.hxx.
◆ ifCan_
| IfCan* openlcb::StreamSenderCan::ifCan_ |
|
private |
◆ isLoopbackStream_
| uint8_t openlcb::StreamSenderCan::isLoopbackStream_ |
|
private |
Determines whether the stream transmission is happening to localhost.
Almost never true.
Definition at line 575 of file StreamSender.hxx.
◆ localStreamId_
◆ MAX_BYTES_PAYLOAD_PER_CAN_FRAME
| constexpr size_t openlcb::StreamSenderCan::MAX_BYTES_PAYLOAD_PER_CAN_FRAME = 7 |
|
staticconstexprprivate |
How many bytes payload we can copy into a single CAN frame.
Definition at line 541 of file StreamSender.hxx.
◆ MAX_FRAMES_IN_FLIGHT
| constexpr size_t openlcb::StreamSenderCan::MAX_FRAMES_IN_FLIGHT = 4 |
|
staticconstexprprivate |
How many CAN frames should we allocate at a given time.
Definition at line 544 of file StreamSender.hxx.
◆ node_
| Node* openlcb::StreamSenderCan::node_ {nullptr} |
|
private |
Which node are we sending the outgoing data from.
This is a local virtual node.
Definition at line 561 of file StreamSender.hxx.
◆ requestClose_
| uint8_t openlcb::StreamSenderCan::requestClose_ |
|
private |
◆ requestInit_
| uint8_t openlcb::StreamSenderCan::requestInit_ |
|
private |
◆ sleeping_
| uint8_t openlcb::StreamSenderCan::sleeping_ |
|
private |
◆ state_
◆ STREAM_INIT_TIMEOUT_SEC
| constexpr size_t openlcb::StreamSenderCan::STREAM_INIT_TIMEOUT_SEC = 20 |
|
staticconstexprprivate |
How many seconds for waiting for a stream init before we give up with a timeout.
Definition at line 538 of file StreamSender.hxx.
◆ STREAM_PROCEED_TIMEOUT_SEC
| constexpr size_t openlcb::StreamSenderCan::STREAM_PROCEED_TIMEOUT_SEC = 20 |
|
staticconstexprprivate |
How many seconds for waiting for a stream proceed before we give up with a timeout.
Definition at line 534 of file StreamSender.hxx.
◆ streamAdditionalFlags_
| uint8_t openlcb::StreamSenderCan::streamAdditionalFlags_ {0} |
|
private |
More flags from the remote node that we got in stream initiate reply.
Definition at line 585 of file StreamSender.hxx.
◆ streamFlags_
| uint8_t openlcb::StreamSenderCan::streamFlags_ {0} |
|
private |
Flags from the remote node that we got in stream initiate reply.
Definition at line 583 of file StreamSender.hxx.
◆ streamInitiateReplyHandler_
| MessageHandler::GenericHandler openlcb::StreamSenderCan::streamInitiateReplyHandler_ |
|
private |
Initial value:{
void stream_initiate_replied(Buffer< GenMessage > *message)
Callback from GenHandler when a stream initiate reply message arrives at the local interface.
Handles incoming stream initiate reply messages.
Definition at line 554 of file StreamSender.hxx.
◆ streamProceedHandler_
| MessageHandler::GenericHandler openlcb::StreamSenderCan::streamProceedHandler_ |
|
private |
Initial value:{
void stream_proceed_received(Buffer< GenMessage > *message)
Callback from the handler flow.
Handles incoming stream proceed messages.
Definition at line 551 of file StreamSender.hxx.
◆ streamWindowRemaining_
| uint16_t openlcb::StreamSenderCan::streamWindowRemaining_ {0} |
|
private |
◆ streamWindowSize_
◆ timer_
| StateFlowTimer openlcb::StreamSenderCan::timer_ {this} |
|
private |
◆ totalByteCount_
| size_t openlcb::StreamSenderCan::totalByteCount_ {0} |
|
private |
How many bytes we have transmitted in this stream so far.
Definition at line 566 of file StreamSender.hxx.
The documentation for this class was generated from the following file: