From 858360934e26897654f92bb0283e280f52978a39 Mon Sep 17 00:00:00 2001 From: Andy Spencer Date: Tue, 11 Mar 2014 07:13:22 +0000 Subject: [PATCH] Update message definitions --- hw2/control.c | 4 ++-- hw2/main.cpp | 6 ++++-- hw2/messages.h | 7 ++++--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/hw2/control.c b/hw2/control.c index 743c0a3..ea10f9b 100644 --- a/hw2/control.c +++ b/hw2/control.c @@ -24,7 +24,7 @@ void dump(const char *label, uint8_t *data, int len) int main(int argc, char **argv) { if (argc < 3) - error("usage: host /dev/ttyACM0 0 sync"); + error("usage: control /dev/ttyACM0 0 sync"); // Parse args char *opt_tty = argv[1]; @@ -61,7 +61,7 @@ int main(int argc, char **argv) body.start.nanosec = 0; //ts.tv_nsec; body.period.seconds = 0; body.period.nanosec = 100000000; - // [ ][ ] + // [s][m][u][n] // Transmit message FILE *fd = fopen(opt_tty, "a+"); diff --git a/hw2/main.cpp b/hw2/main.cpp index 72beb38..d32dd0c 100644 --- a/hw2/main.cpp +++ b/hw2/main.cpp @@ -316,7 +316,8 @@ void serial_send_event(sirq_t *port, uint16_t event, uint64_t local) // Convert timestamp uint64_t world = time_to_world(local); - ntime_t ntime = serial_write_time(world); + ntime_t ltime = serial_write_time(local); + ntime_t wtime = serial_write_time(world); // Message data header_t head = {}; @@ -330,7 +331,8 @@ void serial_send_event(sirq_t *port, uint16_t event, uint64_t local) body.device = serial_device_id; body.event = event; - body.time = ntime; + body.world = ltime; + body.local = wtime; // Transmit message to BBB sirq_write(port, &head, sizeof(head)); diff --git a/hw2/messages.h b/hw2/messages.h index af40683..cefdecf 100644 --- a/hw2/messages.h +++ b/hw2/messages.h @@ -22,7 +22,7 @@ typedef enum { } 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; @@ -36,9 +36,9 @@ typedef struct { typedef struct { 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 - ntime_t world; // World time (since 1970) } init_msg_t; typedef struct { @@ -49,7 +49,8 @@ typedef struct { 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() -- 2.43.2