/** \file canmon.c CAN bus monitor for the SJA1000 \author Cristiano Brudna \date 2001, 2002, 2003 University of Ulm, Germany This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include #include #include #include #include #include #include "can.h" #include "canlib.h" int can, done = 0; int plot = 0; /* text format */ char *BLACK = "\033[30m", *RED = "\033[31m", *GREEN = "\033[32m", *YELLOW = "\033[33m", *BLUE = "\033[34m", *MAGENTA = "\033[35m", *CYAN = "\033[36m", *WHITE = "\033[37m", *RESET = "\033[m", *BOLD = "\033[1m", *ITALIC = "\033[3m", *UNDERLINE = "\033[4m", *INVERSE = "\033[7m", *CROSSEDPOUT = "\033[9m"; void siginthandler(int a) { if(!plot) showStatus(can); done = 1; } void monitor(void) { int n = 0, i, ret; long long int time, start_time=-1; canmsg msg; if(!plot) printf("type -> identifier [ data ] timestamp \n\n"); while(!done) { ret = read(can, &msg, sizeof(canmsg)); if(ret > 0) { n++; if(!plot) { printf(BOLD); if(msg.type == EXTENDED) printf("Extended"); else printf("Standard"); if(msg.rtr == 1) printf(" remote"); else printf(" data"); printf(" frame -> "); printf(RESET); printf(CYAN); printf("0x%x ", msg.id); printf(RESET); printf("["); printf(GREEN); for(i=0; i