X-Git-Url: http://pileus.org/git/?p=~andy%2Fcsm213a-hw;a=blobdiff_plain;f=hw2%2Fmain_comm.c;fp=hw2%2Fmain_comm.c;h=118f6b3cd42f2499528829e5568fd7c1f00a490e;hp=d5c66b168c7a66f1cc89ff7988cf6ee4245dd359;hb=3519f0f7a6ced0a3a4419eac56fe49cd2c2fa938;hpb=6cbe6f47d7ffc6959df5a74a33d789575f4746f4 diff --git a/hw2/main_comm.c b/hw2/main_comm.c index d5c66b1..118f6b3 100644 --- a/hw2/main_comm.c +++ b/hw2/main_comm.c @@ -228,12 +228,6 @@ 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) - emit_set_start(comm_read_time(body->start)); - - 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)); @@ -244,6 +238,13 @@ void comm_handle_init(header_t *head, init_msg_t *body) if (body->control & MSG_CTL_BEGIN_SYNC) comm_sync_due = tdma_time() + comm_sync_delay; + + // Run these after world time is valid + if (body->control & MSG_CTL_VALID_START) + emit_set_start(comm_read_time(body->start)); + + if (body->control & MSG_CTL_VALID_PERIOD) + emit_set_period(comm_read_time(body->period)); } /**