X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=hw2%2Fmessages.h;h=752476fb2c4ecd60b8fd2425b72171eceb868be0;hb=16ad7d215971b9bbd79007f7c334c4f8d9659c49;hp=20887ccb9097bfcb707a87603b100584c98a1d0b;hpb=fcf3a5999ccfbb4a88f747ee3d9ed1c9c81891de;p=~andy%2Fcsm213a-hw diff --git a/hw2/messages.h b/hw2/messages.h index 20887cc..752476f 100644 --- a/hw2/messages.h +++ b/hw2/messages.h @@ -4,18 +4,25 @@ #include -#define MSG_HEADER 0x1234 -#define MSG_MAXID 2 +#define MSG_HEADER 0x1234 + +#define MSG_VALID_DEVICE 0x0001 // device id is valid +#define MSG_VALID_WORLD 0x0002 // world time is valid +#define MSG_VALID_START 0x0004 // start time is valid +#define MSG_VALID_PERIOD 0x0008 // period is valid +#define MSG_VALID_SYNC 0x8000 // begin time sync #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 { - uint32_t seconds; // Seconds since 1970 (without leap seconds) + uint32_t seconds; // Seconds since 1970 uint32_t nanosec; // Nanoseconds since 'seconds' } ntime_t; @@ -27,14 +34,22 @@ typedef struct { } header_t; typedef struct { - uint32_t seq; // Current sequence counter + uint16_t valid; // Message valid bits + uint16_t device; // Device ID to use + ntime_t world; // World time (since 1970) + ntime_t start; // Transmit start time + ntime_t period; // Transmit period +} init_msg_t; + +typedef struct { ntime_t time; // Time of previous message } sync_msg_t; typedef struct { uint16_t device; // Device ID uint16_t event; // Event ID - ntime_t time; // Timestamp + ntime_t world; // UTC Time of event + ntime_t local; // Time since turn-on } event_msg_t; #pragma pack()