]> Pileus Git - ~andy/csm213a-hw/blobdiff - hw2/main_comm.c
Split start and period set functions
[~andy/csm213a-hw] / hw2 / main_comm.c
index a9dbf7757baf97eb27d12629ec2003ab8d445ff5..54cdffcf23d18b9025359e8836f36d6a1d6d56c1 100644 (file)
@@ -227,18 +227,14 @@ void comm_handle_init(header_t *head, init_msg_t *body)
        if (body->control & MSG_CTL_VALID_DEVICE)
                comm_device_id = body->device;
 
-       if (body->control & MSG_CTL_VALID_START ||
-           body->control & MSG_CTL_VALID_PERIOD) {
-               uint64_t start  = comm_read_time(body->start);
-               uint64_t period = comm_read_time(body->period);
-               emit_enable(start, period);
-       }
+       if (body->control & MSG_CTL_VALID_START)
+               emit_set_start(comm_read_time(body->start));
 
-       if (body->control & MSG_CTL_VALID_WORLD) {
-               uint64_t world = comm_read_time(body->world);
-               uint64_t local = tdma_time();
-               time_ext_init(local, world);
-       }
+       if (body->control & MSG_CTL_VALID_PERIOD)
+               emit_set_period(comm_read_time(body->period));
+
+       if (body->control & MSG_CTL_VALID_WORLD)
+               time_ext_init(tdma_time(), comm_read_time(body->world));
 
        if (body->control & MSG_CTL_RELAY_MODE)
                comm_relay_mode = 1;