OSDN Git Service

Changed the implementation with lib.
[kozos-expbrd/kozos_expbrd.git] / firm / sample / simple_mp3_player / target / os / task_command.c
1
2 #include "defines.h"
3 #include "kozos.h"
4 #include "lib.h"
5 #include "driver_console.h"
6 #include "ntshell.h"
7
8 int func_read(char *buf, int cnt)
9 {
10   int i;
11   for (i = 0; i < cnt; i++) {
12     char *p;
13     int size;
14     /* ¥³¥ó¥½¡¼¥ë¤«¤é¤Î¼õ¿®Ê¸»úÎó¤ò¼õ¤±¼è¤ë */
15     kz_recv(MSGBOX_ID_CONSINPUT, &size, &p);
16     buf[i] = p[0];
17     kz_kmfree(p);
18   }
19   return 0;
20 }
21
22 int func_write(const char *buf, int cnt)
23 {
24   int i;
25   for (i = 0; i < cnt; i++) {
26     putc(buf[i]);
27   }
28   return 0;
29 }
30
31 int func_callback(const char *text, void *extobj)
32 {
33   if (strlen(text) > 0) {
34     puts((unsigned char *)text);
35     puts("\n");
36   }
37   return 0;
38 }
39
40 int task_command(int argc, char *argv[])
41 {
42   ntshell_t ntshell;
43
44   console_use(SERIAL_DEFAULT_DEVICE);
45
46   while (1) {
47     ntshell_execute(&ntshell, func_read, func_write, func_callback, NULL);
48   }
49
50   return 0;
51 }
52