FreeCalypso > hg > freecalypso-hwlab
changeset 27:4b7cac119fb5
lcdtest: added our own local exitcodes.h header
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 27 May 2018 21:49:46 +0000 |
parents | 225556110fa6 |
children | de3d3cfcbb35 |
files | lcdtest/busops.c lcdtest/exitcodes.h lcdtest/testmain.c |
diffstat | 3 files changed, 15 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/lcdtest/busops.c Sun May 27 21:36:07 2018 +0000 +++ b/lcdtest/busops.c Sun May 27 21:49:46 2018 +0000 @@ -3,6 +3,7 @@ #include <stdlib.h> #include <unistd.h> #include <ftdi.h> +#include "exitcodes.h" extern struct ftdi_context ftdi; @@ -11,7 +12,7 @@ { if (ftdi_write_data(&ftdi, cmd, cmdlen) != cmdlen) { fprintf(stderr, "FTDI write error: %s\n", ftdi.error_str); - exit(1); + exit(ERROR_FTDI); } }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lcdtest/exitcodes.h Sun May 27 21:49:46 2018 +0000 @@ -0,0 +1,7 @@ +#define ERROR_USAGE 1 +#define ERROR_TARGET 2 +#define ERROR_RVINTERF 3 +#define ERROR_UNIX 4 +#define ERROR_BUG 5 +/* our local definition */ +#define ERROR_FTDI 6
--- a/lcdtest/testmain.c Sun May 27 21:36:07 2018 +0000 +++ b/lcdtest/testmain.c Sun May 27 21:49:46 2018 +0000 @@ -3,6 +3,7 @@ #include <stdlib.h> #include <unistd.h> #include <ftdi.h> +#include "exitcodes.h" char *device_serial; struct ftdi_context ftdi; @@ -20,7 +21,7 @@ continue; default: /* error msg already printed */ - exit(1); + exit(ERROR_USAGE); } } switch (argc - optind) { @@ -29,12 +30,12 @@ case 1: if (chdir(argv[optind]) < 0) { perror(argv[optind]); - exit(1); + exit(ERROR_UNIX); } break; default: fprintf(stderr, "usage: %s [options] [chdir]\n", argv[0]); - exit(1); + exit(ERROR_USAGE); } } @@ -47,12 +48,12 @@ ftdi_init(&ftdi); if (ftdi_usb_open_desc(&ftdi, 0x0403, 0x7157, 0, device_serial) < 0) { fprintf(stderr, "FTDI USB open failed: %s\n", ftdi.error_str); - exit(1); + exit(ERROR_FTDI); } if (ftdi_set_bitmode(&ftdi, 0, BITMODE_MCU) < 0) { fprintf(stderr, "unable to enter MCU mode: %s\n", ftdi.error_str); - exit(1); + exit(ERROR_FTDI); } for (;;) { if (isatty(0)) {