ArDrone SDK 1.8 added
[mardrone] / mardrone / ARDrone_SDK_Version_1_8_20110726 / ARDroneLib / VP_SDK / Examples / elinux / atcodec_client.c
1
2 #include <stdio.h>
3 #include <stdlib.h>
4
5 #include <ATcodec/ATcodec_api.h>
6 #include <VP_Stages/vp_stages_io_com.h>
7
8 #define AT_MESSAGES_HEADER "ATcodec/ATcodec_Messages_ex.h"
9
10 #include "ATcodec/ATcodec_api.h"
11 #include "VP_Os/vp_os_types.h"
12 #include "VP_Os/vp_os_thread.h"
13 #include "VP_Os/vp_os_delay.h"
14 #include "VP_Os/vp_os_print.h"
15 #include <Examples/common/atcodec_client.h>
16
17 #ifndef AT_MESSAGES_HEADER
18 #error You need to define AT_MESSAGES_HEADER
19 #endif
20
21 extern AT_CODEC_MSG_IDS ids;
22
23 #define INTRA_CMD_DELAY 10
24
25 THREAD_RET
26 thread_send_commands (THREAD_PARAMS data)
27 {
28   while(1)
29     {
30       ATcodec_Queue_Message_valist(ids.AT_MSG_ATCMD_CGMI);
31       vp_os_delay(INTRA_CMD_DELAY);
32       ATcodec_Queue_Message_valist(ids.AT_MSG_ATCMD_CGMI);
33       vp_os_delay(INTRA_CMD_DELAY);
34       //vp_os_thread_yield();
35
36       ATcodec_Queue_Message_valist(ids.AT_MSG_ATCMD_PM_QW,1);
37       vp_os_delay(INTRA_CMD_DELAY);
38       ATcodec_Queue_Message_valist(ids.AT_MSG_ATCMD_PM_QW,1);
39       vp_os_delay(INTRA_CMD_DELAY);
40       //vp_os_thread_yield();
41
42       ATcodec_Queue_Message_valist(ids.AT_MSG_ATCMD_PM_EXE,1,50);
43       vp_os_delay(INTRA_CMD_DELAY);
44       ATcodec_Queue_Message_valist(ids.AT_MSG_ATCMD_PM_EXE,1,50);
45       vp_os_delay(INTRA_CMD_DELAY);
46       //vp_os_thread_yield();
47     }
48 }
49
50 int main(int argc, char **argv)
51 {
52   THREAD_HANDLE atcodec_test_handle;
53   THREAD_HANDLE atcodec_test_handle2;
54   THREAD_HANDLE cmds_handle;
55
56   AT_CODEC_FUNCTIONS_PTRS ptrs =
57     {
58       .init     = AT_CODEC_Client_init,
59       .shutdown = AT_CODEC_Client_shutdown,
60       .open     = AT_CODEC_Client_open,
61       .close    = AT_CODEC_Client_close,
62       .read     = AT_CODEC_Client_read,
63       .write    = AT_CODEC_Client_write,
64     };
65
66   ATcodec_Init_Library(&ptrs);
67
68   vp_os_thread_create(thread_ATcodec_Commands_Client, 0, &atcodec_test_handle);
69   vp_os_thread_create(thread_send_commands, 0, &cmds_handle);
70   vp_os_thread_create(thread_ATcodec_Commands_Server, 0, &atcodec_test_handle2);
71
72   vp_os_thread_join(cmds_handle);
73   vp_os_thread_join(atcodec_test_handle2);
74   vp_os_thread_join(atcodec_test_handle);
75
76   return EXIT_SUCCESS;
77 }
78