remove CVS
[aversive.git] / modules / debug / error / test / main.c
1 /*  
2  *  Copyright Droids Corporation, Microb Technology, Eirbot (2005)
3  * 
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation; either version 2 of the License, or
7  *  (at your option) any later version.
8  *
9  *  This program is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License
15  *  along with this program; if not, write to the Free Software
16  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  *
18  *  Revision : $Id: main.c,v 1.6.4.2 2007-05-23 17:18:12 zer0 Exp $
19  *
20  */
21
22 #include <aversive.h>
23
24 #include <uart.h>
25 #include <aversive/wait.h>
26 #include <stdio.h>
27 #include <stdarg.h>
28
29 #include <aversive/error.h>
30 #include <aversive/pgmspace.h>
31
32
33 void mylog(struct error * e, ...)
34 {
35         va_list ap;
36
37         va_start(ap, e);
38         printf_P(PSTR("[%d]: E%d "), e->severity, e->err_num);
39         vfprintf_P(stdout, e->text, ap); 
40         printf_P(PSTR(", "));
41         printf_P(e->file);
42         printf_P(PSTR(", L%d\n"), e->line);
43         va_end(ap);
44 }
45
46 int main(void)
47 {
48 #ifndef HOST_VERSION
49         /* uart stuff */
50         uart_init();  
51         sei();
52         fdevopen(uart0_dev_send,NULL);
53 #endif
54         
55         /* hello */
56         printf_P(PSTR("test error module\n"));
57         printf("%d\n",sizeof(va_list));
58         
59         /* don't display anything */
60         ERROR(54, "pouet");
61         
62         error_register_emerg(mylog);
63         error_register_error(mylog);
64         
65         EMERG(3, "this is an emerg log");
66         EMERG(3, "this is an emerg log with param %d", 453);
67         ERROR(54, "this is another log, level = error");
68         
69         /* don't display it, fcts are not registered */
70         WARNING(4, "not displayed");
71         NOTICE(5, "not displayed");
72         DEBUG(6, "not displayed");
73         
74         while(1);
75         return 0;
76 }