[FIX] us -> ns + refactoring
authorNikita Kalyazin <n.kalyazin@samsung.com>
Tue, 2 Jul 2013 07:54:23 +0000 (11:54 +0400)
committerNikita Kalyazin <n.kalyazin@samsung.com>
Tue, 2 Jul 2013 07:54:23 +0000 (11:54 +0400)
daemon/da_data.c
daemon/da_protocol.h
daemon/sys_stat.c

index 62a7f8f..3b856a0 100644 (file)
@@ -213,7 +213,7 @@ int fill_data_msg_head (struct msg_data_t *data, uint32_t msgid, uint32_t seq, u
        data->seq_num = seq; // TODO fill good value
        gettimeofday(&time, NULL);
        data->sec = time.tv_sec;
-       data->usec = time.tv_usec;
+       data->nsec = time.tv_usec * 1000;
        data->len = len;
        return 0;
 }
index 2060f4c..62dc8ca 100644 (file)
@@ -110,7 +110,7 @@ struct msg_data_t {
        uint32_t id;
        uint32_t seq_num;
        uint32_t sec;
-       uint32_t usec;
+       uint32_t nsec;
        uint32_t len;
        char payload[0];
 };
index f335c94..157bce2 100644 (file)
@@ -2231,13 +2231,6 @@ struct msg_data_t *pack_system_info(struct system_info_t *sys_info)
        struct msg_data_t *msg = NULL;
        char *p = NULL;
        int i = 0;
-       struct timeval tv;
-
-       uint32_t id = NMSG_SYSTEM;
-       uint32_t seq_num = 0; // TODO
-       gettimeofday(&tv, NULL);
-       uint32_t sec = tv.tv_sec;
-       uint32_t usec = tv.tv_usec;
        uint32_t len = sizeof(*sys_info) -
                (sizeof(sys_info->thread_load) +
                 sizeof(sys_info->process_load)) +
@@ -2250,11 +2243,8 @@ struct msg_data_t *pack_system_info(struct system_info_t *sys_info)
                LOGE("Cannot alloc message: %d bytes\n", len);
                return NULL;
        }
-       msg->id = id;
-       msg->seq_num = seq_num;
-       msg->sec = sec;
-       msg->usec = usec;
-       msg->len = len;
+
+       fill_data_msg_head(msg, NMSG_SYSTEM, 0, len);
        p = msg->payload;
        
        pack_int(p, sys_info->energy);