]> Pileus Git - ~andy/csm213a-hw/commitdiff
Update message definitions
authorAndy Spencer <andy753421@gmail.com>
Tue, 11 Mar 2014 07:13:22 +0000 (07:13 +0000)
committerAndy Spencer <andy753421@gmail.com>
Wed, 12 Mar 2014 20:10:29 +0000 (20:10 +0000)
hw2/control.c
hw2/main.cpp
hw2/messages.h

index 743c0a32ce78f54bbc2b7246127c1cd22ccdb08c..ea10f9b9cff340510b2489276baac3ce0d1521c0 100644 (file)
@@ -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+");
index 72beb38c7858f51dc40256ec126f1db294cf757b..d32dd0c78cd68cd3baded568d12bbbdd8ace9dad 100644 (file)
@@ -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));
index af40683c9628f79a340fd49069cdf60bc1d76b07..cefdecfeda6c15848948f72184f767bd43d574c5 100644 (file)
@@ -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()