]> Pileus Git - ~andy/csm213a-hw/blobdiff - hw2/messages.h
Add output event and more messages
[~andy/csm213a-hw] / hw2 / messages.h
index 20887ccb9097bfcb707a87603b100584c98a1d0b..e18166bd66b987dc37d588ae700f9355550b5852 100644 (file)
@@ -4,14 +4,20 @@
 
 #include <stdint.h>
 
-#define MSG_HEADER 0x1234
-#define MSG_MAXID  2
+#define MSG_HEADER       0x1234
+
+#define MSG_VALID_DEVICE 0x0001
+#define MSG_VALID_START  0x0002
+#define MSG_VALID_PERIOD 0x0004
+#define MSG_VALID_WORLD  0x0008
 
 #pragma pack(1)
 
 typedef enum {
+       MSG_ID_INIT,       // Device initialization
        MSG_ID_SYNC,       // Time synchronization
        MSG_ID_EVENT,      // Event occurred
+       MSG_MAX_ID,        // Maximum message ID
 } msgid_t;
 
 typedef struct {
@@ -26,6 +32,14 @@ typedef struct {
        uint16_t cksum;    // Body checksum
 } header_t;
 
+typedef struct {
+       uint16_t valid;    // Message valid bits
+       uint16_t device;   // Device ID to use
+       ntime_t  start;    // Transmit start time 
+       ntime_t  period;   // Transmit period
+       ntime_t  world;    // World time (since 1970)
+} init_msg_t;
+
 typedef struct {
        uint32_t seq;      // Current sequence counter
        ntime_t  time;     // Time of previous message