1 /*
2 * Copyright (C) 2015-2021 Alibaba Group Holding Limited
3 */
4 #if AOS_COMP_CLI
5 #include <stdio.h>
6 #include <assert.h>
7 #include "debug_api.h"
8 #include "aos/debug.h"
9 #include "aos/cli.h"
10 #ifdef AOS_COMP_ULOG
11 #include "ulog/ulog.h"
12 #endif
13
14 #define MAX_32 ((long)(~0UL))
15 #define MAX_64 ((long long)(~0ULL))
16
17 typedef int (*print_func)(const char *fmt, ...);
18
print_test(int (* print_func)(const char * fmt,...))19 static void print_test(int (*print_func)(const char *fmt, ...))
20 {
21 int a = 1234;
22 unsigned long long b = 12345678;
23 float c = 3.14;
24 double d = 5.6789;
25
26 print_func("int : %d max_32 : 0x%X\r\n", a, MAX_32);
27 print_func("ll : %lld max_64 : 0x%llX\r\n", b, MAX_64);
28 print_func("float : %f\r\n", c);
29 print_func("double : %lf\r\n", d);
30 }
31
32 /*test for printf when irq disable, which mostly test uart_send_dirver of vendor*/
print_test_cmd(int argc,char ** argv)33 static void print_test_cmd(int argc, char **argv)
34 {
35 CPSR_ALLOC();
36
37 printk("\r\nbegin test printk\r\n");
38 print_test(printk);
39 RHINO_CPU_INTRPT_DISABLE();
40 printk("printk : hello world ! yes we can\r\n");
41 RHINO_CPU_INTRPT_ENABLE();
42 printk("\r\nprintk test end\r\n");
43
44 printf("\r\nbegin test printf\r\n");
45 print_test(printf);
46 RHINO_CPU_INTRPT_DISABLE();
47 printf("printf : hello world ! yes we can\r\n");
48 RHINO_CPU_INTRPT_ENABLE();
49 printf("\r\nprintf test end\r\n");
50 }
ALIOS_CLI_CMD_REGISTER(print_test_cmd,print_t,Console Cmd Print Test)51 ALIOS_CLI_CMD_REGISTER(print_test_cmd, print_t, Console Cmd Print Test)
52
53 /* test for ulog encoder to fs*/
54 #ifdef AOS_COMP_ULOG
55 static void ulog_encode_fs_test(int argc, char **argv)
56 {
57 static int cnt = 0;
58
59 LOGE("AOS", "hello alibaba : %d\n", cnt++);
60 }
ALIOS_CLI_CMD_REGISTER(ulog_encode_fs_test,uet,Console ulog encode fs test)61 ALIOS_CLI_CMD_REGISTER(ulog_encode_fs_test, uet, Console ulog encode fs test)
62 #endif
63
64 /* test for panic trigger in task*/
65 static void panic_trigger(int argc, char **argv)
66 {
67 #ifdef OS_UDF
68 OS_UDF();
69 #endif
70 }
ALIOS_CLI_CMD_REGISTER(panic_trigger,panic,Console trigger system panic)71 ALIOS_CLI_CMD_REGISTER(panic_trigger, panic, Console trigger system panic)
72
73 /* test for fatal error trigger in task*/
74 static void fatal_error_trigger(int argc, char **argv)
75 {
76 assert(0);
77 }
ALIOS_CLI_CMD_REGISTER(fatal_error_trigger,assert,Trigger assert)78 ALIOS_CLI_CMD_REGISTER(fatal_error_trigger, assert, Trigger assert)
79
80
81 static void hung_trigger(int argc, char **argv)
82 {
83 CPSR_ALLOC();
84
85 RHINO_CPU_INTRPT_DISABLE();
86 (void)cpsr;
87 aos_msleep(1000);
88 }
ALIOS_CLI_CMD_REGISTER(hung_trigger,hung,Trigger system hung)89 ALIOS_CLI_CMD_REGISTER(hung_trigger, hung, Trigger system hung)
90
91 __attribute__((weak)) void alios_debug_pc_show(int argc, char **argv)
92 {
93 return;
94 }
95 ALIOS_CLI_CMD_REGISTER(alios_debug_pc_show, pcshow, Show pc addr region)
96
97 #endif /* AOS_COMP_CLI */
98