Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
openlcb::DatagramDefs Struct Reference

Static constants and functions related to the Datagram protocol. More...

#include <DatagramDefs.hxx>

Public Types

enum  Protocol {
  LOG_REQUEST = 0x01 , LOG_REPLY = 0x02 , CONFIGURATION = 0x20 , REMOTE_BUTTON = 0x21 ,
  DISPLAY_PROTOCOL = 0x28 , TRAIN_CONTROL = 0x30
}
 All known datagram protocols. More...
 
enum  { MAX_SIZE = 72 }
 Various public datagram constants. More...
 
enum  Flag {
  FLAGS_NONE = 0x00 , REPLY_PENDING = 0x80 , TIMEOUT_NONE = 0x00 , TIMEOUT_2 = 0x01 ,
  TIMEOUT_4 = 0x02 , TIMEOUT_8 = 0x03 , TIMEOUT_16 = 0x04 , TIMEOUT_32 = 0x05 ,
  TIMEOUT_64 = 0x06 , TIMEOUT_128 = 0x07 , TIMEOUT_256 = 0x08 , TIMEOUT_512 = 0x09 ,
  TIMEOUT_1024 = 0x0A , TIMEOUT_2048 = 0x0B , TIMEOUT_4096 = 0x0C , TIMEOUT_8192 = 0x0D ,
  TIMEOUT_16384 = 0x0E , TIMEOUT_32768 = 0x0F , TIMEOUT_MASK = 0x0F
}
 Possible flags for a successful receipt (received okay) of a Datagram. More...
 
enum  Error {
  RESEND_OK = 0x2000 , TRANSPORT_ERROR = 0x6000 , BUFFER_UNAVAILABLE = 0x2020 , OUT_OF_ORDER = 0x2040 ,
  PERMANENT_ERROR = 0x1000 , SRC_NOT_PERMITTED = 0x1020 , NOT_ACCEPTED = 0x1040 , UNIMPLEMENTED = 0x1080 ,
  INVALID_ARGUMENTS = 0x1010
}
 Possible error codes for a rejected datagram. More...
 

Static Public Member Functions

static bool resend_ok (uint16_t error)
 We can try to resend the datagram.
 
static bool transport_error (uint16_t error)
 Transport error occurred.
 
static bool buffer_unavailable (uint16_t error)
 Buffer unavailable error occurred.
 
static unsigned int protocol_size (uint64_t protocol)
 Determine if the protocol ID is represented by one, two, or six bytes.
 

Private Types

enum  { PROTOCOL_SIZE_2 = 0xE0 , PROTOCOL_SIZE_6 = 0xF0 , PROTOCOL_SIZE_MASK = 0xF0 }
 Constants used by the protocol_size function. More...
 

Private Member Functions

 DatagramDefs ()
 Do not instantiate this class, ever.
 

Detailed Description

Static constants and functions related to the Datagram protocol.

Definition at line 43 of file DatagramDefs.hxx.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Various public datagram constants.

Enumerator
MAX_SIZE 

maximum size in bytes of a datagram

Definition at line 57 of file DatagramDefs.hxx.

◆ anonymous enum

anonymous enum
private

Constants used by the protocol_size function.

Enumerator
PROTOCOL_SIZE_2 

possible return value for protocol_size

PROTOCOL_SIZE_6 

possible return value for protocol_size

PROTOCOL_SIZE_MASK 

mask used when determining protocol size

Definition at line 144 of file DatagramDefs.hxx.

◆ Error

Possible error codes for a rejected datagram.

Enumerator
RESEND_OK 

We can try to resend the datagram.

TRANSPORT_ERROR 

Transport error occurred.

BUFFER_UNAVAILABLE 

Buffer unavailable error occurred.

OUT_OF_ORDER 

Out of order error occurred.

PERMANENT_ERROR 

Permanent error occurred.

SRC_NOT_PERMITTED 

Source not permitted error occurred.

NOT_ACCEPTED 

Destination node does not accept datagrams of any kind.

UNIMPLEMENTED 

NON_STANDARD The feature or command requested is not implemented by the target node.

INVALID_ARGUMENTS 

NON_STANDARD Invalid or unparseable arguments.

Definition at line 92 of file DatagramDefs.hxx.

◆ Flag

Possible flags for a successful receipt (received okay) of a Datagram.

Enumerator
FLAGS_NONE 

no flags set

REPLY_PENDING 

A reply is pending.

TIMEOUT_NONE 

no timeout

TIMEOUT_2 

2 second timeout

TIMEOUT_4 

4 second timeout

TIMEOUT_8 

8 second timeout

TIMEOUT_16 

16 second timeout

TIMEOUT_32 

32 second timeout

TIMEOUT_64 

64 second timeout

TIMEOUT_128 

128 second timeout

TIMEOUT_256 

256 second timeout

TIMEOUT_512 

512 second timeout

TIMEOUT_1024 

1024 second timeout

TIMEOUT_2048 

2048 second timeout

TIMEOUT_4096 

4096 second timeout

TIMEOUT_8192 

8192 second timeout

TIMEOUT_16384 

16384 second timeout

TIMEOUT_32768 

32768 second timeout

TIMEOUT_MASK 

Mask for reply timeout.

Definition at line 65 of file DatagramDefs.hxx.

◆ Protocol

All known datagram protocols.

Enumerator
LOG_REQUEST 

request a placement into the log

LOG_REPLY 

reply to a LOG_REQUEST

CONFIGURATION 

configuration message

REMOTE_BUTTON 

remote button input

DISPLAY_PROTOCOL 

place on display

TRAIN_CONTROL 

operation of mobile nodes

Definition at line 46 of file DatagramDefs.hxx.

Member Function Documentation

◆ buffer_unavailable()

static bool openlcb::DatagramDefs::buffer_unavailable ( uint16_t  error)
inlinestatic

Buffer unavailable error occurred.

Parameters
errorerror number
Returns
true or false

Definition at line 127 of file DatagramDefs.hxx.

◆ protocol_size()

static unsigned int openlcb::DatagramDefs::protocol_size ( uint64_t  protocol)
inlinestatic

Determine if the protocol ID is represented by one, two, or six bytes.

Parameters
_protocolprotocol ID to interrogate
Returns
number of bytes representing the protocol

Definition at line 136 of file DatagramDefs.hxx.

◆ resend_ok()

static bool openlcb::DatagramDefs::resend_ok ( uint16_t  error)
inlinestatic

We can try to resend the datagram.

Parameters
errorerror number
Returns
true or false

Definition at line 109 of file DatagramDefs.hxx.

◆ transport_error()

static bool openlcb::DatagramDefs::transport_error ( uint16_t  error)
inlinestatic

Transport error occurred.

Parameters
errorerror number
Returns
true or false

Definition at line 118 of file DatagramDefs.hxx.


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