Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
DatagramDefs.hxx
Go to the documentation of this file.
1
34#ifndef _OPENLCB_DATAGRAMDEFS_HXX_
35#define _OPENLCB_DATAGRAMDEFS_HXX_
36
37#include <stdint.h>
38
39namespace openlcb
40{
41
44{
47 {
48 LOG_REQUEST = 0x01,
49 LOG_REPLY = 0x02,
54 };
55
57 enum
58 {
59 MAX_SIZE = 72,
61 };
62
65 enum Flag
66 {
67 FLAGS_NONE = 0x00,
70 TIMEOUT_NONE = 0x00,
71 TIMEOUT_2 = 0x01,
72 TIMEOUT_4 = 0x02,
73 TIMEOUT_8 = 0x03,
74 TIMEOUT_16 = 0x04,
75 TIMEOUT_32 = 0x05,
76 TIMEOUT_64 = 0x06,
77 TIMEOUT_128 = 0x07,
78 TIMEOUT_256 = 0x08,
79 TIMEOUT_512 = 0x09,
80 TIMEOUT_1024 = 0x0A,
81 TIMEOUT_2048 = 0x0B,
82 TIMEOUT_4096 = 0x0C,
83 TIMEOUT_8192 = 0x0D,
87 TIMEOUT_MASK = 0x0F,
88 };
89
92 enum Error
93 {
94 RESEND_OK = 0x2000,
95 TRANSPORT_ERROR = 0x6000,
97 OUT_OF_ORDER = 0x2040,
98 PERMANENT_ERROR = 0x1000,
100 NOT_ACCEPTED = 0x1040,
101 UNIMPLEMENTED = 0x1080,
103 };
104
109 static bool resend_ok(uint16_t error)
110 {
111 return error & RESEND_OK;
112 }
113
118 static bool transport_error(uint16_t error)
119 {
120 return error & TRANSPORT_ERROR;
121 }
122
127 static bool buffer_unavailable(uint16_t error)
128 {
129 return error & BUFFER_UNAVAILABLE;
130 }
131
136 static unsigned int protocol_size(uint64_t protocol)
137 {
138 return (((protocol & PROTOCOL_SIZE_MASK) == PROTOCOL_SIZE_6) ? 6 :
139 ((protocol & PROTOCOL_SIZE_MASK) == PROTOCOL_SIZE_2) ? 2 : 1);
140 }
141
142private:
144 enum
145 {
149 };
150
153};
154
155
156} // namespace openlcb
157
158
159#endif // _OPENLCB_DATAGRAMDEFS_HXX_
160
Static constants and functions related to the Datagram protocol.
static bool resend_ok(uint16_t error)
We can try to resend the datagram.
Flag
Possible flags for a successful receipt (received okay) of a Datagram.
@ TIMEOUT_4096
4096 second timeout
@ TIMEOUT_1024
1024 second timeout
@ TIMEOUT_16384
16384 second timeout
@ TIMEOUT_32768
32768 second timeout
@ TIMEOUT_512
512 second timeout
@ TIMEOUT_2048
2048 second timeout
@ REPLY_PENDING
A reply is pending.
@ TIMEOUT_32
32 second timeout
@ FLAGS_NONE
no flags set
@ TIMEOUT_4
4 second timeout
@ TIMEOUT_128
128 second timeout
@ TIMEOUT_2
2 second timeout
@ TIMEOUT_8
8 second timeout
@ TIMEOUT_MASK
Mask for reply timeout.
@ TIMEOUT_256
256 second timeout
@ TIMEOUT_64
64 second timeout
@ TIMEOUT_16
16 second timeout
@ TIMEOUT_8192
8192 second timeout
static bool buffer_unavailable(uint16_t error)
Buffer unavailable error occurred.
@ MAX_SIZE
maximum size in bytes of a datagram
DatagramDefs()
Do not instantiate this class, ever.
static unsigned int protocol_size(uint64_t protocol)
Determine if the protocol ID is represented by one, two, or six bytes.
Error
Possible error codes for a rejected datagram.
@ INVALID_ARGUMENTS
NON_STANDARD Invalid or unparseable arguments.
@ TRANSPORT_ERROR
Transport error occurred.
@ UNIMPLEMENTED
NON_STANDARD The feature or command requested is not implemented by the target node.
@ OUT_OF_ORDER
Out of order error occurred.
@ BUFFER_UNAVAILABLE
Buffer unavailable error occurred.
@ RESEND_OK
We can try to resend the datagram.
@ PERMANENT_ERROR
Permanent error occurred.
@ NOT_ACCEPTED
Destination node does not accept datagrams of any kind.
@ SRC_NOT_PERMITTED
Source not permitted error occurred.
@ PROTOCOL_SIZE_6
possible return value for protocol_size
@ PROTOCOL_SIZE_2
possible return value for protocol_size
@ PROTOCOL_SIZE_MASK
mask used when determining protocol size
static bool transport_error(uint16_t error)
Transport error occurred.
Protocol
All known datagram protocols.
@ LOG_REPLY
reply to a LOG_REQUEST
@ LOG_REQUEST
request a placement into the log
@ TRAIN_CONTROL
operation of mobile nodes
@ REMOTE_BUTTON
remote button input
@ CONFIGURATION
configuration message
@ DISPLAY_PROTOCOL
place on display