From ef7482ac8bccef25fbe9e2be0f1ba89a4bdcca42 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Thu, 5 Jun 2014 09:34:54 +0000 Subject: [PATCH] added a first draft for a new message format aka protocol version 1 git-svn-id: https://zerberus.eonerc.rwth-aachen.de:8443/svn/s2ss/trunk@26 8ec27952-4edc-4aab-86aa-e87bb2611832 --- include/msg.h | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/include/msg.h b/include/msg.h index 02f7fa4e9..ffe437a80 100644 --- a/include/msg.h +++ b/include/msg.h @@ -33,6 +33,46 @@ struct msg /// Message data double data[MAX_VALUES]; } __attribute__((packed)); +#elif PROTOCOL == 1 +/** + * Next generation message format for RTDS integration + * + * This struct defines the format of a message (protocol version 1) + * Its declared as "packed" because it represents the "on wire" data. + */ +struct msg +{ + struct + { + /// Protocol version + unsigned version : 4; + /// Header length + unsigned hdr_len : 4; + /// Message flags + uint8_t flags; + /// Sender device ID + uint16_t dev_id; + /// Message ID + uint32_t sequence; + /// Message length (data only) + uint16_t data_len; + /// Digital signature for authentication + uint32_t signature; + /// Timestamp in uS since unix epoch + uint64_t timestamp + } header; + union + { + uint32_t integer; + float data float_single; + char * data_str; + } data[MAX_VALUES]; + +} __attribute__((packed)); +#else + #error "Unknown protocol version!" +#endif + /** * @brief Print a raw UDP packge in human readable form *