summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschodet2003-04-26 13:34:16 +0000
committerschodet2003-04-26 13:34:16 +0000
commitdab8d405a6b7089d646e1dc3cb902b28da24e78d (patch)
tree39a9a54faa879a24301bc930ab5618c59f05a737
parent507fbba2228174768553c5b4e832a4e2d4f3cc89 (diff)
Mod: Gestion des erreurs.
-rw-r--r--2003/i/buzz/src/busp/GNUmakefile5
-rw-r--r--2003/i/buzz/src/busp/test_busp.cc45
2 files changed, 31 insertions, 19 deletions
diff --git a/2003/i/buzz/src/busp/GNUmakefile b/2003/i/buzz/src/busp/GNUmakefile
index 7406b5a..3fe815e 100644
--- a/2003/i/buzz/src/busp/GNUmakefile
+++ b/2003/i/buzz/src/busp/GNUmakefile
@@ -3,9 +3,12 @@ CXXFLAGS = -Wall -g
CPPFLAGS = -I$(SRCDIR)
TARGETS = test_busp
-test_busp_SOURCES = busp.cc test_busp.cc
+test_busp_SOURCES = busp.cc test_busp.cc $(SRCDIR)/erreur/erreur.a
all: $(TARGETS)
test_busp: $(test_busp_SOURCES:%.cc=%.o)
$(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS)
+
+clean:
+ rm -f $(TARGETS) *.o
diff --git a/2003/i/buzz/src/busp/test_busp.cc b/2003/i/buzz/src/busp/test_busp.cc
index ef15858..81bc21a 100644
--- a/2003/i/buzz/src/busp/test_busp.cc
+++ b/2003/i/buzz/src/busp/test_busp.cc
@@ -3,6 +3,7 @@
// Copyright (C) 2003 Nicolas Schodet
//
#include "busp.h"
+#include "erreur/erreur.h"
#include <iostream>
#include <cstdlib>
@@ -10,25 +11,33 @@
int
main (int argc, char **argv)
{
- Busp busp;
- int addr, data;
- switch (argc)
+ try
{
- case 3:
- // Ecriture.
- addr = strtol (argv[1], 0, 0);
- data = strtol (argv[2], 0, 0);
- cout << "write " << addr << " " << data << endl;
- busp.write (addr, data);
- break;
- case 2:
- // Lecture.
- addr = strtol (argv[1], 0, 0);
- cout << "read " << addr << " = " << busp.read (addr) << endl;
- break;
- default:
- cerr << argv[0] << ": teste le bus parallèle." << endl
- << "\t" << argv[0] << " adresse [donnée]" << endl;
+ Busp busp;
+ int addr, data;
+ switch (argc)
+ {
+ case 3:
+ // Ecriture.
+ addr = strtol (argv[1], 0, 0);
+ data = strtol (argv[2], 0, 0);
+ cout << "write " << addr << " " << data << endl;
+ busp.write (addr, data);
+ break;
+ case 2:
+ // Lecture.
+ addr = strtol (argv[1], 0, 0);
+ cout << "read " << addr << " = " << busp.read (addr) << endl;
+ break;
+ default:
+ cerr << argv[0] << ": teste le bus parallèle." << endl
+ << "\t" << argv[0] << " adresse [donnée]" << endl;
+ return 1;
+ }
+ }
+ catch (const std::exception &e)
+ {
+ cerr << e.what ();
return 1;
}
return 0;