VCOM Linux Driver
Advantech Inc.
Loading...
Searching...
No Matches
vcom_debug.h
Go to the documentation of this file.
1#ifndef _VCOM_DEBUG_H
2#define _VCOM_DEBUG_H
3#include <time.h>
4#define ALL_SPACE 12
5/*
6 * To show the stack content
7 * The format should be like this :
8 *
9 * Function : <func>
10 * Time : <hh/mm/ss>
11 * State : <state>
12 * | |
13 * | Sync |
14 * | Net Up |
15 * | Net Down |
16 * --------------
17 */
18static inline void _lineup(struct stk_vc *stk, int fram, int count)
19{
20 int i;
21 for(i = 0; i < fram/2; i++){
22 printf(" ");
23 }
24 printf("%s", stk->stk_stat[count]->name());
25 for(i = 0; i < fram/2; i++){
26 printf(" ");
27 }
28 if(fram % 2){
29 printf(" ");
30 }
31}
32
33static inline void stk_display(struct stk_vc *stk, const char *func)
34{
35 int i;
36 int len, fram;
37 time_t t = time(NULL);
38 struct tm *lt = localtime(&t);
39
40 if(stk_empty(stk)){
41 printf("stack empty ...\n");
42 return;
43 }
44 printf("Function : %s\n", func);
45 printf("Time : %02d:%02d:%02d\n", lt->tm_hour, lt->tm_min, lt->tm_sec);
46 printf("Stack :\n");
47 printf("|%*s|\n", ALL_SPACE, " ");
48 for(i = stk->top; i >= 0; i--){
49 len = strlen(stk->stk_stat[i]->name());
50 fram = ALL_SPACE - len;
51 printf("|");
52 _lineup(stk, fram, i);
53 printf("|\n");
54 }
55 for(i = 0; i <= ALL_SPACE+2; i++){
56 printf("-");
57 }
58 printf("\n");
59}
60#endif
Definition vcom.h:25
struct vc_ops * stk_stat[STACK_MAX]
Definition vcom.h:27
int top
Definition vcom.h:26
char *(* name)(void)
Definition vcom.h:71
#define stk_empty(a)
Definition vcom.h:23
#define ALL_SPACE
Definition vcom_debug.h:4
unsigned short len
Definition vcom_proto.h:3