(toppers-etrobo 126) Re: time.h clock()について
Yutaka MATSUBARA
yutaka @ ertl.jp
2018年 6月 14日 (木) 14:34:46 JST
東奥さま
名古屋大学の松原です。
clock()の使用目的は,ある区間の処理時間を測定したいという理解でよろしいでしょうか?
もしその目的でしたら,OSの時間計測機能を利用すると簡単です。サンプルプログラムが
hrp2/test/perf0.c
にありますので,これを参考にやってみて頂けますでしょうか?
On 2018/06/12 0:50, 東奥航志郎 wrote:
> 開発者様及びメーリングリスト登録者様、いつもお世話になっております。
>
> EV3rtにて、時間経過の判断をしたいと思い、C言語標準ライブラリのtime.hの
> clock()使用してみたかったのですが、
> コンパイル時にエラーが発生し、使用することができませんでした。
> EV3rtでは使用できないのでしょうか?
> 以下、私の書いたプログラムと、コンパイルエラーのログを記します。
> もしよろしければご回答お願いいたします。
> 使用不可の場合は、代替案等ご教授いただけると幸いです…
>
> 【開発環境】
> macOS High Sierra
> EV3rt β7
> gcc-arm-none-eabi-6-2017-q1-update
>
> /*******************************************************************************************************************************/
> app.c
>
> #include "ev3api.h"
> #include "app.h"
> #include <stdio.h>
> #include <stdbool.h>
> #include <time.h>
>
> #if defined(BUILD_MODULE)
> #include "module_cfg.h"
> #else
> #include "kernel_cfg.h"
> #endif
>
> #define DEBUG
>
> #ifdef DEBUG
> #define _debug(x) (x)
> #else
> #define _debug(x)
> #endif
>
> char str[20];
>
> clock_t start_point;
>
> void main_task(intptr_t unused)
> {
> while(ev3_button_is_pressed (4)==false){
> start_point = clock();
> sprintf(str,"%ld”,start_point);
> ev3_lcd_draw_string(str,0,0);
> }
> }
>
> /*******************************************************************************************************************************/
>
> koushiro-MacBook-Air:workspace koushiro$ make app=Kou_timer_test
> rm -rf /Users/koushiro/ev3rt/hrp2/sdk/workspace/.././OBJ/
> cd /Users/koushiro/ev3rt/hrp2/sdk/workspace/.././OBJ/ && \
> /Users/koushiro/ev3rt/hrp2/sdk/workspace/../../configure -T ev3_gcc -A
> app \
> -a ../workspace/Kou_timer_test \
> -t ../workspace/Kou_timer_test \
> -D ../.. \
> -L ../common/library \
> -l c \
> -m .ev3rt_temp_Makefile -o "-DBUILD_MODULE" \
> -U "" && \
> rm
> /Users/koushiro/ev3rt/hrp2/sdk/workspace/Kou_timer_test/.ev3rt_temp_Makefile
> && \
> mv .ev3rt_temp_Makefile Makefile && \
> make clean
> configure: Generating .ev3rt_temp_Makefile from
> ../workspace/Kou_timer_test/.ev3rt_temp_Makefile.
> configure: Generating app.c from ../workspace/Kou_timer_test/app.c.
> configure: Generating app.h from ../workspace/Kou_timer_test/app.h.
> configure: Generating app.cfg from ../workspace/Kou_timer_test/app.cfg.
> rm -f cfg1_out cfg1_out.o cfg1_out.c cfg1_out.syms cfg1_out.srec
> module_cfg.h module_cfg.c \#* *~ *.o
> CFG[1] module_cfg.h
> CFG[2] module_cfg.h
> CC module_cfg.c
> CC ../../library/t_perror.c
> CC ../../library/strerror.c
> CC ../../library/vasyslog.c
> CC ../../target/ev3_gcc/TLSF-2.4.6/src/tlsf.c
> CC app.c
> CC ../common/ev3api/src/ev3api.c
> CC ev3api_cfg.c
> CC ../common/ev3api/src/ev3api_battery.c
> CC ../common/ev3api/src/ev3api_brick.c
> CC ../common/ev3api/src/ev3api_fs.c
> CC ../common/ev3api/src/ev3api_speaker.c
> CC ../common/ev3api/src/ev3api_lcd.c
> CC ../common/ev3api/src/ev3api_motor.c
> CC ../common/ev3api/src/ev3api_newlib.c
> CC ../common/ev3api/src/ev3api_sensor.c
> LD app
> /usr/local/gcc-arm-none-eabi-6-2017-q1-update/bin/../lib/gcc/arm-none-eabi/6.3.1/../../../../arm-none-eabi/lib/libc.a(lib_a-timesr.o):
> In function `_times_r':
> timesr.c:(.text._times_r+0x8): undefined reference to `_times'
> collect2: error: ld returned 1 exit status
> make[1]: *** [app] Error 1
> make: *** [app] Error 2
--
松原豊