Controller can controll the Car
authorjunkyu han <junkyu.han@samsung.com>
Thu, 11 Jan 2018 06:45:49 +0000 (15:45 +0900)
committerjunkyu han <junkyu.han@samsung.com>
Thu, 11 Jan 2018 06:45:49 +0000 (15:45 +0900)
inc/communication_center.h
src/app.c
src/communication_by_udp.c
src/communication_center.c
src/resource.c
src/resource_accelerometer.c
src/view.c

index bd27824..d30a8a5 100644 (file)
@@ -33,8 +33,11 @@ typedef enum _communication_state_e {
 } communication_state_e;
 
 typedef struct _commu_data_s {
-       int x;
-       int y;
+       unsigned long long int seq_num;
+       int cmd;
+       int servo;
+       int speed;
+       unsigned long long int time;
 } commu_data_s;
 
 typedef struct _communication_info {
index d14e9e2..33811b6 100644 (file)
--- a/src/app.c
+++ b/src/app.c
@@ -100,4 +100,3 @@ int main(int argc, char* argv[])
 
        return ret;
 }
-
index 51898a6..3a0ebbf 100644 (file)
@@ -122,7 +122,7 @@ static void __send_data(void *user_data)
        GError *error = NULL;
        GIOCondition condi;
        commu_data_s send_data = *(commu_data_s *)user_data;
-       _D("Send data.x[%d], data.y[%d]", send_data.x, send_data.y);
+       _D("Send Servo[%d], Speed[%d]", send_data.servo, send_data.speed);
 
        if (udp_info.commu_info->socket == NULL ||
                        udp_info.commu_info->opponent == NULL) {
index cd64946..7f7fdaa 100644 (file)
@@ -82,7 +82,7 @@ void communication_center_start_communication(void)
        for (i = 0; i < COMMUNICATION_MAX; i++)
        {
                if (communications[i])
-                       communications[i]->communication_start("192.168.0.61", 57984);
+                       communications[i]->communication_start("192.168.1.168", 57984);
        }
 }
 
@@ -90,10 +90,18 @@ void communication_center_send_data(void *user_data)
 {
        int i = 0;
 
+       commu_data_s *commu_data = (commu_data_s *)user_data;
+       if (commu_data == NULL) {
+               _E("Commu data is NULL");
+               return;
+       }
+
+       commu_data->cmd = 2;
+
        for (i = 0; i < COMMUNICATION_MAX; i++)
        {
                if (communications[i])
-                       communications[i]->communication_send_data(user_data);
+                       communications[i]->communication_send_data((void *)commu_data);
        }
 }
 
index dad5928..e3812d8 100644 (file)
@@ -70,7 +70,7 @@ void resource_info_free(resource_info *sensor_info)
        }
 
        free(sensor_info);
-       sensor_info == NULL;
+       sensor_info = NULL;
 }
 
 void resource_start_sensing(void)
index 15d5d59..4a8a885 100644 (file)
@@ -128,8 +128,8 @@ static void __sensor_value_changed_cb(sensor_h sensor, sensor_event_s *event, vo
 
        commu_data_s temp = { NULL, NULL };
 
-       temp.x = event->values[0] * 100;
-       temp.y = event->values[1] * 100;
+       temp.servo = event->values[0] * -100;
+       temp.speed = event->values[1] * -100;
 
        view_update_view_with_data((void *)&temp);
        communication_center_send_data((void *)&temp);
@@ -155,5 +155,13 @@ static void __stop_sensing(void)
                _E("Failed to stop sensor listener event");
                return;
        }
+
+       commu_data_s temp = { NULL, NULL };
+
+       temp.servo = 0;
+       temp.speed = 0;
+
+       view_update_view_with_data((void *)&temp);
+       communication_center_send_data((void *)&temp);
 }
 
index 3660983..c15432d 100644 (file)
@@ -93,8 +93,8 @@ void view_update_view_with_data(void *user_data)
        char x_value[1024];
        char y_value[1024];
 
-       snprintf(x_value, 1024, "%d", data.x);
-       snprintf(y_value, 1024, "%d", data.y);
+       snprintf(x_value, 1024, "%d", data.servo);
+       snprintf(y_value, 1024, "%d", data.speed);
 
        elm_object_part_text_set(view_info.layout, "x_value", x_value);
        elm_object_part_text_set(view_info.layout, "y_value", y_value);