diff --git a/examples/Makefile.am b/examples/Makefile.am index 7a376bc..9362e05 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -27,46 +27,48 @@ if IRDA bin_PROGRAMS += smart endif -universal_SOURCES = universal.c +COMMON = common.c common.h -solution_SOURCES = suunto_solution_test.c +universal_SOURCES = universal.c $(COMMON) -eon_SOURCES = suunto_eon_test.c +solution_SOURCES = suunto_solution_test.c $(COMMON) -vyper_SOURCES = suunto_vyper_test.c +eon_SOURCES = suunto_eon_test.c $(COMMON) -vyper2_SOURCES = suunto_vyper2_test.c +vyper_SOURCES = suunto_vyper_test.c $(COMMON) -d9_SOURCES = suunto_d9_test.c +vyper2_SOURCES = suunto_vyper2_test.c $(COMMON) -sensus_SOURCES = reefnet_sensus_test.c +d9_SOURCES = suunto_d9_test.c $(COMMON) -sensuspro_SOURCES = reefnet_sensuspro_test.c +sensus_SOURCES = reefnet_sensus_test.c $(COMMON) -sensusultra_SOURCES = reefnet_sensusultra_test.c +sensuspro_SOURCES = reefnet_sensuspro_test.c $(COMMON) -aladin_SOURCES = uwatec_aladin_test.c +sensusultra_SOURCES = reefnet_sensusultra_test.c $(COMMON) -memomouse_SOURCES = uwatec_memomouse_test.c +aladin_SOURCES = uwatec_aladin_test.c $(COMMON) -atom2_SOURCES = oceanic_atom2_test.c +memomouse_SOURCES = uwatec_memomouse_test.c $(COMMON) -veo250_SOURCES = oceanic_veo250_test.c +atom2_SOURCES = oceanic_atom2_test.c $(COMMON) -vtpro_SOURCES = oceanic_vtpro_test.c +veo250_SOURCES = oceanic_veo250_test.c $(COMMON) -nemo_SOURCES = mares_nemo_test.c +vtpro_SOURCES = oceanic_vtpro_test.c $(COMMON) -puck_SOURCES = mares_puck_test.c +nemo_SOURCES = mares_nemo_test.c $(COMMON) -iconhd_SOURCES = mares_iconhd_test.c +puck_SOURCES = mares_puck_test.c $(COMMON) -ostc_SOURCES = hw_ostc_test.c +iconhd_SOURCES = mares_iconhd_test.c $(COMMON) -edy_SOURCES = cressi_edy_test.c +ostc_SOURCES = hw_ostc_test.c $(COMMON) -n2ition3_SOURCES = zeagle_n2ition3_test.c +edy_SOURCES = cressi_edy_test.c $(COMMON) + +n2ition3_SOURCES = zeagle_n2ition3_test.c $(COMMON) if IRDA -smart_SOURCES = uwatec_smart_test.c +smart_SOURCES = uwatec_smart_test.c $(COMMON) endif diff --git a/examples/common.c b/examples/common.c new file mode 100644 index 0000000..2d55de1 --- /dev/null +++ b/examples/common.c @@ -0,0 +1,49 @@ +/* + * libdivecomputer + * + * Copyright (C) 2011 Jef Driesen + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "common.h" + +const char * +errmsg (device_status_t rc) +{ + switch (rc) { + case DEVICE_STATUS_SUCCESS: + return "Success"; + case DEVICE_STATUS_UNSUPPORTED: + return "Unsupported operation"; + case DEVICE_STATUS_TYPE_MISMATCH: + return "Device type mismatch"; + case DEVICE_STATUS_ERROR: + return "Generic error"; + case DEVICE_STATUS_IO: + return "Input/output error"; + case DEVICE_STATUS_MEMORY: + return "Memory error"; + case DEVICE_STATUS_PROTOCOL: + return "Protocol error"; + case DEVICE_STATUS_TIMEOUT: + return "Timeout"; + case DEVICE_STATUS_CANCELLED: + return "Cancelled"; + default: + return "Unknown error"; + } +} diff --git a/examples/common.h b/examples/common.h new file mode 100644 index 0000000..7d73621 --- /dev/null +++ b/examples/common.h @@ -0,0 +1,37 @@ +/* + * libdivecomputer + * + * Copyright (C) 2011 Jef Driesen + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#ifndef EXAMPLES_COMMON_H +#define EXAMPLES_COMMON_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +const char * +errmsg (device_status_t rc); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ +#endif /* EXAMPLES_COMMON_H */ diff --git a/examples/cressi_edy_test.c b/examples/cressi_edy_test.c index 8c3c108..82bca9f 100644 --- a/examples/cressi_edy_test.c +++ b/examples/cressi_edy_test.c @@ -24,6 +24,7 @@ #include "cressi_edy.h" #include "utils.h" +#include "common.h" device_status_t test_dump_memory (const char* name, const char* filename) @@ -68,32 +69,6 @@ test_dump_memory (const char* name, const char* filename) } -const char* -errmsg (device_status_t rc) -{ - switch (rc) { - case DEVICE_STATUS_SUCCESS: - return "Success"; - case DEVICE_STATUS_UNSUPPORTED: - return "Unsupported operation"; - case DEVICE_STATUS_TYPE_MISMATCH: - return "Device type mismatch"; - case DEVICE_STATUS_ERROR: - return "Generic error"; - case DEVICE_STATUS_IO: - return "Input/output error"; - case DEVICE_STATUS_MEMORY: - return "Memory error"; - case DEVICE_STATUS_PROTOCOL: - return "Protocol error"; - case DEVICE_STATUS_TIMEOUT: - return "Timeout"; - default: - return "Unknown error"; - } -} - - int main(int argc, char *argv[]) { message_set_logfile ("EDY.LOG"); diff --git a/examples/hw_ostc_test.c b/examples/hw_ostc_test.c index 84519ac..73660c2 100644 --- a/examples/hw_ostc_test.c +++ b/examples/hw_ostc_test.c @@ -24,6 +24,8 @@ #include "hw_ostc.h" #include "utils.h" +#include "common.h" + device_status_t test_dump_memory (const char* name, const char* filename) { @@ -67,32 +69,6 @@ test_dump_memory (const char* name, const char* filename) } -const char* -errmsg (device_status_t rc) -{ - switch (rc) { - case DEVICE_STATUS_SUCCESS: - return "Success"; - case DEVICE_STATUS_UNSUPPORTED: - return "Unsupported operation"; - case DEVICE_STATUS_TYPE_MISMATCH: - return "Device type mismatch"; - case DEVICE_STATUS_ERROR: - return "Generic error"; - case DEVICE_STATUS_IO: - return "Input/output error"; - case DEVICE_STATUS_MEMORY: - return "Memory error"; - case DEVICE_STATUS_PROTOCOL: - return "Protocol error"; - case DEVICE_STATUS_TIMEOUT: - return "Timeout"; - default: - return "Unknown error"; - } -} - - int main(int argc, char *argv[]) { message_set_logfile ("OSTC.LOG"); diff --git a/examples/mares_iconhd_test.c b/examples/mares_iconhd_test.c index 6fd5d13..0aca5b3 100644 --- a/examples/mares_iconhd_test.c +++ b/examples/mares_iconhd_test.c @@ -24,6 +24,8 @@ #include "mares_iconhd.h" #include "utils.h" +#include "common.h" + device_status_t test_dump_memory (const char* name, const char* filename) { @@ -67,32 +69,6 @@ test_dump_memory (const char* name, const char* filename) } -const char* -errmsg (device_status_t rc) -{ - switch (rc) { - case DEVICE_STATUS_SUCCESS: - return "Success"; - case DEVICE_STATUS_UNSUPPORTED: - return "Unsupported operation"; - case DEVICE_STATUS_TYPE_MISMATCH: - return "Device type mismatch"; - case DEVICE_STATUS_ERROR: - return "Generic error"; - case DEVICE_STATUS_IO: - return "Input/output error"; - case DEVICE_STATUS_MEMORY: - return "Memory error"; - case DEVICE_STATUS_PROTOCOL: - return "Protocol error"; - case DEVICE_STATUS_TIMEOUT: - return "Timeout"; - default: - return "Unknown error"; - } -} - - int main(int argc, char *argv[]) { message_set_logfile ("ICONHD.LOG"); diff --git a/examples/mares_nemo_test.c b/examples/mares_nemo_test.c index a6fc2c1..728a69e 100644 --- a/examples/mares_nemo_test.c +++ b/examples/mares_nemo_test.c @@ -24,6 +24,8 @@ #include "mares_nemo.h" #include "utils.h" +#include "common.h" + device_status_t test_dump_memory (const char* name, const char* filename) { @@ -67,32 +69,6 @@ test_dump_memory (const char* name, const char* filename) } -const char* -errmsg (device_status_t rc) -{ - switch (rc) { - case DEVICE_STATUS_SUCCESS: - return "Success"; - case DEVICE_STATUS_UNSUPPORTED: - return "Unsupported operation"; - case DEVICE_STATUS_TYPE_MISMATCH: - return "Device type mismatch"; - case DEVICE_STATUS_ERROR: - return "Generic error"; - case DEVICE_STATUS_IO: - return "Input/output error"; - case DEVICE_STATUS_MEMORY: - return "Memory error"; - case DEVICE_STATUS_PROTOCOL: - return "Protocol error"; - case DEVICE_STATUS_TIMEOUT: - return "Timeout"; - default: - return "Unknown error"; - } -} - - int main(int argc, char *argv[]) { message_set_logfile ("NEMO.LOG"); diff --git a/examples/mares_puck_test.c b/examples/mares_puck_test.c index 42f699d..f68dd36 100644 --- a/examples/mares_puck_test.c +++ b/examples/mares_puck_test.c @@ -24,6 +24,8 @@ #include "mares_puck.h" #include "utils.h" +#include "common.h" + device_status_t test_dump_memory (const char* name, const char* filename) { @@ -67,32 +69,6 @@ test_dump_memory (const char* name, const char* filename) } -const char* -errmsg (device_status_t rc) -{ - switch (rc) { - case DEVICE_STATUS_SUCCESS: - return "Success"; - case DEVICE_STATUS_UNSUPPORTED: - return "Unsupported operation"; - case DEVICE_STATUS_TYPE_MISMATCH: - return "Device type mismatch"; - case DEVICE_STATUS_ERROR: - return "Generic error"; - case DEVICE_STATUS_IO: - return "Input/output error"; - case DEVICE_STATUS_MEMORY: - return "Memory error"; - case DEVICE_STATUS_PROTOCOL: - return "Protocol error"; - case DEVICE_STATUS_TIMEOUT: - return "Timeout"; - default: - return "Unknown error"; - } -} - - int main(int argc, char *argv[]) { message_set_logfile ("PUCK.LOG"); diff --git a/examples/oceanic_atom2_test.c b/examples/oceanic_atom2_test.c index c7835a2..443554e 100644 --- a/examples/oceanic_atom2_test.c +++ b/examples/oceanic_atom2_test.c @@ -24,6 +24,8 @@ #include "oceanic_atom2.h" #include "utils.h" +#include "common.h" + device_status_t test_dump_memory (const char* name, const char* filename) { @@ -75,31 +77,6 @@ test_dump_memory (const char* name, const char* filename) } -const char* -errmsg (device_status_t rc) -{ - switch (rc) { - case DEVICE_STATUS_SUCCESS: - return "Success"; - case DEVICE_STATUS_UNSUPPORTED: - return "Unsupported operation"; - case DEVICE_STATUS_TYPE_MISMATCH: - return "Device type mismatch"; - case DEVICE_STATUS_ERROR: - return "Generic error"; - case DEVICE_STATUS_IO: - return "Input/output error"; - case DEVICE_STATUS_MEMORY: - return "Memory error"; - case DEVICE_STATUS_PROTOCOL: - return "Protocol error"; - case DEVICE_STATUS_TIMEOUT: - return "Timeout"; - default: - return "Unknown error"; - } -} - int main(int argc, char *argv[]) { message_set_logfile ("ATOM2.LOG"); diff --git a/examples/oceanic_veo250_test.c b/examples/oceanic_veo250_test.c index 5e982bf..102ded4 100644 --- a/examples/oceanic_veo250_test.c +++ b/examples/oceanic_veo250_test.c @@ -24,6 +24,8 @@ #include "oceanic_veo250.h" #include "utils.h" +#include "common.h" + device_status_t test_dump_memory (const char* name, const char* filename) { @@ -75,31 +77,6 @@ test_dump_memory (const char* name, const char* filename) } -const char* -errmsg (device_status_t rc) -{ - switch (rc) { - case DEVICE_STATUS_SUCCESS: - return "Success"; - case DEVICE_STATUS_UNSUPPORTED: - return "Unsupported operation"; - case DEVICE_STATUS_TYPE_MISMATCH: - return "Device type mismatch"; - case DEVICE_STATUS_ERROR: - return "Generic error"; - case DEVICE_STATUS_IO: - return "Input/output error"; - case DEVICE_STATUS_MEMORY: - return "Memory error"; - case DEVICE_STATUS_PROTOCOL: - return "Protocol error"; - case DEVICE_STATUS_TIMEOUT: - return "Timeout"; - default: - return "Unknown error"; - } -} - int main(int argc, char *argv[]) { message_set_logfile ("VEO250.LOG"); diff --git a/examples/oceanic_vtpro_test.c b/examples/oceanic_vtpro_test.c index 6132fb5..f468da0 100644 --- a/examples/oceanic_vtpro_test.c +++ b/examples/oceanic_vtpro_test.c @@ -24,6 +24,8 @@ #include "oceanic_vtpro.h" #include "utils.h" +#include "common.h" + device_status_t test_dump_memory (const char* name, const char* filename) { @@ -67,31 +69,6 @@ test_dump_memory (const char* name, const char* filename) } -const char* -errmsg (device_status_t rc) -{ - switch (rc) { - case DEVICE_STATUS_SUCCESS: - return "Success"; - case DEVICE_STATUS_UNSUPPORTED: - return "Unsupported operation"; - case DEVICE_STATUS_TYPE_MISMATCH: - return "Device type mismatch"; - case DEVICE_STATUS_ERROR: - return "Generic error"; - case DEVICE_STATUS_IO: - return "Input/output error"; - case DEVICE_STATUS_MEMORY: - return "Memory error"; - case DEVICE_STATUS_PROTOCOL: - return "Protocol error"; - case DEVICE_STATUS_TIMEOUT: - return "Timeout"; - default: - return "Unknown error"; - } -} - int main(int argc, char *argv[]) { message_set_logfile ("VTPRO.LOG"); diff --git a/examples/reefnet_sensus_test.c b/examples/reefnet_sensus_test.c index 087895d..2f4a8bf 100644 --- a/examples/reefnet_sensus_test.c +++ b/examples/reefnet_sensus_test.c @@ -25,6 +25,8 @@ #include "reefnet_sensus.h" #include "utils.h" +#include "common.h" + device_status_t test_dump_memory (const char* name, const char* filename) { @@ -73,32 +75,6 @@ test_dump_memory (const char* name, const char* filename) } -const char* -errmsg (device_status_t rc) -{ - switch (rc) { - case DEVICE_STATUS_SUCCESS: - return "Success"; - case DEVICE_STATUS_UNSUPPORTED: - return "Unsupported operation"; - case DEVICE_STATUS_TYPE_MISMATCH: - return "Device type mismatch"; - case DEVICE_STATUS_ERROR: - return "Generic error"; - case DEVICE_STATUS_IO: - return "Input/output error"; - case DEVICE_STATUS_MEMORY: - return "Memory error"; - case DEVICE_STATUS_PROTOCOL: - return "Protocol error"; - case DEVICE_STATUS_TIMEOUT: - return "Timeout"; - default: - return "Unknown error"; - } -} - - int main(int argc, char *argv[]) { message_set_logfile ("SENSUS.LOG"); diff --git a/examples/reefnet_sensuspro_test.c b/examples/reefnet_sensuspro_test.c index 2cbc4a1..5270fcd 100644 --- a/examples/reefnet_sensuspro_test.c +++ b/examples/reefnet_sensuspro_test.c @@ -25,6 +25,8 @@ #include "reefnet_sensuspro.h" #include "utils.h" +#include "common.h" + device_status_t test_dump_memory (const char* name, const char* filename) { @@ -73,32 +75,6 @@ test_dump_memory (const char* name, const char* filename) } -const char* -errmsg (device_status_t rc) -{ - switch (rc) { - case DEVICE_STATUS_SUCCESS: - return "Success"; - case DEVICE_STATUS_UNSUPPORTED: - return "Unsupported operation"; - case DEVICE_STATUS_TYPE_MISMATCH: - return "Device type mismatch"; - case DEVICE_STATUS_ERROR: - return "Generic error"; - case DEVICE_STATUS_IO: - return "Input/output error"; - case DEVICE_STATUS_MEMORY: - return "Memory error"; - case DEVICE_STATUS_PROTOCOL: - return "Protocol error"; - case DEVICE_STATUS_TIMEOUT: - return "Timeout"; - default: - return "Unknown error"; - } -} - - int main(int argc, char *argv[]) { message_set_logfile ("SENSUSPRO.LOG"); diff --git a/examples/reefnet_sensusultra_test.c b/examples/reefnet_sensusultra_test.c index 27c5c19..c4f6803 100644 --- a/examples/reefnet_sensusultra_test.c +++ b/examples/reefnet_sensusultra_test.c @@ -25,6 +25,8 @@ #include "reefnet_sensusultra.h" #include "utils.h" +#include "common.h" + device_status_t test_dump_memory_dives (const char* name, const char* filename) { @@ -153,32 +155,6 @@ test_dump_memory_user (const char* name, const char* filename) } -const char* -errmsg (device_status_t rc) -{ - switch (rc) { - case DEVICE_STATUS_SUCCESS: - return "Success"; - case DEVICE_STATUS_UNSUPPORTED: - return "Unsupported operation"; - case DEVICE_STATUS_TYPE_MISMATCH: - return "Device type mismatch"; - case DEVICE_STATUS_ERROR: - return "Generic error"; - case DEVICE_STATUS_IO: - return "Input/output error"; - case DEVICE_STATUS_MEMORY: - return "Memory error"; - case DEVICE_STATUS_PROTOCOL: - return "Protocol error"; - case DEVICE_STATUS_TIMEOUT: - return "Timeout"; - default: - return "Unknown error"; - } -} - - int main(int argc, char *argv[]) { message_set_logfile ("SENSUSULTRA.LOG"); diff --git a/examples/suunto_d9_test.c b/examples/suunto_d9_test.c index 6fd991d..a2fb938 100644 --- a/examples/suunto_d9_test.c +++ b/examples/suunto_d9_test.c @@ -24,6 +24,8 @@ #include "suunto_d9.h" #include "utils.h" +#include "common.h" + device_status_t test_dump_sdm (const char* name) { @@ -116,31 +118,6 @@ test_dump_memory (const char* name, const char* filename) } -const char* -errmsg (device_status_t rc) -{ - switch (rc) { - case DEVICE_STATUS_SUCCESS: - return "Success"; - case DEVICE_STATUS_UNSUPPORTED: - return "Unsupported operation"; - case DEVICE_STATUS_TYPE_MISMATCH: - return "Device type mismatch"; - case DEVICE_STATUS_ERROR: - return "Generic error"; - case DEVICE_STATUS_IO: - return "Input/output error"; - case DEVICE_STATUS_MEMORY: - return "Memory error"; - case DEVICE_STATUS_PROTOCOL: - return "Protocol error"; - case DEVICE_STATUS_TIMEOUT: - return "Timeout"; - default: - return "Unknown error"; - } -} - int main(int argc, char *argv[]) { message_set_logfile ("D9.LOG"); diff --git a/examples/suunto_eon_test.c b/examples/suunto_eon_test.c index 0443132..6c6498e 100644 --- a/examples/suunto_eon_test.c +++ b/examples/suunto_eon_test.c @@ -24,6 +24,8 @@ #include "suunto_eon.h" #include "utils.h" +#include "common.h" + device_status_t test_dump_memory (const char* name, const char* filename) { @@ -67,32 +69,6 @@ test_dump_memory (const char* name, const char* filename) } -const char* -errmsg (device_status_t rc) -{ - switch (rc) { - case DEVICE_STATUS_SUCCESS: - return "Success"; - case DEVICE_STATUS_UNSUPPORTED: - return "Unsupported operation"; - case DEVICE_STATUS_TYPE_MISMATCH: - return "Device type mismatch"; - case DEVICE_STATUS_ERROR: - return "Generic error"; - case DEVICE_STATUS_IO: - return "Input/output error"; - case DEVICE_STATUS_MEMORY: - return "Memory error"; - case DEVICE_STATUS_PROTOCOL: - return "Protocol error"; - case DEVICE_STATUS_TIMEOUT: - return "Timeout"; - default: - return "Unknown error"; - } -} - - int main(int argc, char *argv[]) { message_set_logfile ("EON.LOG"); diff --git a/examples/suunto_solution_test.c b/examples/suunto_solution_test.c index 9b8ce02..8948a0e 100644 --- a/examples/suunto_solution_test.c +++ b/examples/suunto_solution_test.c @@ -3,6 +3,8 @@ #include "suunto.h" #include "utils.h" +#include "common.h" + device_status_t test_dump_memory (const char* name, const char* filename) { @@ -46,32 +48,6 @@ test_dump_memory (const char* name, const char* filename) } -const char* -errmsg (device_status_t rc) -{ - switch (rc) { - case DEVICE_STATUS_SUCCESS: - return "Success"; - case DEVICE_STATUS_UNSUPPORTED: - return "Unsupported operation"; - case DEVICE_STATUS_TYPE_MISMATCH: - return "Device type mismatch"; - case DEVICE_STATUS_ERROR: - return "Generic error"; - case DEVICE_STATUS_IO: - return "Input/output error"; - case DEVICE_STATUS_MEMORY: - return "Memory error"; - case DEVICE_STATUS_PROTOCOL: - return "Protocol error"; - case DEVICE_STATUS_TIMEOUT: - return "Timeout"; - default: - return "Unknown error"; - } -} - - int main(int argc, char *argv[]) { diff --git a/examples/suunto_vyper2_test.c b/examples/suunto_vyper2_test.c index e2ec269..9f5740e 100644 --- a/examples/suunto_vyper2_test.c +++ b/examples/suunto_vyper2_test.c @@ -24,6 +24,8 @@ #include "suunto_vyper2.h" #include "utils.h" +#include "common.h" + device_status_t test_dump_sdm (const char* name) { @@ -116,31 +118,6 @@ test_dump_memory (const char* name, const char* filename) } -const char* -errmsg (device_status_t rc) -{ - switch (rc) { - case DEVICE_STATUS_SUCCESS: - return "Success"; - case DEVICE_STATUS_UNSUPPORTED: - return "Unsupported operation"; - case DEVICE_STATUS_TYPE_MISMATCH: - return "Device type mismatch"; - case DEVICE_STATUS_ERROR: - return "Generic error"; - case DEVICE_STATUS_IO: - return "Input/output error"; - case DEVICE_STATUS_MEMORY: - return "Memory error"; - case DEVICE_STATUS_PROTOCOL: - return "Protocol error"; - case DEVICE_STATUS_TIMEOUT: - return "Timeout"; - default: - return "Unknown error"; - } -} - int main(int argc, char *argv[]) { message_set_logfile ("VYPER2.LOG"); diff --git a/examples/suunto_vyper_test.c b/examples/suunto_vyper_test.c index 690fa66..df0106d 100644 --- a/examples/suunto_vyper_test.c +++ b/examples/suunto_vyper_test.c @@ -25,6 +25,8 @@ #include "suunto_vyper.h" #include "utils.h" +#include "common.h" + device_status_t test_dump_sdm (const char* name, unsigned int delay) { @@ -103,31 +105,6 @@ test_dump_memory (const char* name, unsigned int delay, const char* filename) } -const char* -errmsg (device_status_t rc) -{ - switch (rc) { - case DEVICE_STATUS_SUCCESS: - return "Success"; - case DEVICE_STATUS_UNSUPPORTED: - return "Unsupported operation"; - case DEVICE_STATUS_TYPE_MISMATCH: - return "Device type mismatch"; - case DEVICE_STATUS_ERROR: - return "Generic error"; - case DEVICE_STATUS_IO: - return "Input/output error"; - case DEVICE_STATUS_MEMORY: - return "Memory error"; - case DEVICE_STATUS_PROTOCOL: - return "Protocol error"; - case DEVICE_STATUS_TIMEOUT: - return "Timeout"; - default: - return "Unknown error"; - } -} - int main(int argc, char *argv[]) { message_set_logfile ("VYPER.LOG"); diff --git a/examples/universal.c b/examples/universal.c index 3f18685..54d8ebd 100644 --- a/examples/universal.c +++ b/examples/universal.c @@ -45,6 +45,8 @@ #include #include +#include "common.h" + static const char *g_cachedir = NULL; static int g_cachedir_read = 1; @@ -535,33 +537,6 @@ dive_cb (const unsigned char *data, unsigned int size, const unsigned char *fing } -static const char* -errmsg (device_status_t rc) -{ - switch (rc) { - case DEVICE_STATUS_SUCCESS: - return "Success"; - case DEVICE_STATUS_UNSUPPORTED: - return "Unsupported operation"; - case DEVICE_STATUS_TYPE_MISMATCH: - return "Device type mismatch"; - case DEVICE_STATUS_ERROR: - return "Generic error"; - case DEVICE_STATUS_IO: - return "Input/output error"; - case DEVICE_STATUS_MEMORY: - return "Memory error"; - case DEVICE_STATUS_PROTOCOL: - return "Protocol error"; - case DEVICE_STATUS_TIMEOUT: - return "Timeout"; - case DEVICE_STATUS_CANCELLED: - return "Cancelled"; - default: - return "Unknown error"; - } -} - static void usage (const char *filename) { diff --git a/examples/uwatec_aladin_test.c b/examples/uwatec_aladin_test.c index 470b0c9..bd8faba 100644 --- a/examples/uwatec_aladin_test.c +++ b/examples/uwatec_aladin_test.c @@ -3,6 +3,8 @@ #include "uwatec_aladin.h" #include "utils.h" +#include "common.h" + device_status_t test_dump_memory (const char* name, const char* filename) { @@ -46,32 +48,6 @@ test_dump_memory (const char* name, const char* filename) } -const char* -errmsg (device_status_t rc) -{ - switch (rc) { - case DEVICE_STATUS_SUCCESS: - return "Success"; - case DEVICE_STATUS_UNSUPPORTED: - return "Unsupported operation"; - case DEVICE_STATUS_TYPE_MISMATCH: - return "Device type mismatch"; - case DEVICE_STATUS_ERROR: - return "Generic error"; - case DEVICE_STATUS_IO: - return "Input/output error"; - case DEVICE_STATUS_MEMORY: - return "Memory error"; - case DEVICE_STATUS_PROTOCOL: - return "Protocol error"; - case DEVICE_STATUS_TIMEOUT: - return "Timeout"; - default: - return "Unknown error"; - } -} - - int main(int argc, char *argv[]) { message_set_logfile ("ALADIN.LOG"); diff --git a/examples/uwatec_memomouse_test.c b/examples/uwatec_memomouse_test.c index e04e39e..f2224b9 100644 --- a/examples/uwatec_memomouse_test.c +++ b/examples/uwatec_memomouse_test.c @@ -24,6 +24,8 @@ #include "uwatec_memomouse.h" #include "utils.h" +#include "common.h" + device_status_t test_dump_memory (const char* name, const char* filename) { @@ -67,32 +69,6 @@ test_dump_memory (const char* name, const char* filename) } -const char* -errmsg (device_status_t rc) -{ - switch (rc) { - case DEVICE_STATUS_SUCCESS: - return "Success"; - case DEVICE_STATUS_UNSUPPORTED: - return "Unsupported operation"; - case DEVICE_STATUS_TYPE_MISMATCH: - return "Device type mismatch"; - case DEVICE_STATUS_ERROR: - return "Generic error"; - case DEVICE_STATUS_IO: - return "Input/output error"; - case DEVICE_STATUS_MEMORY: - return "Memory error"; - case DEVICE_STATUS_PROTOCOL: - return "Protocol error"; - case DEVICE_STATUS_TIMEOUT: - return "Timeout"; - default: - return "Unknown error"; - } -} - - int main(int argc, char *argv[]) { message_set_logfile ("MEMOMOUSE.LOG"); diff --git a/examples/uwatec_smart_test.c b/examples/uwatec_smart_test.c index b0a5e70..61592a1 100644 --- a/examples/uwatec_smart_test.c +++ b/examples/uwatec_smart_test.c @@ -26,6 +26,8 @@ #include "uwatec_smart.h" #include "utils.h" +#include "common.h" + device_status_t test_dump_memory (const char* filename) { @@ -78,32 +80,6 @@ test_dump_memory (const char* filename) } -const char* -errmsg (device_status_t rc) -{ - switch (rc) { - case DEVICE_STATUS_SUCCESS: - return "Success"; - case DEVICE_STATUS_UNSUPPORTED: - return "Unsupported operation"; - case DEVICE_STATUS_TYPE_MISMATCH: - return "Device type mismatch"; - case DEVICE_STATUS_ERROR: - return "Generic error"; - case DEVICE_STATUS_IO: - return "Input/output error"; - case DEVICE_STATUS_MEMORY: - return "Memory error"; - case DEVICE_STATUS_PROTOCOL: - return "Protocol error"; - case DEVICE_STATUS_TIMEOUT: - return "Timeout"; - default: - return "Unknown error"; - } -} - - int main(int argc, char *argv[]) { message_set_logfile ("SMART.LOG"); diff --git a/examples/zeagle_n2ition3_test.c b/examples/zeagle_n2ition3_test.c index 386ba6d..5900c57 100644 --- a/examples/zeagle_n2ition3_test.c +++ b/examples/zeagle_n2ition3_test.c @@ -24,6 +24,7 @@ #include "zeagle_n2ition3.h" #include "utils.h" +#include "common.h" device_status_t test_dump_memory (const char* name, const char* filename) @@ -68,32 +69,6 @@ test_dump_memory (const char* name, const char* filename) } -const char* -errmsg (device_status_t rc) -{ - switch (rc) { - case DEVICE_STATUS_SUCCESS: - return "Success"; - case DEVICE_STATUS_UNSUPPORTED: - return "Unsupported operation"; - case DEVICE_STATUS_TYPE_MISMATCH: - return "Device type mismatch"; - case DEVICE_STATUS_ERROR: - return "Generic error"; - case DEVICE_STATUS_IO: - return "Input/output error"; - case DEVICE_STATUS_MEMORY: - return "Memory error"; - case DEVICE_STATUS_PROTOCOL: - return "Protocol error"; - case DEVICE_STATUS_TIMEOUT: - return "Timeout"; - default: - return "Unknown error"; - } -} - - int main(int argc, char *argv[]) { message_set_logfile ("N2ITION3.LOG");