ArDrone SDK 1.8 added
[mardrone] / mardrone / ARDrone_SDK_Version_1_8_20110726 / ARDroneLib / VP_SDK / Examples / elinux / api_serial_ofile.c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <ctype.h>
4 #include <termios.h>
5 #include <fcntl.h>
6 #include <errno.h>
7 #include <unistd.h>
8
9 #include <VP_Api/vp_api.h>
10 #include <VP_Api/vp_api_error.h>
11 #include <VP_Stages/vp_stages_configs.h>
12 #include <VP_Stages/vp_stages_io_console.h>
13 #include <VP_Stages/vp_stages_io_com.h>
14 #include <VP_Stages/vp_stages_io_file.h>
15 #include <VP_Os/vp_os_print.h>
16 #include <VP_Os/vp_os_malloc.h>
17 #include <VP_Os/vp_os_delay.h>
18
19
20 #define NB_STAGES 2
21
22
23 PIPELINE_HANDLE pipeline_handle;
24
25
26 int
27 main(int argc, char **argv)
28 {
29   vp_api_io_pipeline_t    pipeline;
30   vp_api_io_data_t        out;
31   vp_api_io_stage_t       stages[NB_STAGES];
32
33   vp_com_t                          com;
34   vp_stages_input_com_config_t      icc;
35   vp_com_serial_config_t            config;
36   vp_stages_output_file_config_t    ofc;
37
38
39   vp_os_memset(&icc,0,sizeof(vp_stages_input_com_config_t));
40   vp_os_memset(&ofc,0,sizeof(vp_stages_output_file_config_t));
41   vp_stages_fill_default_config(UART1_COM_CONFIG, &config, sizeof(config));
42   vp_os_memset(&com, 0, sizeof(vp_com_t));
43
44   com.type                = VP_COM_SERIAL;
45   icc.com                 = &com;
46   icc.socket.type         = VP_COM_CLIENT;
47   icc.config              = (vp_com_config_t *)&config;
48   icc.buffer_size         = 1024;
49
50
51   ofc.name = "toto.out";
52
53
54   stages[0].type    = VP_API_INPUT_SOCKET;
55   stages[0].cfg     = (void *)&icc;
56   stages[0].funcs   = vp_stages_input_com_funcs;
57
58   stages[1].type    = VP_API_OUTPUT_FILE;
59   stages[1].cfg     = (void *)&ofc;
60   stages[1].funcs   = vp_stages_output_file_funcs;
61
62   pipeline.nb_stages = NB_STAGES;
63   pipeline.stages = &stages[0];
64
65
66   vp_api_open(&pipeline, &pipeline_handle);
67   out.status = VP_API_STATUS_PROCESSING;
68   while(SUCCEED(vp_api_run(&pipeline, &out)) && (out.status == VP_API_STATUS_PROCESSING || out.status == VP_API_STATUS_STILL_RUNNING))
69     {
70       //vp_os_delay( 200 );
71     }
72
73   vp_api_close(&pipeline, &pipeline_handle);
74
75   return EXIT_SUCCESS;
76 }