6 #include <VP_Api/vp_api.h>
7 #include <VP_Api/vp_api_error.h>
8 #include <VP_Stages/vp_stages_configs.h>
9 #include <VP_Stages/vp_stages_io_console.h>
10 #include <VP_Stages/vp_stages_io_com.h>
11 #include <VP_Stages/vp_stages_io_file.h>
12 #include <VP_Os/vp_os_print.h>
13 #include <VP_Os/vp_os_malloc.h>
15 #include <ardrone_tool/Com/config_com.h>
16 #include <ardrone_tool/ardrone_tool.h>
22 static PIPELINE_HANDLE pipeline_handle;
23 static char filename[100];
26 DEFINE_THREAD_ROUTINE(remote_console, data)
28 vp_api_io_pipeline_t pipeline;
30 vp_api_io_stage_t stages[NB_STAGES];
32 vp_stages_input_com_config_t icc;
33 vp_stages_output_file_config_t ofc;
38 gettimeofday(&tv,NULL);
39 localtime_r(&tv.tv_sec, &atm);
40 sprintf(&filename[0], "logs_%04d%02d%02d_%02d%02d%02d.txt",
41 atm.tm_year+1900, atm.tm_mon+1, atm.tm_mday,
42 atm.tm_hour, atm.tm_min, atm.tm_sec);
44 vp_os_memset( &icc, 0, sizeof(vp_stages_input_com_config_t));
45 vp_os_memset( &ofc, 0, sizeof(vp_stages_output_file_config_t));
47 icc.com = COM_REMOTE_CONSOLE();
48 icc.config = COM_CONFIG_REMOTE_CONSOLE();
49 icc.connection = COM_CONNECTION_REMOTE_CONSOLE();
50 icc.buffer_size = 1024;
51 COM_CONFIG_SOCKET_REMOTE_CONSOLE(&icc.socket, VP_COM_CLIENT, PRINTF_PORT, wifi_ardrone_ip);
53 ofc.name = &filename[0];
55 stages[0].type = VP_API_INPUT_SOCKET;
56 stages[0].cfg = (void *)&icc;
57 stages[0].funcs = vp_stages_input_com_funcs;
59 stages[1].type = VP_API_OUTPUT_CONSOLE;
61 stages[1].funcs = vp_stages_output_console_funcs;
63 stages[2].type = VP_API_OUTPUT_FILE;
64 stages[2].cfg = (void *)&ofc;
65 stages[2].funcs = vp_stages_output_file_funcs;
67 pipeline.nb_stages = NB_STAGES;
68 pipeline.stages = &stages[0];
70 if(SUCCEED(vp_api_open(&pipeline, &pipeline_handle)))
72 out.status = VP_API_STATUS_PROCESSING;
73 while(SUCCEED(vp_api_run(&pipeline, &out)) && (out.status == VP_API_STATUS_PROCESSING || out.status == VP_API_STATUS_STILL_RUNNING) && !ardrone_tool_exit());
74 vp_api_close(&pipeline, &pipeline_handle);