diff options
author | Eunyoung Lee <ey928.lee@samsung.com> | 2017-07-20 05:30:52 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@review.ap-northeast-2.compute.internal> | 2017-07-20 05:30:52 +0000 |
commit | c4e49a08ca2ce6643d9bd8fb13abe0f5dbbb5ade (patch) | |
tree | 2c22d88c72be8ded03de5ff6026f9cd266257961 | |
parent | 1e606b03bc8592c827a9d7895ae76096173ce3e8 (diff) | |
parent | f7f9a950fca66bcae0f170240f95049c0bedeede (diff) | |
download | position-finder-server-c4e49a08ca2ce6643d9bd8fb13abe0f5dbbb5ade.tar.gz position-finder-server-c4e49a08ca2ce6643d9bd8fb13abe0f5dbbb5ade.tar.bz2 position-finder-server-c4e49a08ca2ce6643d9bd8fb13abe0f5dbbb5ade.zip |
Merge "Modified internal value of the ultrasonic sensor"
-rw-r--r-- | src/resource/resource_ultrasonic_sensor.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/resource/resource_ultrasonic_sensor.c b/src/resource/resource_ultrasonic_sensor.c index 1dae292..2dd2b62 100644 --- a/src/resource/resource_ultrasonic_sensor.c +++ b/src/resource/resource_ultrasonic_sensor.c @@ -52,34 +52,34 @@ static int _get_echo_value(int echo_pin_num) return value; } -int resource_read_ultrasonic_sensor(int echo_pin_num, int trig_pin_num, double *out_value) +int resource_read_ultrasonic_sensor(int trig_pin_num, int echo_pin_num, double *out_value) { int ret = 0; double duration = 0.0; struct timeval start_time, end_time, temp_start_time, temp_end_time; - if (!resource_get_info(echo_pin_num)->opened) { - _I("Ultrasonic sensor is initializing..."); + if (!resource_get_info(trig_pin_num)->opened) { + _I("Ultrasonic sensor's trig is initializing..."); - ret = peripheral_gpio_open(echo_pin_num, &resource_get_info(echo_pin_num)->sensor_h); - retv_if(!resource_get_info(echo_pin_num)->sensor_h, -1); + ret = peripheral_gpio_open(trig_pin_num, &resource_get_info(trig_pin_num)->sensor_h); + retv_if(!resource_get_info(trig_pin_num)->sensor_h, -1); - ret = peripheral_gpio_set_direction(resource_get_info(echo_pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_IN); + ret = peripheral_gpio_set_direction(resource_get_info(trig_pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_OUT); retv_if(ret != 0, -1); - resource_get_info(echo_pin_num)->opened = 1; + resource_get_info(trig_pin_num)->opened = 1; } - if (!resource_get_info(trig_pin_num)->opened) { - _I("Ultrasonic sensor is initializing..."); + if (!resource_get_info(echo_pin_num)->opened) { + _I("Ultrasonic sensor's echo is initializing..."); - ret = peripheral_gpio_open(trig_pin_num, &resource_get_info(trig_pin_num)->sensor_h); - retv_if(!resource_get_info(trig_pin_num)->sensor_h, -1); + ret = peripheral_gpio_open(echo_pin_num, &resource_get_info(echo_pin_num)->sensor_h); + retv_if(!resource_get_info(echo_pin_num)->sensor_h, -1); - ret = peripheral_gpio_set_direction(resource_get_info(trig_pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_IN); + ret = peripheral_gpio_set_direction(resource_get_info(echo_pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_IN); retv_if(ret != 0, -1); - resource_get_info(trig_pin_num)->opened = 1; + resource_get_info(echo_pin_num)->opened = 1; } ret = peripheral_gpio_write(resource_get_info(trig_pin_num)->sensor_h, 0); |