uartdebugparser.c
来自「tinyos最新版」· C语言 代码 · 共 70 行
C
70 行
/* uartDebugParser.c * * This program parses an log file generated by uartDebugServer.c * The same table of states and events that used by uartDebugServer should be * used here too. If no state-event table is included, will simply display * the raw bytes provided by each node. * * Author: Wei Ye (USC/ISI) * Date: 03/10/2003 * */#include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <errno.h>#include <string.h>#include <sys/types.h>// if debug another component, comment out following line// or include a corresponding debug table, which should be the same// as in uartDebugServer.c#include "smacDebugTab.h"#define MAXBUFLEN 80int main(int argc, char ** argv){ unsigned int numbytes, i, msgNo; char buf[MAXBUFLEN]; unsigned int nodeId, days, hours, minutes, seconds, milisec; FILE *logFile; if (argc != 2) { printf("Usage: uartDebugParser logFile\n"); exit(1); } if ((logFile = fopen(argv[1], "r")) == NULL) { printf("Error: can't open log file.\n"); exit(1); } fgets(buf, MAXBUFLEN, logFile); printf("\n%s\n", buf);/* while ( EOF != fscanf(logFile, "%d %d %d %d %d", &nodeId, &hours, &minutes, &seconds, &milisec)) { printf("Node %d at %02d:%02d:%02d.%02d\n", nodeId, hours, minutes, seconds, milisec);*/ while (EOF != fscanf(logFile, "%d", &nodeId)) { printf("Node %d:\n", nodeId); fscanf(logFile, "%d", &numbytes); // print out debugging info for(i = 0; i < numbytes; i++){ fscanf(logFile, "%d", &msgNo);#ifdef STATE_EVENT if (msgNo >= sizeof(stateEvent)) exit(1); printf(" %s\n", stateEvent[msgNo]);#else printf(" %d\n", msgNo);#endif } printf("\n"); } fclose(logFile); return 0;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?