Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
packet.h
Go to the documentation of this file.
1
35#ifndef _DCC_PACKET_H_
36#define _DCC_PACKET_H_
37
38#include <stdint.h>
39
40#ifdef __cplusplus
41extern "C" {
42#endif
43
45#define DCC_PACKET_MAX_PAYLOAD (32)
47#define DCC_PACKET_EMERGENCY_STOP (0xFFFF)
50#define DCC_PACKET_CHANGE_DIR (0xFFFF)
51
54typedef struct dcc_packet
55{
57 struct pkt_t
58 {
60 uint8_t is_pkt : 1;
62 uint8_t is_marklin : 1;
63
66 uint8_t skip_ec : 1;
69 uint8_t send_long_preamble : 1;
71 uint8_t sense_ack : 1;
74 uint8_t rept_count : 2;
76 uint8_t csum_error : 1;
77 };
78
80 struct cmd_t
81 {
83 uint8_t is_pkt : 1;
85 uint8_t cmd : 7;
86 };
87
88 union
89 {
90 uint8_t header_raw_data;
91 struct pkt_t packet_header;
92 struct cmd_t command_header;
93 };
95 uint8_t dlc;
97 uint8_t payload[DCC_PACKET_MAX_PAYLOAD];
98
104 uintptr_t feedback_key;
105} DCCPacket;
106
107#ifdef __cplusplus
108}
109#endif
110
111#endif /* _DCC_PACKET_H_ */
112
#define DCC_PACKET_MAX_PAYLOAD
Maximum number of payload bytes.
Definition packet.h:45
Specifies the meaning of the command byte for meta-commands to send.
Definition packet.h:81
uint8_t is_pkt
Always 1.
Definition packet.h:83
uint8_t cmd
Command identifier.
Definition packet.h:85
Specifies the meaning of the command byte for packets to send.
Definition packet.h:58
uint8_t skip_ec
typically for DCC packets: 1: do NOT append an EC byte to the end of the packet.
Definition packet.h:66
uint8_t send_long_preamble
1: send long preamble instead of packet.
Definition packet.h:69
uint8_t is_marklin
0: DCC packet, 1: motorola packet.
Definition packet.h:62
uint8_t csum_error
1 if there was a checksum error in this packet.
Definition packet.h:76
uint8_t sense_ack
1: wait for service mode ack and report it back to the host.
Definition packet.h:71
uint8_t is_pkt
Always 0.
Definition packet.h:60
uint8_t rept_count
The packet will be sent 1 + rept_count times to the wire.
Definition packet.h:74
Stores a DCC packet in memory.
Definition packet.h:55
uintptr_t feedback_key
An opaque key used by the hardware driver to attribute feedback information to the source of the pack...
Definition packet.h:104
uint8_t dlc
Specifies the number of used payload bytes.
Definition packet.h:95