ETrobocon2017 - 片山研究所モデルベース開発推進事業部
app.cpp
[詳解]
1 
9 #include "ev3api.h"
10 #include "app.h"
11 #include "util.h"
12 #include "EtRobocon2017.h" // ETロボコン2017
13 #include "SelfLocalization.h"
14 
15 #if defined(BUILD_MODULE)
16 #include "module_cfg.h"
17 #else
18 #include "kernel_cfg.h"
19 #endif
20 
21 #define DEBUG
22 
23 #ifdef DEBUG
24 #define _debug(x) (x)
25 #else
26 #define _debug(x)
27 #endif
28 
29 static int g_bluetooth_command = 0; // Bluetoothコマンド 1:リモートスタート
30 static FILE *g_bluetooth = NULL; // Bluetoothファイルハンドル
31 
32 /* メインタスク */
33 void main_task( intptr_t unused )
34 {
35  /* Open Bluetooth file */
36  g_bluetooth = ev3_serial_open_file( EV3_SERIAL_BT );
37  assert( g_bluetooth != NULL );
38 
39  /* Bluetooth通信タスクの起動 */
40  act_tsk( BT_TASK );
41 
42 
43  msg_f("ET-Robocon2017 Hirakobasample", 1);
44  msg_f(" create from github.com/korosuke613/etrobocon2017", 2);
45 
46  EtRobocon2017 etrobocon;
47  etrobocon.start( g_bluetooth_command );
48 
49 
50 
51  ter_tsk( BT_TASK );
52  fclose( g_bluetooth );
53 
54  ext_tsk();
55 }
56 
64 void bt_task( intptr_t unused )
65 {
66  while( 1 )
67  {
68  uint8_t c = fgetc( g_bluetooth ); /* 受信 */
69  switch( c )
70  {
71  case '1':
72  g_bluetooth_command = 1;
73  break;
74  default:
75  break;
76  }
77  fputc( c, g_bluetooth ); /* エコーバック */
78  }
79 }
main的なクラス
void main_task(intptr_t unused)
Definition: app.cpp:37
void bt_task(intptr_t unused)
Definition: app.cpp:98
void msg_f(const char *str, int32_t line)
Definition: util.cpp:17
void start(int)