diff --git a/examples/cressi_edy_test.c b/examples/cressi_edy_test.c index 5c23691..1626fa3 100644 --- a/examples/cressi_edy_test.c +++ b/examples/cressi_edy_test.c @@ -29,7 +29,7 @@ dc_status_t test_dump_memory (const char* name, const char* filename) { - device_t *device = NULL; + dc_device_t *device = NULL; message ("cressi_edy_device_open\n"); dc_status_t rc = cressi_edy_device_open (&device, name); @@ -40,12 +40,12 @@ test_dump_memory (const char* name, const char* filename) dc_buffer_t *buffer = dc_buffer_new (0); - message ("device_dump\n"); - rc = device_dump (device, buffer); + message ("dc_device_dump\n"); + rc = dc_device_dump (device, buffer); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot read memory."); dc_buffer_free (buffer); - device_close (device); + dc_device_close (device); return rc; } @@ -58,8 +58,8 @@ test_dump_memory (const char* name, const char* filename) dc_buffer_free (buffer); - message ("device_close\n"); - rc = device_close (device); + message ("dc_device_close\n"); + rc = dc_device_close (device); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot close device."); return rc; diff --git a/examples/hw_frog_test.c b/examples/hw_frog_test.c index 1757afa..f1026e1 100644 --- a/examples/hw_frog_test.c +++ b/examples/hw_frog_test.c @@ -29,7 +29,7 @@ dc_status_t test_dump_memory (const char* name, const char* filename) { - device_t *device = NULL; + dc_device_t *device = NULL; message ("hw_frog_device_open\n"); dc_status_t rc = hw_frog_device_open (&device, name); @@ -38,16 +38,16 @@ test_dump_memory (const char* name, const char* filename) return rc; } - message ("device_foreach\n"); - rc = device_foreach (device, NULL, NULL); + message ("dc_device_foreach\n"); + rc = dc_device_foreach (device, NULL, NULL); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot read memory."); - device_close (device); + dc_device_close (device); return rc; } - message ("device_close\n"); - rc = device_close (device); + message ("dc_device_close\n"); + rc = dc_device_close (device); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot close device."); return rc; diff --git a/examples/hw_ostc_test.c b/examples/hw_ostc_test.c index 5d7e000..4ebe2c3 100644 --- a/examples/hw_ostc_test.c +++ b/examples/hw_ostc_test.c @@ -29,7 +29,7 @@ dc_status_t test_dump_memory (const char* name, const char* filename) { - device_t *device = NULL; + dc_device_t *device = NULL; message ("hw_ostc_device_open\n"); dc_status_t rc = hw_ostc_device_open (&device, name); @@ -40,12 +40,12 @@ test_dump_memory (const char* name, const char* filename) dc_buffer_t *buffer = dc_buffer_new (0); - message ("device_dump\n"); - rc = device_dump (device, buffer); + message ("dc_device_dump\n"); + rc = dc_device_dump (device, buffer); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot read memory."); dc_buffer_free (buffer); - device_close (device); + dc_device_close (device); return rc; } @@ -58,8 +58,8 @@ test_dump_memory (const char* name, const char* filename) dc_buffer_free (buffer); - message ("device_close\n"); - rc = device_close (device); + message ("dc_device_close\n"); + rc = dc_device_close (device); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot close device."); return rc; diff --git a/examples/mares_darwin_test.c b/examples/mares_darwin_test.c index d51661b..a6dba36 100644 --- a/examples/mares_darwin_test.c +++ b/examples/mares_darwin_test.c @@ -29,7 +29,7 @@ dc_status_t test_dump_memory (const char* name, const char* filename) { - device_t *device = NULL; + dc_device_t *device = NULL; message ("mares_darwin_device_open\n"); dc_status_t rc = mares_darwin_device_open (&device, name, 0); @@ -40,12 +40,12 @@ test_dump_memory (const char* name, const char* filename) dc_buffer_t *buffer = dc_buffer_new (0); - message ("device_dump\n"); - rc = device_dump (device, buffer); + message ("dc_device_dump\n"); + rc = dc_device_dump (device, buffer); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot read memory."); dc_buffer_free (buffer); - device_close (device); + dc_device_close (device); return rc; } @@ -58,8 +58,8 @@ test_dump_memory (const char* name, const char* filename) dc_buffer_free (buffer); - message ("device_close\n"); - rc = device_close (device); + message ("dc_device_close\n"); + rc = dc_device_close (device); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot close device."); return rc; diff --git a/examples/mares_iconhd_test.c b/examples/mares_iconhd_test.c index 375812c..3fea5f6 100644 --- a/examples/mares_iconhd_test.c +++ b/examples/mares_iconhd_test.c @@ -29,7 +29,7 @@ dc_status_t test_dump_memory (const char* name, const char* filename) { - device_t *device = NULL; + dc_device_t *device = NULL; message ("mares_iconhd_device_open\n"); dc_status_t rc = mares_iconhd_device_open (&device, name); @@ -40,12 +40,12 @@ test_dump_memory (const char* name, const char* filename) dc_buffer_t *buffer = dc_buffer_new (0); - message ("device_dump\n"); - rc = device_dump (device, buffer); + message ("dc_device_dump\n"); + rc = dc_device_dump (device, buffer); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot read memory."); dc_buffer_free (buffer); - device_close (device); + dc_device_close (device); return rc; } @@ -58,8 +58,8 @@ test_dump_memory (const char* name, const char* filename) dc_buffer_free (buffer); - message ("device_close\n"); - rc = device_close (device); + message ("dc_device_close\n"); + rc = dc_device_close (device); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot close device."); return rc; diff --git a/examples/mares_nemo_test.c b/examples/mares_nemo_test.c index 5b6705a..cd78573 100644 --- a/examples/mares_nemo_test.c +++ b/examples/mares_nemo_test.c @@ -29,7 +29,7 @@ dc_status_t test_dump_memory (const char* name, const char* filename) { - device_t *device = NULL; + dc_device_t *device = NULL; message ("mares_nemo_device_open\n"); dc_status_t rc = mares_nemo_device_open (&device, name); @@ -40,12 +40,12 @@ test_dump_memory (const char* name, const char* filename) dc_buffer_t *buffer = dc_buffer_new (0); - message ("device_dump\n"); - rc = device_dump (device, buffer); + message ("dc_device_dump\n"); + rc = dc_device_dump (device, buffer); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot read memory."); dc_buffer_free (buffer); - device_close (device); + dc_device_close (device); return rc; } @@ -58,8 +58,8 @@ test_dump_memory (const char* name, const char* filename) dc_buffer_free (buffer); - message ("device_close\n"); - rc = device_close (device); + message ("dc_device_close\n"); + rc = dc_device_close (device); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot close device."); return rc; diff --git a/examples/mares_puck_test.c b/examples/mares_puck_test.c index 0b1239c..f6d7dab 100644 --- a/examples/mares_puck_test.c +++ b/examples/mares_puck_test.c @@ -29,7 +29,7 @@ dc_status_t test_dump_memory (const char* name, const char* filename) { - device_t *device = NULL; + dc_device_t *device = NULL; message ("mares_puck_device_open\n"); dc_status_t rc = mares_puck_device_open (&device, name); @@ -40,12 +40,12 @@ test_dump_memory (const char* name, const char* filename) dc_buffer_t *buffer = dc_buffer_new (0); - message ("device_dump\n"); - rc = device_dump (device, buffer); + message ("dc_device_dump\n"); + rc = dc_device_dump (device, buffer); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot read memory."); dc_buffer_free (buffer); - device_close (device); + dc_device_close (device); return rc; } @@ -58,8 +58,8 @@ test_dump_memory (const char* name, const char* filename) dc_buffer_free (buffer); - message ("device_close\n"); - rc = device_close (device); + message ("dc_device_close\n"); + rc = dc_device_close (device); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot close device."); return rc; diff --git a/examples/oceanic_atom2_test.c b/examples/oceanic_atom2_test.c index dde3585..41322e9 100644 --- a/examples/oceanic_atom2_test.c +++ b/examples/oceanic_atom2_test.c @@ -29,7 +29,7 @@ dc_status_t test_dump_memory (const char* name, const char* filename) { - device_t *device = NULL; + dc_device_t *device = NULL; message ("oceanic_atom2_device_open\n"); dc_status_t rc = oceanic_atom2_device_open (&device, name); @@ -40,12 +40,12 @@ test_dump_memory (const char* name, const char* filename) dc_buffer_t *buffer = dc_buffer_new (0); - message ("device_dump\n"); - rc = device_dump (device, buffer); + message ("dc_device_dump\n"); + rc = dc_device_dump (device, buffer); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot read memory."); dc_buffer_free (buffer); - device_close (device); + dc_device_close (device); return rc; } @@ -58,16 +58,16 @@ test_dump_memory (const char* name, const char* filename) dc_buffer_free (buffer); - message ("device_foreach\n"); - rc = device_foreach (device, NULL, NULL); + message ("dc_device_foreach\n"); + rc = dc_device_foreach (device, NULL, NULL); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot read dives."); - device_close (device); + dc_device_close (device); return rc; } - message ("device_close\n"); - rc = device_close (device); + message ("dc_device_close\n"); + rc = dc_device_close (device); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot close device."); return rc; diff --git a/examples/oceanic_veo250_test.c b/examples/oceanic_veo250_test.c index 32f1f0c..0594b1d 100644 --- a/examples/oceanic_veo250_test.c +++ b/examples/oceanic_veo250_test.c @@ -29,7 +29,7 @@ dc_status_t test_dump_memory (const char* name, const char* filename) { - device_t *device = NULL; + dc_device_t *device = NULL; message ("oceanic_veo250_device_open\n"); dc_status_t rc = oceanic_veo250_device_open (&device, name); @@ -40,12 +40,12 @@ test_dump_memory (const char* name, const char* filename) dc_buffer_t *buffer = dc_buffer_new (0); - message ("device_dump\n"); - rc = device_dump (device, buffer); + message ("dc_device_dump\n"); + rc = dc_device_dump (device, buffer); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot read memory."); dc_buffer_free (buffer); - device_close (device); + dc_device_close (device); return rc; } @@ -58,16 +58,16 @@ test_dump_memory (const char* name, const char* filename) dc_buffer_free (buffer); - message ("device_foreach\n"); - rc = device_foreach (device, NULL, NULL); + message ("dc_device_foreach\n"); + rc = dc_device_foreach (device, NULL, NULL); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot read dives."); - device_close (device); + dc_device_close (device); return rc; } - message ("device_close\n"); - rc = device_close (device); + message ("dc_device_close\n"); + rc = dc_device_close (device); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot close device."); return rc; diff --git a/examples/oceanic_vtpro_test.c b/examples/oceanic_vtpro_test.c index 456c107..770312b 100644 --- a/examples/oceanic_vtpro_test.c +++ b/examples/oceanic_vtpro_test.c @@ -29,7 +29,7 @@ dc_status_t test_dump_memory (const char* name, const char* filename) { - device_t *device = NULL; + dc_device_t *device = NULL; message ("oceanic_vtpro_device_open\n"); dc_status_t rc = oceanic_vtpro_device_open (&device, name); @@ -40,12 +40,12 @@ test_dump_memory (const char* name, const char* filename) dc_buffer_t *buffer = dc_buffer_new (0); - message ("device_dump\n"); - rc = device_dump (device, buffer); + message ("dc_device_dump\n"); + rc = dc_device_dump (device, buffer); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot read memory."); dc_buffer_free (buffer); - device_close (device); + dc_device_close (device); return rc; } @@ -58,8 +58,8 @@ test_dump_memory (const char* name, const char* filename) dc_buffer_free (buffer); - message ("device_close\n"); - rc = device_close (device); + message ("dc_device_close\n"); + rc = dc_device_close (device); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot close device."); return rc; diff --git a/examples/reefnet_sensus_test.c b/examples/reefnet_sensus_test.c index 817305d..a15e0e1 100644 --- a/examples/reefnet_sensus_test.c +++ b/examples/reefnet_sensus_test.c @@ -30,7 +30,7 @@ dc_status_t test_dump_memory (const char* name, const char* filename) { - device_t *device = NULL; + dc_device_t *device = NULL; message ("reefnet_sensus_device_open\n"); dc_status_t rc = reefnet_sensus_device_open (&device, name); @@ -46,12 +46,12 @@ test_dump_memory (const char* name, const char* filename) dc_buffer_t *buffer = dc_buffer_new (0); - message ("device_dump\n"); - rc = device_dump (device, buffer); + message ("dc_device_dump\n"); + rc = dc_device_dump (device, buffer); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot read memory."); dc_buffer_free (buffer); - device_close (device); + dc_device_close (device); return rc; } @@ -64,8 +64,8 @@ test_dump_memory (const char* name, const char* filename) dc_buffer_free (buffer); - message ("device_close\n"); - rc = device_close (device); + message ("dc_device_close\n"); + rc = dc_device_close (device); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot close device."); return rc; diff --git a/examples/reefnet_sensuspro_test.c b/examples/reefnet_sensuspro_test.c index ae93cb6..33ac7fa 100644 --- a/examples/reefnet_sensuspro_test.c +++ b/examples/reefnet_sensuspro_test.c @@ -30,7 +30,7 @@ dc_status_t test_dump_memory (const char* name, const char* filename) { - device_t *device = NULL; + dc_device_t *device = NULL; message ("reefnet_sensuspro_device_open\n"); dc_status_t rc = reefnet_sensuspro_device_open (&device, name); @@ -46,12 +46,12 @@ test_dump_memory (const char* name, const char* filename) dc_buffer_t *buffer = dc_buffer_new (0); - message ("device_dump\n"); - rc = device_dump (device, buffer); + message ("dc_device_dump\n"); + rc = dc_device_dump (device, buffer); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot read memory."); dc_buffer_free (buffer); - device_close (device); + dc_device_close (device); return rc; } @@ -64,8 +64,8 @@ test_dump_memory (const char* name, const char* filename) dc_buffer_free (buffer); - message ("device_close\n"); - rc = device_close (device); + message ("dc_device_close\n"); + rc = dc_device_close (device); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot close device."); return rc; diff --git a/examples/reefnet_sensusultra_test.c b/examples/reefnet_sensusultra_test.c index 07e1c6b..3c6d38a 100644 --- a/examples/reefnet_sensusultra_test.c +++ b/examples/reefnet_sensusultra_test.c @@ -30,7 +30,7 @@ dc_status_t test_dump_memory_dives (const char* name, const char* filename) { - device_t *device = NULL; + dc_device_t *device = NULL; message ("reefnet_sensusultra_device_open\n"); dc_status_t rc = reefnet_sensusultra_device_open (&device, name); @@ -44,16 +44,16 @@ test_dump_memory_dives (const char* name, const char* filename) strftime (datetime, sizeof (datetime), "%Y-%m-%dT%H:%M:%SZ", gmtime (&now)); message ("time=%lu (%s)\n", (unsigned long)now, datetime); - message ("device_foreach\n"); - rc = device_foreach (device, NULL, NULL); + message ("dc_device_foreach\n"); + rc = dc_device_foreach (device, NULL, NULL); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot read dives."); - device_close (device); + dc_device_close (device); return rc; } - message ("device_close\n"); - rc = device_close (device); + message ("dc_device_close\n"); + rc = dc_device_close (device); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot close device."); return rc; @@ -66,7 +66,7 @@ test_dump_memory_dives (const char* name, const char* filename) dc_status_t test_dump_memory_data (const char* name, const char* filename) { - device_t *device = NULL; + dc_device_t *device = NULL; message ("reefnet_sensusultra_device_open\n"); dc_status_t rc = reefnet_sensusultra_device_open (&device, name); @@ -82,12 +82,12 @@ test_dump_memory_data (const char* name, const char* filename) dc_buffer_t *buffer = dc_buffer_new (0); - message ("device_dump\n"); - rc = device_dump (device, buffer); + message ("dc_device_dump\n"); + rc = dc_device_dump (device, buffer); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot read memory."); dc_buffer_free (buffer); - device_close (device); + dc_device_close (device); return rc; } @@ -100,8 +100,8 @@ test_dump_memory_data (const char* name, const char* filename) dc_buffer_free (buffer); - message ("device_close\n"); - rc = device_close (device); + message ("dc_device_close\n"); + rc = dc_device_close (device); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot close device."); return rc; @@ -114,7 +114,7 @@ test_dump_memory_data (const char* name, const char* filename) dc_status_t test_dump_memory_user (const char* name, const char* filename) { - device_t *device = NULL; + dc_device_t *device = NULL; unsigned char data[REEFNET_SENSUSULTRA_MEMORY_USER_SIZE] = {0}; message ("reefnet_sensusultra_device_open\n"); @@ -133,7 +133,7 @@ test_dump_memory_user (const char* name, const char* filename) rc = reefnet_sensusultra_device_read_user (device, data, sizeof (data)); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot read memory."); - device_close (device); + dc_device_close (device); return rc; } @@ -144,8 +144,8 @@ test_dump_memory_user (const char* name, const char* filename) fclose (fp); } - message ("device_close\n"); - rc = device_close (device); + message ("dc_device_close\n"); + rc = dc_device_close (device); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot close device."); return rc; diff --git a/examples/suunto_d9_test.c b/examples/suunto_d9_test.c index f1dd339..fa206d4 100644 --- a/examples/suunto_d9_test.c +++ b/examples/suunto_d9_test.c @@ -29,7 +29,7 @@ dc_status_t test_dump_sdm (const char* name) { - device_t *device = NULL; + dc_device_t *device = NULL; message ("suunto_d9_device_open\n"); dc_status_t rc = suunto_d9_device_open (&device, name, 0); @@ -38,25 +38,25 @@ test_dump_sdm (const char* name) return rc; } - message ("device_version\n"); + message ("dc_device_version\n"); unsigned char version[SUUNTO_D9_VERSION_SIZE] = {0}; - rc = device_version (device, version, sizeof (version)); + rc = dc_device_version (device, version, sizeof (version)); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot identify computer."); - device_close (device); + dc_device_close (device); return rc; } - message ("device_foreach\n"); - rc = device_foreach (device, NULL, NULL); + message ("dc_device_foreach\n"); + rc = dc_device_foreach (device, NULL, NULL); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot read dives."); - device_close (device); + dc_device_close (device); return rc; } - message ("device_close\n"); - rc = device_close (device); + message ("dc_device_close\n"); + rc = dc_device_close (device); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot close device."); return rc; @@ -69,7 +69,7 @@ test_dump_sdm (const char* name) dc_status_t test_dump_memory (const char* name, const char* filename) { - device_t *device = NULL; + dc_device_t *device = NULL; message ("suunto_d9_device_open\n"); dc_status_t rc = suunto_d9_device_open (&device, name, 0); @@ -78,23 +78,23 @@ test_dump_memory (const char* name, const char* filename) return rc; } - message ("device_version\n"); + message ("dc_device_version\n"); unsigned char version[SUUNTO_D9_VERSION_SIZE] = {0}; - rc = device_version (device, version, sizeof (version)); + rc = dc_device_version (device, version, sizeof (version)); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot identify computer."); - device_close (device); + dc_device_close (device); return rc; } dc_buffer_t *buffer = dc_buffer_new (0); - message ("device_dump\n"); - rc = device_dump (device, buffer); + message ("dc_device_dump\n"); + rc = dc_device_dump (device, buffer); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot read memory."); dc_buffer_free (buffer); - device_close (device); + dc_device_close (device); return rc; } @@ -107,8 +107,8 @@ test_dump_memory (const char* name, const char* filename) dc_buffer_free (buffer); - message ("device_close\n"); - rc = device_close (device); + message ("dc_device_close\n"); + rc = dc_device_close (device); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot close device."); return rc; diff --git a/examples/suunto_eon_test.c b/examples/suunto_eon_test.c index 7527b9f..12cfaa2 100644 --- a/examples/suunto_eon_test.c +++ b/examples/suunto_eon_test.c @@ -29,7 +29,7 @@ dc_status_t test_dump_memory (const char* name, const char* filename) { - device_t *device = NULL; + dc_device_t *device = NULL; message ("suunto_eon_device_open\n"); dc_status_t rc = suunto_eon_device_open (&device, name); @@ -40,12 +40,12 @@ test_dump_memory (const char* name, const char* filename) dc_buffer_t *buffer = dc_buffer_new (0); - message ("device_dump\n"); - rc = device_dump (device, buffer); + message ("dc_device_dump\n"); + rc = dc_device_dump (device, buffer); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot read memory."); dc_buffer_free (buffer); - device_close (device); + dc_device_close (device); return rc; } @@ -58,8 +58,8 @@ test_dump_memory (const char* name, const char* filename) dc_buffer_free (buffer); - message ("device_close\n"); - rc = device_close (device); + message ("dc_device_close\n"); + rc = dc_device_close (device); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot close device."); return rc; diff --git a/examples/suunto_solution_test.c b/examples/suunto_solution_test.c index 1630b99..a5ce107 100644 --- a/examples/suunto_solution_test.c +++ b/examples/suunto_solution_test.c @@ -8,7 +8,7 @@ dc_status_t test_dump_memory (const char* name, const char* filename) { - device_t *device = NULL; + dc_device_t *device = NULL; message ("suunto_solution_device_open\n"); int rc = suunto_solution_device_open (&device, name); @@ -19,12 +19,12 @@ test_dump_memory (const char* name, const char* filename) dc_buffer_t *buffer = dc_buffer_new (0); - message ("device_dump\n"); - rc = device_dump (device, buffer); + message ("dc_device_dump\n"); + rc = dc_device_dump (device, buffer); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot read memory."); dc_buffer_free (buffer); - device_close (device); + dc_device_close (device); return rc; } @@ -37,8 +37,8 @@ test_dump_memory (const char* name, const char* filename) dc_buffer_free (buffer); - message ("device_close\n"); - rc = device_close (device); + message ("dc_device_close\n"); + rc = dc_device_close (device); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot close device."); return rc; diff --git a/examples/suunto_vyper2_test.c b/examples/suunto_vyper2_test.c index cab4f7d..0d75e0a 100644 --- a/examples/suunto_vyper2_test.c +++ b/examples/suunto_vyper2_test.c @@ -29,7 +29,7 @@ dc_status_t test_dump_sdm (const char* name) { - device_t *device = NULL; + dc_device_t *device = NULL; message ("suunto_vyper2_device_open\n"); dc_status_t rc = suunto_vyper2_device_open (&device, name); @@ -38,25 +38,25 @@ test_dump_sdm (const char* name) return rc; } - message ("device_version\n"); + message ("dc_device_version\n"); unsigned char version[SUUNTO_VYPER2_VERSION_SIZE] = {0}; - rc = device_version (device, version, sizeof (version)); + rc = dc_device_version (device, version, sizeof (version)); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot identify computer."); - device_close (device); + dc_device_close (device); return rc; } - message ("device_foreach\n"); - rc = device_foreach (device, NULL, NULL); + message ("dc_device_foreach\n"); + rc = dc_device_foreach (device, NULL, NULL); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot read dives."); - device_close (device); + dc_device_close (device); return rc; } - message ("device_close\n"); - rc = device_close (device); + message ("dc_device_close\n"); + rc = dc_device_close (device); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot close device."); return rc; @@ -69,7 +69,7 @@ test_dump_sdm (const char* name) dc_status_t test_dump_memory (const char* name, const char* filename) { - device_t *device = NULL; + dc_device_t *device = NULL; message ("suunto_vyper2_device_open\n"); dc_status_t rc = suunto_vyper2_device_open (&device, name); @@ -78,23 +78,23 @@ test_dump_memory (const char* name, const char* filename) return rc; } - message ("device_version\n"); + message ("dc_device_version\n"); unsigned char version[SUUNTO_VYPER2_VERSION_SIZE] = {0}; - rc = device_version (device, version, sizeof (version)); + rc = dc_device_version (device, version, sizeof (version)); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot identify computer."); - device_close (device); + dc_device_close (device); return rc; } dc_buffer_t *buffer = dc_buffer_new (0); - message ("device_dump\n"); - rc = device_dump (device, buffer); + message ("dc_device_dump\n"); + rc = dc_device_dump (device, buffer); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot read memory."); dc_buffer_free (buffer); - device_close (device); + dc_device_close (device); return rc; } @@ -107,8 +107,8 @@ test_dump_memory (const char* name, const char* filename) dc_buffer_free (buffer); - message ("device_close\n"); - rc = device_close (device); + message ("dc_device_close\n"); + rc = dc_device_close (device); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot close device."); return rc; diff --git a/examples/suunto_vyper_test.c b/examples/suunto_vyper_test.c index 0cc8aba..944076f 100644 --- a/examples/suunto_vyper_test.c +++ b/examples/suunto_vyper_test.c @@ -30,7 +30,7 @@ dc_status_t test_dump_sdm (const char* name, unsigned int delay) { - device_t *device = NULL; + dc_device_t *device = NULL; message ("suunto_vyper_device_open\n"); dc_status_t rc = suunto_vyper_device_open (&device, name); @@ -41,16 +41,16 @@ test_dump_sdm (const char* name, unsigned int delay) suunto_vyper_device_set_delay (device, delay); - message ("device_foreach\n"); - rc = device_foreach (device, NULL, NULL); + message ("dc_device_foreach\n"); + rc = dc_device_foreach (device, NULL, NULL); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot read dives."); - device_close (device); + dc_device_close (device); return rc; } - message ("device_close\n"); - rc = device_close (device); + message ("dc_device_close\n"); + rc = dc_device_close (device); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot close device."); return rc; @@ -63,7 +63,7 @@ test_dump_sdm (const char* name, unsigned int delay) dc_status_t test_dump_memory (const char* name, unsigned int delay, const char* filename) { - device_t *device = NULL; + dc_device_t *device = NULL; message ("suunto_vyper_device_open\n"); dc_status_t rc = suunto_vyper_device_open (&device, name); @@ -76,12 +76,12 @@ test_dump_memory (const char* name, unsigned int delay, const char* filename) dc_buffer_t *buffer = dc_buffer_new (0); - message ("device_dump\n"); - rc = device_dump (device, buffer); + message ("dc_device_dump\n"); + rc = dc_device_dump (device, buffer); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot read memory."); dc_buffer_free (buffer); - device_close (device); + dc_device_close (device); return rc; } @@ -94,8 +94,8 @@ test_dump_memory (const char* name, unsigned int delay, const char* filename) dc_buffer_free (buffer); - message ("device_close\n"); - rc = device_close (device); + message ("dc_device_close\n"); + rc = dc_device_close (device); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot close device."); return rc; diff --git a/examples/universal.c b/examples/universal.c index 0ba3dc8..314911e 100644 --- a/examples/universal.c +++ b/examples/universal.c @@ -52,8 +52,8 @@ static int g_cachedir_read = 1; typedef struct device_data_t { dc_family_t backend; - device_devinfo_t devinfo; - device_clock_t clock; + dc_event_devinfo_t devinfo; + dc_event_clock_t clock; } device_data_t; typedef struct dive_data_t { @@ -232,7 +232,7 @@ cancel_cb (void *userdata) } void -sample_cb (parser_sample_type_t type, parser_sample_value_t value, void *userdata) +sample_cb (dc_sample_type_t type, dc_sample_value_t value, void *userdata) { static const char *events[] = { "none", "deco", "rbt", "ascent", "ceiling", "workload", "transmitter", @@ -244,35 +244,35 @@ sample_cb (parser_sample_type_t type, parser_sample_value_t value, void *userdat sample_data_t *sampledata = (sample_data_t *) userdata; switch (type) { - case SAMPLE_TYPE_TIME: + case DC_SAMPLE_TIME: if (sampledata->nsamples++) fprintf (sampledata->fp, "\n"); fprintf (sampledata->fp, "\n"); fprintf (sampledata->fp, " \n", value.time / 60, value.time % 60); break; - case SAMPLE_TYPE_DEPTH: + case DC_SAMPLE_DEPTH: fprintf (sampledata->fp, " %.2f\n", value.depth); break; - case SAMPLE_TYPE_PRESSURE: + case DC_SAMPLE_PRESSURE: fprintf (sampledata->fp, " %.2f\n", value.pressure.tank, value.pressure.value); break; - case SAMPLE_TYPE_TEMPERATURE: + case DC_SAMPLE_TEMPERATURE: fprintf (sampledata->fp, " %.2f\n", value.temperature); break; - case SAMPLE_TYPE_EVENT: + case DC_SAMPLE_EVENT: fprintf (sampledata->fp, " %s\n", value.event.type, value.event.time, value.event.flags, value.event.value, events[value.event.type]); break; - case SAMPLE_TYPE_RBT: + case DC_SAMPLE_RBT: fprintf (sampledata->fp, " %u\n", value.rbt); break; - case SAMPLE_TYPE_HEARTBEAT: + case DC_SAMPLE_HEARTBEAT: fprintf (sampledata->fp, " %u\n", value.heartbeat); break; - case SAMPLE_TYPE_BEARING: + case DC_SAMPLE_BEARING: fprintf (sampledata->fp, " %u\n", value.bearing); break; - case SAMPLE_TYPE_VENDOR: + case DC_SAMPLE_VENDOR: fprintf (sampledata->fp, " ", value.vendor.type, value.vendor.size); for (unsigned int i = 0; i < value.vendor.size; ++i) fprintf (sampledata->fp, "%02X", ((unsigned char *) value.vendor.data)[i]); @@ -288,7 +288,7 @@ doparse (FILE *fp, device_data_t *devdata, const unsigned char data[], unsigned { // Create the parser. message ("Creating the parser.\n"); - parser_t *parser = NULL; + dc_parser_t *parser = NULL; dc_status_t rc = DC_STATUS_SUCCESS; switch (devdata->backend) { case DC_FAMILY_SUUNTO_SOLUTION: @@ -366,20 +366,20 @@ doparse (FILE *fp, device_data_t *devdata, const unsigned char data[], unsigned // Register the data. message ("Registering the data.\n"); - rc = parser_set_data (parser, data, size); + rc = dc_parser_set_data (parser, data, size); if (rc != DC_STATUS_SUCCESS) { WARNING ("Error registering the data."); - parser_destroy (parser); + dc_parser_destroy (parser); return rc; } // Parse the datetime. message ("Parsing the datetime.\n"); dc_datetime_t dt = {0}; - rc = parser_get_datetime (parser, &dt); + rc = dc_parser_get_datetime (parser, &dt); if (rc != DC_STATUS_SUCCESS && rc != DC_STATUS_UNSUPPORTED) { WARNING ("Error parsing the datetime."); - parser_destroy (parser); + dc_parser_destroy (parser); return rc; } @@ -390,10 +390,10 @@ doparse (FILE *fp, device_data_t *devdata, const unsigned char data[], unsigned // Parse the divetime. message ("Parsing the divetime.\n"); unsigned int divetime = 0; - rc = parser_get_field (parser, FIELD_TYPE_DIVETIME, 0, &divetime); + rc = dc_parser_get_field (parser, DC_FIELD_DIVETIME, 0, &divetime); if (rc != DC_STATUS_SUCCESS && rc != DC_STATUS_UNSUPPORTED) { WARNING ("Error parsing the divetime."); - parser_destroy (parser); + dc_parser_destroy (parser); return rc; } @@ -403,10 +403,10 @@ doparse (FILE *fp, device_data_t *devdata, const unsigned char data[], unsigned // Parse the maxdepth. message ("Parsing the maxdepth.\n"); double maxdepth = 0.0; - rc = parser_get_field (parser, FIELD_TYPE_MAXDEPTH, 0, &maxdepth); + rc = dc_parser_get_field (parser, DC_FIELD_MAXDEPTH, 0, &maxdepth); if (rc != DC_STATUS_SUCCESS && rc != DC_STATUS_UNSUPPORTED) { WARNING ("Error parsing the maxdepth."); - parser_destroy (parser); + dc_parser_destroy (parser); return rc; } @@ -416,19 +416,19 @@ doparse (FILE *fp, device_data_t *devdata, const unsigned char data[], unsigned // Parse the gas mixes. message ("Parsing the gas mixes.\n"); unsigned int ngases = 0; - rc = parser_get_field (parser, FIELD_TYPE_GASMIX_COUNT, 0, &ngases); + rc = dc_parser_get_field (parser, DC_FIELD_GASMIX_COUNT, 0, &ngases); if (rc != DC_STATUS_SUCCESS && rc != DC_STATUS_UNSUPPORTED) { WARNING ("Error parsing the gas mix count."); - parser_destroy (parser); + dc_parser_destroy (parser); return rc; } for (unsigned int i = 0; i < ngases; ++i) { - gasmix_t gasmix = {0}; - rc = parser_get_field (parser, FIELD_TYPE_GASMIX, i, &gasmix); + dc_gasmix_t gasmix = {0}; + rc = dc_parser_get_field (parser, DC_FIELD_GASMIX, i, &gasmix); if (rc != DC_STATUS_SUCCESS && rc != DC_STATUS_UNSUPPORTED) { WARNING ("Error parsing the gas mix."); - parser_destroy (parser); + dc_parser_destroy (parser); return rc; } @@ -450,10 +450,10 @@ doparse (FILE *fp, device_data_t *devdata, const unsigned char data[], unsigned // Parse the sample data. message ("Parsing the sample data.\n"); - rc = parser_samples_foreach (parser, sample_cb, &sampledata); + rc = dc_parser_samples_foreach (parser, sample_cb, &sampledata); if (rc != DC_STATUS_SUCCESS) { WARNING ("Error parsing the sample data."); - parser_destroy (parser); + dc_parser_destroy (parser); return rc; } @@ -462,7 +462,7 @@ doparse (FILE *fp, device_data_t *devdata, const unsigned char data[], unsigned // Destroy the parser. message ("Destroying the parser.\n"); - rc = parser_destroy (parser); + rc = dc_parser_destroy (parser); if (rc != DC_STATUS_SUCCESS) { WARNING ("Error destroying the parser."); return rc; @@ -472,24 +472,24 @@ doparse (FILE *fp, device_data_t *devdata, const unsigned char data[], unsigned } static void -event_cb (device_t *device, device_event_t event, const void *data, void *userdata) +event_cb (dc_device_t *device, dc_event_type_t event, const void *data, void *userdata) { - const device_progress_t *progress = (device_progress_t *) data; - const device_devinfo_t *devinfo = (device_devinfo_t *) data; - const device_clock_t *clock = (device_clock_t *) data; + const dc_event_progress_t *progress = (dc_event_progress_t *) data; + const dc_event_devinfo_t *devinfo = (dc_event_devinfo_t *) data; + const dc_event_clock_t *clock = (dc_event_clock_t *) data; device_data_t *devdata = (device_data_t *) userdata; switch (event) { - case DEVICE_EVENT_WAITING: + case DC_EVENT_WAITING: message ("Event: waiting for user action\n"); break; - case DEVICE_EVENT_PROGRESS: + case DC_EVENT_PROGRESS: message ("Event: progress %3.2f%% (%u/%u)\n", 100.0 * (double) progress->current / (double) progress->maximum, progress->current, progress->maximum); break; - case DEVICE_EVENT_DEVINFO: + case DC_EVENT_DEVINFO: devdata->devinfo = *devinfo; message ("Event: model=%u (0x%08x), firmware=%u (0x%08x), serial=%u (0x%08x)\n", devinfo->model, devinfo->model, @@ -497,13 +497,13 @@ event_cb (device_t *device, device_event_t event, const void *data, void *userda devinfo->serial, devinfo->serial); if (g_cachedir && g_cachedir_read) { dc_buffer_t *fingerprint = fpread (g_cachedir, devdata->backend, devinfo->serial); - device_set_fingerprint (device, + dc_device_set_fingerprint (device, dc_buffer_get_data (fingerprint), dc_buffer_get_size (fingerprint)); dc_buffer_free (fingerprint); } break; - case DEVICE_EVENT_CLOCK: + case DC_EVENT_CLOCK: devdata->clock = *clock; message ("Event: systime=" DC_TICKS_FORMAT ", devtime=%u\n", clock->systime, clock->devtime); @@ -589,7 +589,7 @@ dowork (dc_family_t backend, unsigned int model, const char *devname, const char // Open the device. message ("Opening the device (%s, %s).\n", lookup_name (backend), devname ? devname : "null"); - device_t *device = NULL; + dc_device_t *device = NULL; switch (backend) { case DC_FAMILY_SUUNTO_SOLUTION: rc = suunto_solution_device_open (&device, devname); @@ -671,30 +671,30 @@ dowork (dc_family_t backend, unsigned int model, const char *devname, const char // Register the event handler. message ("Registering the event handler.\n"); - int events = DEVICE_EVENT_WAITING | DEVICE_EVENT_PROGRESS | DEVICE_EVENT_DEVINFO | DEVICE_EVENT_CLOCK; - rc = device_set_events (device, events, event_cb, &devdata); + int events = DC_EVENT_WAITING | DC_EVENT_PROGRESS | DC_EVENT_DEVINFO | DC_EVENT_CLOCK; + rc = dc_device_set_events (device, events, event_cb, &devdata); if (rc != DC_STATUS_SUCCESS) { WARNING ("Error registering the event handler."); - device_close (device); + dc_device_close (device); return rc; } // Register the cancellation handler. message ("Registering the cancellation handler.\n"); - rc = device_set_cancel (device, cancel_cb, NULL); + rc = dc_device_set_cancel (device, cancel_cb, NULL); if (rc != DC_STATUS_SUCCESS) { WARNING ("Error registering the cancellation handler."); - device_close (device); + dc_device_close (device); return rc; } // Register the fingerprint data. if (fingerprint) { message ("Registering the fingerprint data.\n"); - rc = device_set_fingerprint (device, dc_buffer_get_data (fingerprint), dc_buffer_get_size (fingerprint)); + rc = dc_device_set_fingerprint (device, dc_buffer_get_data (fingerprint), dc_buffer_get_size (fingerprint)); if (rc != DC_STATUS_SUCCESS) { WARNING ("Error registering the fingerprint data."); - device_close (device); + dc_device_close (device); return rc; } } @@ -705,11 +705,11 @@ dowork (dc_family_t backend, unsigned int model, const char *devname, const char // Download the memory dump. message ("Downloading the memory dump.\n"); - rc = device_dump (device, buffer); + rc = dc_device_dump (device, buffer); if (rc != DC_STATUS_SUCCESS) { WARNING ("Error downloading the memory dump."); dc_buffer_free (buffer); - device_close (device); + dc_device_close (device); return rc; } @@ -736,12 +736,12 @@ dowork (dc_family_t backend, unsigned int model, const char *devname, const char // Download the dives. message ("Downloading the dives.\n"); - rc = device_foreach (device, dive_cb, &divedata); + rc = dc_device_foreach (device, dive_cb, &divedata); if (rc != DC_STATUS_SUCCESS) { WARNING ("Error downloading the dives."); dc_buffer_free (divedata.fingerprint); if (divedata.fp) fclose (divedata.fp); - device_close (device); + dc_device_close (device); return rc; } @@ -759,7 +759,7 @@ dowork (dc_family_t backend, unsigned int model, const char *devname, const char // Close the device. message ("Closing the device.\n"); - rc = device_close (device); + rc = dc_device_close (device); if (rc != DC_STATUS_SUCCESS) { WARNING ("Error closing the device."); return rc; diff --git a/examples/uwatec_aladin_test.c b/examples/uwatec_aladin_test.c index 5e9370b..44a2552 100644 --- a/examples/uwatec_aladin_test.c +++ b/examples/uwatec_aladin_test.c @@ -8,7 +8,7 @@ dc_status_t test_dump_memory (const char* name, const char* filename) { - device_t *device = NULL; + dc_device_t *device = NULL; message ("uwatec_aladin_device_open\n"); dc_status_t rc = uwatec_aladin_device_open (&device, name); @@ -19,12 +19,12 @@ test_dump_memory (const char* name, const char* filename) dc_buffer_t *buffer = dc_buffer_new (0); - message ("device_dump\n"); - rc = device_dump (device, buffer); + message ("dc_device_dump\n"); + rc = dc_device_dump (device, buffer); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot read memory."); dc_buffer_free (buffer); - device_close (device); + dc_device_close (device); return rc; } @@ -37,8 +37,8 @@ test_dump_memory (const char* name, const char* filename) dc_buffer_free (buffer); - message ("device_close\n"); - rc = device_close (device); + message ("dc_device_close\n"); + rc = dc_device_close (device); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot close device."); return rc; diff --git a/examples/uwatec_memomouse_test.c b/examples/uwatec_memomouse_test.c index deff9e6..9636210 100644 --- a/examples/uwatec_memomouse_test.c +++ b/examples/uwatec_memomouse_test.c @@ -29,7 +29,7 @@ dc_status_t test_dump_memory (const char* name, const char* filename) { - device_t *device = NULL; + dc_device_t *device = NULL; message ("uwatec_memomouse_device_open\n"); dc_status_t rc = uwatec_memomouse_device_open (&device, name); @@ -40,12 +40,12 @@ test_dump_memory (const char* name, const char* filename) dc_buffer_t *buffer = dc_buffer_new (0); - message ("device_dump\n"); - rc = device_dump (device, buffer); + message ("dc_device_dump\n"); + rc = dc_device_dump (device, buffer); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot read memory."); dc_buffer_free (buffer); - device_close (device); + dc_device_close (device); return rc; } @@ -58,8 +58,8 @@ test_dump_memory (const char* name, const char* filename) dc_buffer_free (buffer); - message ("device_close\n"); - rc = device_close (device); + message ("dc_device_close\n"); + rc = dc_device_close (device); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot close device."); return rc; diff --git a/examples/uwatec_smart_test.c b/examples/uwatec_smart_test.c index 008f36b..24daf5f 100644 --- a/examples/uwatec_smart_test.c +++ b/examples/uwatec_smart_test.c @@ -31,7 +31,7 @@ dc_status_t test_dump_memory (const char* filename) { - device_t *device = NULL; + dc_device_t *device = NULL; message ("uwatec_smart_device_open\n"); dc_status_t rc = uwatec_smart_device_open (&device); @@ -40,23 +40,23 @@ test_dump_memory (const char* filename) return rc; } - message ("device_version\n"); + message ("dc_device_version\n"); unsigned char version[UWATEC_SMART_VERSION_SIZE] = {0}; - rc = device_version (device, version, sizeof (version)); + rc = dc_device_version (device, version, sizeof (version)); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot identify computer."); - device_close (device); + dc_device_close (device); return rc; } dc_buffer_t *buffer = dc_buffer_new (0); - message ("device_dump\n"); - rc = device_dump (device, buffer); + message ("dc_device_dump\n"); + rc = dc_device_dump (device, buffer); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot read memory."); dc_buffer_free (buffer); - device_close (device); + dc_device_close (device); return rc; } @@ -69,8 +69,8 @@ test_dump_memory (const char* filename) dc_buffer_free (buffer); - message ("device_close\n"); - rc = device_close (device); + message ("dc_device_close\n"); + rc = dc_device_close (device); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot close device."); return rc; diff --git a/examples/zeagle_n2ition3_test.c b/examples/zeagle_n2ition3_test.c index c5765ed..00efde8 100644 --- a/examples/zeagle_n2ition3_test.c +++ b/examples/zeagle_n2ition3_test.c @@ -29,7 +29,7 @@ dc_status_t test_dump_memory (const char* name, const char* filename) { - device_t *device = NULL; + dc_device_t *device = NULL; message ("zeagle_n2ition3_device_open\n"); dc_status_t rc = zeagle_n2ition3_device_open (&device, name); @@ -40,12 +40,12 @@ test_dump_memory (const char* name, const char* filename) dc_buffer_t *buffer = dc_buffer_new (0); - message ("device_dump\n"); - rc = device_dump (device, buffer); + message ("dc_device_dump\n"); + rc = dc_device_dump (device, buffer); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot read memory."); dc_buffer_free (buffer); - device_close (device); + dc_device_close (device); return rc; } @@ -58,8 +58,8 @@ test_dump_memory (const char* name, const char* filename) dc_buffer_free (buffer); - message ("device_close\n"); - rc = device_close (device); + message ("dc_device_close\n"); + rc = dc_device_close (device); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot close device."); return rc; diff --git a/include/libdivecomputer/atomics_cobalt.h b/include/libdivecomputer/atomics_cobalt.h index d94f8c1..1f9a8c0 100644 --- a/include/libdivecomputer/atomics_cobalt.h +++ b/include/libdivecomputer/atomics_cobalt.h @@ -30,16 +30,16 @@ extern "C" { #endif /* __cplusplus */ dc_status_t -atomics_cobalt_device_open (device_t **device); +atomics_cobalt_device_open (dc_device_t **device); dc_status_t -atomics_cobalt_device_set_simulation (device_t *abstract, unsigned int simulation); +atomics_cobalt_device_set_simulation (dc_device_t *device, unsigned int simulation); dc_status_t -atomics_cobalt_parser_create (parser_t **parser); +atomics_cobalt_parser_create (dc_parser_t **parser); dc_status_t -atomics_cobalt_parser_set_calibration (parser_t *abstract, double atmospheric, double hydrostatic); +atomics_cobalt_parser_set_calibration (dc_parser_t *parser, double atmospheric, double hydrostatic); #ifdef __cplusplus } diff --git a/include/libdivecomputer/cressi_edy.h b/include/libdivecomputer/cressi_edy.h index b4bfdb6..815c81b 100644 --- a/include/libdivecomputer/cressi_edy.h +++ b/include/libdivecomputer/cressi_edy.h @@ -33,10 +33,10 @@ extern "C" { #define CRESSI_EDY_PACKET_SIZE 128 dc_status_t -cressi_edy_device_open (device_t **device, const char* name); +cressi_edy_device_open (dc_device_t **device, const char *name); dc_status_t -cressi_edy_parser_create (parser_t **parser, unsigned int model); +cressi_edy_parser_create (dc_parser_t **parser, unsigned int model); #ifdef __cplusplus } diff --git a/include/libdivecomputer/device.h b/include/libdivecomputer/device.h index 655db17..3e7ebf1 100644 --- a/include/libdivecomputer/device.h +++ b/include/libdivecomputer/device.h @@ -19,8 +19,8 @@ * MA 02110-1301 USA */ -#ifndef DEVICE_H -#define DEVICE_H +#ifndef DC_DEVICE_H +#define DC_DEVICE_H #include "common.h" #include "buffer.h" @@ -30,58 +30,68 @@ extern "C" { #endif /* __cplusplus */ -typedef enum device_event_t { - DEVICE_EVENT_WAITING = (1 << 0), - DEVICE_EVENT_PROGRESS = (1 << 1), - DEVICE_EVENT_DEVINFO = (1 << 2), - DEVICE_EVENT_CLOCK = (1 << 3) -} device_event_t; +typedef enum dc_event_type_t { + DC_EVENT_WAITING = (1 << 0), + DC_EVENT_PROGRESS = (1 << 1), + DC_EVENT_DEVINFO = (1 << 2), + DC_EVENT_CLOCK = (1 << 3) +} dc_event_type_t; -typedef struct device_t device_t; +typedef struct dc_device_t dc_device_t; -typedef struct device_progress_t { +typedef struct dc_event_progress_t { unsigned int current; unsigned int maximum; -} device_progress_t; +} dc_event_progress_t; -typedef struct device_devinfo_t { +typedef struct dc_event_devinfo_t { unsigned int model; unsigned int firmware; unsigned int serial; -} device_devinfo_t; +} dc_event_devinfo_t; -typedef struct device_clock_t { +typedef struct dc_event_clock_t { unsigned int devtime; dc_ticks_t systime; -} device_clock_t; +} dc_event_clock_t; -typedef int (*device_cancel_callback_t) (void *userdata); +typedef int (*dc_cancel_callback_t) (void *userdata); -typedef void (*device_event_callback_t) (device_t *device, device_event_t event, const void *data, void *userdata); +typedef void (*dc_event_callback_t) (dc_device_t *device, dc_event_type_t event, const void *data, void *userdata); -typedef int (*dive_callback_t) (const unsigned char *data, unsigned int size, const unsigned char *fingerprint, unsigned int fsize, void *userdata); +typedef int (*dc_dive_callback_t) (const unsigned char *data, unsigned int size, const unsigned char *fingerprint, unsigned int fsize, void *userdata); -dc_family_t device_get_type (device_t *device); +dc_family_t +dc_device_get_type (dc_device_t *device); -dc_status_t device_set_cancel (device_t *device, device_cancel_callback_t callback, void *userdata); +dc_status_t +dc_device_set_cancel (dc_device_t *device, dc_cancel_callback_t callback, void *userdata); -dc_status_t device_set_events (device_t *device, unsigned int events, device_event_callback_t callback, void *userdata); +dc_status_t +dc_device_set_events (dc_device_t *device, unsigned int events, dc_event_callback_t callback, void *userdata); -dc_status_t device_set_fingerprint (device_t *device, const unsigned char data[], unsigned int size); +dc_status_t +dc_device_set_fingerprint (dc_device_t *device, const unsigned char data[], unsigned int size); -dc_status_t device_version (device_t *device, unsigned char data[], unsigned int size); +dc_status_t +dc_device_version (dc_device_t *device, unsigned char data[], unsigned int size); -dc_status_t device_read (device_t *device, unsigned int address, unsigned char data[], unsigned int size); +dc_status_t +dc_device_read (dc_device_t *device, unsigned int address, unsigned char data[], unsigned int size); -dc_status_t device_write (device_t *device, unsigned int address, const unsigned char data[], unsigned int size); +dc_status_t +dc_device_write (dc_device_t *device, unsigned int address, const unsigned char data[], unsigned int size); -dc_status_t device_dump (device_t *device, dc_buffer_t *buffer); +dc_status_t +dc_device_dump (dc_device_t *device, dc_buffer_t *buffer); -dc_status_t device_foreach (device_t *device, dive_callback_t callback, void *userdata); +dc_status_t +dc_device_foreach (dc_device_t *device, dc_dive_callback_t callback, void *userdata); -dc_status_t device_close (device_t *device); +dc_status_t +dc_device_close (dc_device_t *device); #ifdef __cplusplus } #endif /* __cplusplus */ -#endif /* DEVICE_H */ +#endif /* DC_DEVICE_H */ diff --git a/include/libdivecomputer/hw_frog.h b/include/libdivecomputer/hw_frog.h index 327439e..74441db 100644 --- a/include/libdivecomputer/hw_frog.h +++ b/include/libdivecomputer/hw_frog.h @@ -31,16 +31,16 @@ extern "C" { #endif /* __cplusplus */ dc_status_t -hw_frog_device_open (device_t **device, const char *name); +hw_frog_device_open (dc_device_t **device, const char *name); dc_status_t -hw_frog_device_clock (device_t *device, const dc_datetime_t *datetime); +hw_frog_device_clock (dc_device_t *device, const dc_datetime_t *datetime); dc_status_t -hw_frog_device_display (device_t *device, const char *text); +hw_frog_device_display (dc_device_t *device, const char *text); dc_status_t -hw_frog_device_customtext (device_t *abstract, const char *text); +hw_frog_device_customtext (dc_device_t *device, const char *text); #ifdef __cplusplus } diff --git a/include/libdivecomputer/hw_ostc.h b/include/libdivecomputer/hw_ostc.h index d879015..eeb3b07 100644 --- a/include/libdivecomputer/hw_ostc.h +++ b/include/libdivecomputer/hw_ostc.h @@ -37,31 +37,31 @@ typedef enum hw_ostc_format_t { } hw_ostc_format_t; dc_status_t -hw_ostc_device_open (device_t **device, const char* name); +hw_ostc_device_open (dc_device_t **device, const char *name); dc_status_t -hw_ostc_device_md2hash (device_t *abstract, unsigned char data[], unsigned int size); +hw_ostc_device_md2hash (dc_device_t *device, unsigned char data[], unsigned int size); dc_status_t -hw_ostc_device_clock (device_t *abstract, const dc_datetime_t *datetime); +hw_ostc_device_clock (dc_device_t *device, const dc_datetime_t *datetime); dc_status_t -hw_ostc_device_eeprom_read (device_t *abstract, unsigned int bank, unsigned char data[], unsigned int size); +hw_ostc_device_eeprom_read (dc_device_t *device, unsigned int bank, unsigned char data[], unsigned int size); dc_status_t -hw_ostc_device_eeprom_write (device_t *abstract, unsigned int bank, const unsigned char data[], unsigned int size); +hw_ostc_device_eeprom_write (dc_device_t *device, unsigned int bank, const unsigned char data[], unsigned int size); dc_status_t -hw_ostc_device_reset (device_t *abstract); +hw_ostc_device_reset (dc_device_t *device); dc_status_t -hw_ostc_device_screenshot (device_t *abstract, dc_buffer_t *buffer, hw_ostc_format_t format); +hw_ostc_device_screenshot (dc_device_t *device, dc_buffer_t *buffer, hw_ostc_format_t format); dc_status_t -hw_ostc_extract_dives (device_t *abstract, const unsigned char data[], unsigned int size, dive_callback_t callback, void *userdata); +hw_ostc_extract_dives (dc_device_t *device, const unsigned char data[], unsigned int size, dc_dive_callback_t callback, void *userdata); dc_status_t -hw_ostc_parser_create (parser_t **parser, unsigned int frog); +hw_ostc_parser_create (dc_parser_t **parser, unsigned int frog); #ifdef __cplusplus } diff --git a/include/libdivecomputer/mares_darwin.h b/include/libdivecomputer/mares_darwin.h index 97191f3..6578346 100644 --- a/include/libdivecomputer/mares_darwin.h +++ b/include/libdivecomputer/mares_darwin.h @@ -30,13 +30,13 @@ extern "C" { #endif /* __cplusplus */ dc_status_t -mares_darwin_device_open (device_t **device, const char *name, unsigned int model); +mares_darwin_device_open (dc_device_t **device, const char *name, unsigned int model); dc_status_t -mares_darwin_extract_dives (device_t *device, const unsigned char data[], unsigned int size, dive_callback_t callback, void *userdata); +mares_darwin_extract_dives (dc_device_t *device, const unsigned char data[], unsigned int size, dc_dive_callback_t callback, void *userdata); dc_status_t -mares_darwin_parser_create (parser_t **parser, unsigned int model); +mares_darwin_parser_create (dc_parser_t **parser, unsigned int model); #ifdef __cplusplus } diff --git a/include/libdivecomputer/mares_iconhd.h b/include/libdivecomputer/mares_iconhd.h index 81d044d..3765a09 100644 --- a/include/libdivecomputer/mares_iconhd.h +++ b/include/libdivecomputer/mares_iconhd.h @@ -32,13 +32,13 @@ extern "C" { #define MARES_ICONHD_MEMORY_SIZE 0x100000 dc_status_t -mares_iconhd_device_open (device_t **device, const char* name); +mares_iconhd_device_open (dc_device_t **device, const char *name); dc_status_t -mares_iconhd_extract_dives (device_t *abstract, const unsigned char data[], unsigned int size, dive_callback_t callback, void *userdata); +mares_iconhd_extract_dives (dc_device_t *device, const unsigned char data[], unsigned int size, dc_dive_callback_t callback, void *userdata); dc_status_t -mares_iconhd_parser_create (parser_t **parser, unsigned int model); +mares_iconhd_parser_create (dc_parser_t **parser, unsigned int model); #ifdef __cplusplus } diff --git a/include/libdivecomputer/mares_nemo.h b/include/libdivecomputer/mares_nemo.h index fef7684..4abbc85 100644 --- a/include/libdivecomputer/mares_nemo.h +++ b/include/libdivecomputer/mares_nemo.h @@ -30,13 +30,13 @@ extern "C" { #endif /* __cplusplus */ dc_status_t -mares_nemo_device_open (device_t **device, const char* name); +mares_nemo_device_open (dc_device_t **device, const char *name); dc_status_t -mares_nemo_extract_dives (device_t *device, const unsigned char data[], unsigned int size, dive_callback_t callback, void *userdata); +mares_nemo_extract_dives (dc_device_t *device, const unsigned char data[], unsigned int size, dc_dive_callback_t callback, void *userdata); dc_status_t -mares_nemo_parser_create (parser_t **parser, unsigned int model); +mares_nemo_parser_create (dc_parser_t **parser, unsigned int model); #ifdef __cplusplus } diff --git a/include/libdivecomputer/mares_puck.h b/include/libdivecomputer/mares_puck.h index 95761c8..7affa0d 100644 --- a/include/libdivecomputer/mares_puck.h +++ b/include/libdivecomputer/mares_puck.h @@ -30,10 +30,10 @@ extern "C" { #endif /* __cplusplus */ dc_status_t -mares_puck_device_open (device_t **device, const char* name); +mares_puck_device_open (dc_device_t **device, const char *name); dc_status_t -mares_puck_extract_dives (device_t *device, const unsigned char data[], unsigned int size, dive_callback_t callback, void *userdata); +mares_puck_extract_dives (dc_device_t *device, const unsigned char data[], unsigned int size, dc_dive_callback_t callback, void *userdata); #ifdef __cplusplus } diff --git a/include/libdivecomputer/oceanic_atom2.h b/include/libdivecomputer/oceanic_atom2.h index 9a93b30..79028ed 100644 --- a/include/libdivecomputer/oceanic_atom2.h +++ b/include/libdivecomputer/oceanic_atom2.h @@ -30,13 +30,13 @@ extern "C" { #endif /* __cplusplus */ dc_status_t -oceanic_atom2_device_open (device_t **device, const char* name); +oceanic_atom2_device_open (dc_device_t **device, const char *name); dc_status_t -oceanic_atom2_device_keepalive (device_t *device); +oceanic_atom2_device_keepalive (dc_device_t *device); dc_status_t -oceanic_atom2_parser_create (parser_t **parser, unsigned int model); +oceanic_atom2_parser_create (dc_parser_t **parser, unsigned int model); #ifdef __cplusplus } diff --git a/include/libdivecomputer/oceanic_veo250.h b/include/libdivecomputer/oceanic_veo250.h index bff4578..f254306 100644 --- a/include/libdivecomputer/oceanic_veo250.h +++ b/include/libdivecomputer/oceanic_veo250.h @@ -30,13 +30,13 @@ extern "C" { #endif /* __cplusplus */ dc_status_t -oceanic_veo250_device_open (device_t **device, const char* name); +oceanic_veo250_device_open (dc_device_t **device, const char *name); dc_status_t -oceanic_veo250_device_keepalive (device_t *device); +oceanic_veo250_device_keepalive (dc_device_t *device); dc_status_t -oceanic_veo250_parser_create (parser_t **parser, unsigned int model); +oceanic_veo250_parser_create (dc_parser_t **parser, unsigned int model); #ifdef __cplusplus } diff --git a/include/libdivecomputer/oceanic_vtpro.h b/include/libdivecomputer/oceanic_vtpro.h index db662e4..53fe02d 100644 --- a/include/libdivecomputer/oceanic_vtpro.h +++ b/include/libdivecomputer/oceanic_vtpro.h @@ -30,13 +30,13 @@ extern "C" { #endif /* __cplusplus */ dc_status_t -oceanic_vtpro_device_open (device_t **device, const char* name); +oceanic_vtpro_device_open (dc_device_t **device, const char *name); dc_status_t -oceanic_vtpro_device_keepalive (device_t *device); +oceanic_vtpro_device_keepalive (dc_device_t *device); dc_status_t -oceanic_vtpro_parser_create (parser_t **parser); +oceanic_vtpro_parser_create (dc_parser_t **parser); #ifdef __cplusplus } diff --git a/include/libdivecomputer/parser.h b/include/libdivecomputer/parser.h index 2e57982..01f5ed1 100644 --- a/include/libdivecomputer/parser.h +++ b/include/libdivecomputer/parser.h @@ -19,8 +19,8 @@ * MA 02110-1301 USA */ -#ifndef PARSER_H -#define PARSER_H +#ifndef DC_PARSER_H +#define DC_PARSER_H #include "common.h" #include "datetime.h" @@ -29,25 +29,25 @@ extern "C" { #endif /* __cplusplus */ -typedef enum parser_sample_type_t { - SAMPLE_TYPE_TIME, - SAMPLE_TYPE_DEPTH, - SAMPLE_TYPE_PRESSURE, - SAMPLE_TYPE_TEMPERATURE, - SAMPLE_TYPE_EVENT, - SAMPLE_TYPE_RBT, - SAMPLE_TYPE_HEARTBEAT, - SAMPLE_TYPE_BEARING, - SAMPLE_TYPE_VENDOR -} parser_sample_type_t; +typedef enum dc_sample_type_t { + DC_SAMPLE_TIME, + DC_SAMPLE_DEPTH, + DC_SAMPLE_PRESSURE, + DC_SAMPLE_TEMPERATURE, + DC_SAMPLE_EVENT, + DC_SAMPLE_RBT, + DC_SAMPLE_HEARTBEAT, + DC_SAMPLE_BEARING, + DC_SAMPLE_VENDOR +} dc_sample_type_t; -typedef enum parser_field_type_t { - FIELD_TYPE_DIVETIME, - FIELD_TYPE_MAXDEPTH, - FIELD_TYPE_AVGDEPTH, - FIELD_TYPE_GASMIX_COUNT, - FIELD_TYPE_GASMIX -} parser_field_type_t; +typedef enum dc_field_type_t { + DC_FIELD_DIVETIME, + DC_FIELD_MAXDEPTH, + DC_FIELD_AVGDEPTH, + DC_FIELD_GASMIX_COUNT, + DC_FIELD_GASMIX +} dc_field_type_t; typedef enum parser_sample_event_t { SAMPLE_EVENT_NONE, @@ -92,13 +92,13 @@ typedef enum parser_sample_vendor_t { SAMPLE_VENDOR_OCEANIC_ATOM2 } parser_sample_vendor_t; -typedef struct gasmix_t { +typedef struct dc_gasmix_t { double helium; double oxygen; double nitrogen; -} gasmix_t; +} dc_gasmix_t; -typedef union parser_sample_value_t { +typedef union dc_sample_value_t { unsigned int time; double depth; struct { @@ -120,31 +120,31 @@ typedef union parser_sample_value_t { unsigned int size; const void *data; } vendor; -} parser_sample_value_t; +} dc_sample_value_t; -typedef struct parser_t parser_t; +typedef struct dc_parser_t dc_parser_t; -typedef void (*sample_callback_t) (parser_sample_type_t type, parser_sample_value_t value, void *userdata); +typedef void (*dc_sample_callback_t) (dc_sample_type_t type, dc_sample_value_t value, void *userdata); dc_family_t -parser_get_type (parser_t *device); +dc_parser_get_type (dc_parser_t *parser); dc_status_t -parser_set_data (parser_t *parser, const unsigned char *data, unsigned int size); +dc_parser_set_data (dc_parser_t *parser, const unsigned char *data, unsigned int size); dc_status_t -parser_get_datetime (parser_t *parser, dc_datetime_t *datetime); +dc_parser_get_datetime (dc_parser_t *parser, dc_datetime_t *datetime); dc_status_t -parser_get_field (parser_t *parser, parser_field_type_t type, unsigned int flags, void *value); +dc_parser_get_field (dc_parser_t *parser, dc_field_type_t type, unsigned int flags, void *value); dc_status_t -parser_samples_foreach (parser_t *parser, sample_callback_t callback, void *userdata); +dc_parser_samples_foreach (dc_parser_t *parser, dc_sample_callback_t callback, void *userdata); dc_status_t -parser_destroy (parser_t *parser); +dc_parser_destroy (dc_parser_t *parser); #ifdef __cplusplus } #endif /* __cplusplus */ -#endif /* PARSER_H */ +#endif /* DC_PARSER_H */ diff --git a/include/libdivecomputer/reefnet_sensus.h b/include/libdivecomputer/reefnet_sensus.h index c49daa8..9d35129 100644 --- a/include/libdivecomputer/reefnet_sensus.h +++ b/include/libdivecomputer/reefnet_sensus.h @@ -33,22 +33,22 @@ extern "C" { #define REEFNET_SENSUS_HANDSHAKE_SIZE 10 dc_status_t -reefnet_sensus_device_open (device_t **device, const char* name); +reefnet_sensus_device_open (dc_device_t **device, const char *name); dc_status_t -reefnet_sensus_device_set_timestamp (device_t *device, unsigned int timestamp); +reefnet_sensus_device_set_timestamp (dc_device_t *device, unsigned int timestamp); dc_status_t -reefnet_sensus_device_get_handshake (device_t *abstract, unsigned char data[], unsigned int size); +reefnet_sensus_device_get_handshake (dc_device_t *device, unsigned char data[], unsigned int size); dc_status_t -reefnet_sensus_extract_dives (device_t *device, const unsigned char data[], unsigned int size, dive_callback_t callback, void *userdata); +reefnet_sensus_extract_dives (dc_device_t *device, const unsigned char data[], unsigned int size, dc_dive_callback_t callback, void *userdata); dc_status_t -reefnet_sensus_parser_create (parser_t **parser, unsigned int devtime, dc_ticks_t systime); +reefnet_sensus_parser_create (dc_parser_t **parser, unsigned int devtime, dc_ticks_t systime); dc_status_t -reefnet_sensus_parser_set_calibration (parser_t *parser, double atmospheric, double hydrostatic); +reefnet_sensus_parser_set_calibration (dc_parser_t *parser, double atmospheric, double hydrostatic); #ifdef __cplusplus } diff --git a/include/libdivecomputer/reefnet_sensuspro.h b/include/libdivecomputer/reefnet_sensuspro.h index 3598905..76fcd8d 100644 --- a/include/libdivecomputer/reefnet_sensuspro.h +++ b/include/libdivecomputer/reefnet_sensuspro.h @@ -33,25 +33,25 @@ extern "C" { #define REEFNET_SENSUSPRO_HANDSHAKE_SIZE 10 dc_status_t -reefnet_sensuspro_device_open (device_t **device, const char* name); +reefnet_sensuspro_device_open (dc_device_t **device, const char *name); dc_status_t -reefnet_sensuspro_device_set_timestamp (device_t *device, unsigned int timestamp); +reefnet_sensuspro_device_set_timestamp (dc_device_t *device, unsigned int timestamp); dc_status_t -reefnet_sensuspro_device_get_handshake (device_t *abstract, unsigned char data[], unsigned int size); +reefnet_sensuspro_device_get_handshake (dc_device_t *device, unsigned char data[], unsigned int size); dc_status_t -reefnet_sensuspro_device_write_interval (device_t *device, unsigned char interval); +reefnet_sensuspro_device_write_interval (dc_device_t *device, unsigned char interval); dc_status_t -reefnet_sensuspro_extract_dives (device_t *device, const unsigned char data[], unsigned int size, dive_callback_t callback, void *userdata); +reefnet_sensuspro_extract_dives (dc_device_t *device, const unsigned char data[], unsigned int size, dc_dive_callback_t callback, void *userdata); dc_status_t -reefnet_sensuspro_parser_create (parser_t **parser, unsigned int devtime, dc_ticks_t systime); +reefnet_sensuspro_parser_create (dc_parser_t **parser, unsigned int devtime, dc_ticks_t systime); dc_status_t -reefnet_sensuspro_parser_set_calibration (parser_t *parser, double atmospheric, double hydrostatic); +reefnet_sensuspro_parser_set_calibration (dc_parser_t *parser, double atmospheric, double hydrostatic); #ifdef __cplusplus } diff --git a/include/libdivecomputer/reefnet_sensusultra.h b/include/libdivecomputer/reefnet_sensusultra.h index 3e16549..118f607 100644 --- a/include/libdivecomputer/reefnet_sensusultra.h +++ b/include/libdivecomputer/reefnet_sensusultra.h @@ -44,37 +44,37 @@ typedef enum reefnet_sensusultra_parameter_t { } reefnet_sensusultra_parameter_t; dc_status_t -reefnet_sensusultra_device_open (device_t **device, const char* name); +reefnet_sensusultra_device_open (dc_device_t **device, const char *name); dc_status_t -reefnet_sensusultra_device_set_maxretries (device_t *device, unsigned int maxretries); +reefnet_sensusultra_device_set_maxretries (dc_device_t *device, unsigned int maxretries); dc_status_t -reefnet_sensusultra_device_set_timestamp (device_t *device, unsigned int timestamp); +reefnet_sensusultra_device_set_timestamp (dc_device_t *device, unsigned int timestamp); dc_status_t -reefnet_sensusultra_device_get_handshake (device_t *abstract, unsigned char data[], unsigned int size); +reefnet_sensusultra_device_get_handshake (dc_device_t *device, unsigned char data[], unsigned int size); dc_status_t -reefnet_sensusultra_device_read_user (device_t *device, unsigned char *data, unsigned int size); +reefnet_sensusultra_device_read_user (dc_device_t *device, unsigned char data[], unsigned int size); dc_status_t -reefnet_sensusultra_device_write_user (device_t *device, const unsigned char *data, unsigned int size); +reefnet_sensusultra_device_write_user (dc_device_t *device, const unsigned char data[], unsigned int size); dc_status_t -reefnet_sensusultra_device_write_parameter (device_t *device, reefnet_sensusultra_parameter_t parameter, unsigned int value); +reefnet_sensusultra_device_write_parameter (dc_device_t *device, reefnet_sensusultra_parameter_t parameter, unsigned int value); dc_status_t -reefnet_sensusultra_device_sense (device_t *device, unsigned char *data, unsigned int size); +reefnet_sensusultra_device_sense (dc_device_t *device, unsigned char data[], unsigned int size); dc_status_t -reefnet_sensusultra_extract_dives (device_t *device, const unsigned char data[], unsigned int size, dive_callback_t callback, void *userdata); +reefnet_sensusultra_extract_dives (dc_device_t *device, const unsigned char data[], unsigned int size, dc_dive_callback_t callback, void *userdata); dc_status_t -reefnet_sensusultra_parser_create (parser_t **parser, unsigned int devtime, dc_ticks_t systime); +reefnet_sensusultra_parser_create (dc_parser_t **parser, unsigned int devtime, dc_ticks_t systime); dc_status_t -reefnet_sensusultra_parser_set_calibration (parser_t *parser, double atmospheric, double hydrostatic); +reefnet_sensusultra_parser_set_calibration (dc_parser_t *parser, double atmospheric, double hydrostatic); #ifdef __cplusplus } diff --git a/include/libdivecomputer/suunto_d9.h b/include/libdivecomputer/suunto_d9.h index b884681..5eef1ae 100644 --- a/include/libdivecomputer/suunto_d9.h +++ b/include/libdivecomputer/suunto_d9.h @@ -34,13 +34,13 @@ extern "C" { #define SUUNTO_D9_VERSION_SIZE 0x04 dc_status_t -suunto_d9_device_open (device_t **device, const char* name, unsigned int model); +suunto_d9_device_open (dc_device_t **device, const char *name, unsigned int model); dc_status_t -suunto_d9_device_reset_maxdepth (device_t *device); +suunto_d9_device_reset_maxdepth (dc_device_t *device); dc_status_t -suunto_d9_parser_create (parser_t **parser, unsigned int model); +suunto_d9_parser_create (dc_parser_t **parser, unsigned int model); #ifdef __cplusplus } diff --git a/include/libdivecomputer/suunto_eon.h b/include/libdivecomputer/suunto_eon.h index 4c0ccd7..6247e64 100644 --- a/include/libdivecomputer/suunto_eon.h +++ b/include/libdivecomputer/suunto_eon.h @@ -32,19 +32,19 @@ extern "C" { #define SUUNTO_EON_MEMORY_SIZE 0x900 dc_status_t -suunto_eon_device_open (device_t **device, const char* name); +suunto_eon_device_open (dc_device_t **device, const char *name); dc_status_t -suunto_eon_device_write_name (device_t *device, unsigned char data[], unsigned int size); +suunto_eon_device_write_name (dc_device_t *device, unsigned char data[], unsigned int size); dc_status_t -suunto_eon_device_write_interval (device_t *device, unsigned char interval); +suunto_eon_device_write_interval (dc_device_t *device, unsigned char interval); dc_status_t -suunto_eon_extract_dives (device_t *device, const unsigned char data[], unsigned int size, dive_callback_t callback, void *userdata); +suunto_eon_extract_dives (dc_device_t *device, const unsigned char data[], unsigned int size, dc_dive_callback_t callback, void *userdata); dc_status_t -suunto_eon_parser_create (parser_t **parser, int spyder); +suunto_eon_parser_create (dc_parser_t **parser, int spyder); #ifdef __cplusplus } diff --git a/include/libdivecomputer/suunto_solution.h b/include/libdivecomputer/suunto_solution.h index 64e4903..adcbd7a 100644 --- a/include/libdivecomputer/suunto_solution.h +++ b/include/libdivecomputer/suunto_solution.h @@ -32,13 +32,13 @@ extern "C" { #define SUUNTO_SOLUTION_MEMORY_SIZE 256 dc_status_t -suunto_solution_device_open (device_t **device, const char* name); +suunto_solution_device_open (dc_device_t **device, const char *name); dc_status_t -suunto_solution_extract_dives (device_t *device, const unsigned char data[], unsigned int size, dive_callback_t callback, void *userdata); +suunto_solution_extract_dives (dc_device_t *device, const unsigned char data[], unsigned int size, dc_dive_callback_t callback, void *userdata); dc_status_t -suunto_solution_parser_create (parser_t **parser); +suunto_solution_parser_create (dc_parser_t **parser); #ifdef __cplusplus } diff --git a/include/libdivecomputer/suunto_vyper.h b/include/libdivecomputer/suunto_vyper.h index ac0a1a1..a4da525 100644 --- a/include/libdivecomputer/suunto_vyper.h +++ b/include/libdivecomputer/suunto_vyper.h @@ -33,19 +33,19 @@ extern "C" { #define SUUNTO_VYPER_PACKET_SIZE 32 dc_status_t -suunto_vyper_device_open (device_t **device, const char* name); +suunto_vyper_device_open (dc_device_t **device, const char *name); dc_status_t -suunto_vyper_device_set_delay (device_t *device, unsigned int delay); +suunto_vyper_device_set_delay (dc_device_t *device, unsigned int delay); dc_status_t -suunto_vyper_device_read_dive (device_t *device, dc_buffer_t *buffer, int init); +suunto_vyper_device_read_dive (dc_device_t *device, dc_buffer_t *buffer, int init); dc_status_t -suunto_vyper_extract_dives (device_t *device, const unsigned char data[], unsigned int size, dive_callback_t callback, void *userdata); +suunto_vyper_extract_dives (dc_device_t *device, const unsigned char data[], unsigned int size, dc_dive_callback_t callback, void *userdata); dc_status_t -suunto_vyper_parser_create (parser_t **parser); +suunto_vyper_parser_create (dc_parser_t **parser); #ifdef __cplusplus } diff --git a/include/libdivecomputer/suunto_vyper2.h b/include/libdivecomputer/suunto_vyper2.h index 279249a..c1fec8c 100644 --- a/include/libdivecomputer/suunto_vyper2.h +++ b/include/libdivecomputer/suunto_vyper2.h @@ -33,10 +33,10 @@ extern "C" { #define SUUNTO_VYPER2_VERSION_SIZE 0x04 dc_status_t -suunto_vyper2_device_open (device_t **device, const char* name); +suunto_vyper2_device_open (dc_device_t **device, const char *name); dc_status_t -suunto_vyper2_device_reset_maxdepth (device_t *device); +suunto_vyper2_device_reset_maxdepth (dc_device_t *device); #ifdef __cplusplus } diff --git a/include/libdivecomputer/uwatec_aladin.h b/include/libdivecomputer/uwatec_aladin.h index 8280bc8..26eb75e 100644 --- a/include/libdivecomputer/uwatec_aladin.h +++ b/include/libdivecomputer/uwatec_aladin.h @@ -31,13 +31,13 @@ extern "C" { #define UWATEC_ALADIN_MEMORY_SIZE 2048 dc_status_t -uwatec_aladin_device_open (device_t **device, const char* name); +uwatec_aladin_device_open (dc_device_t **device, const char *name); dc_status_t -uwatec_aladin_device_set_timestamp (device_t *device, unsigned int timestamp); +uwatec_aladin_device_set_timestamp (dc_device_t *device, unsigned int timestamp); dc_status_t -uwatec_aladin_extract_dives (device_t *device, const unsigned char data[], unsigned int size, dive_callback_t callback, void *userdata); +uwatec_aladin_extract_dives (dc_device_t *device, const unsigned char data[], unsigned int size, dc_dive_callback_t callback, void *userdata); #ifdef __cplusplus } diff --git a/include/libdivecomputer/uwatec_memomouse.h b/include/libdivecomputer/uwatec_memomouse.h index 04568a4..eca4758 100644 --- a/include/libdivecomputer/uwatec_memomouse.h +++ b/include/libdivecomputer/uwatec_memomouse.h @@ -30,16 +30,16 @@ extern "C" { #endif /* __cplusplus */ dc_status_t -uwatec_memomouse_device_open (device_t **device, const char* name); +uwatec_memomouse_device_open (dc_device_t **device, const char *name); dc_status_t -uwatec_memomouse_device_set_timestamp (device_t *device, unsigned int timestamp); +uwatec_memomouse_device_set_timestamp (dc_device_t *device, unsigned int timestamp); dc_status_t -uwatec_memomouse_extract_dives (device_t *device, const unsigned char data[], unsigned int size, dive_callback_t callback, void *userdata); +uwatec_memomouse_extract_dives (dc_device_t *device, const unsigned char data[], unsigned int size, dc_dive_callback_t callback, void *userdata); dc_status_t -uwatec_memomouse_parser_create (parser_t **parser, unsigned int devtime, dc_ticks_t systime); +uwatec_memomouse_parser_create (dc_parser_t **parser, unsigned int devtime, dc_ticks_t systime); #ifdef __cplusplus } diff --git a/include/libdivecomputer/uwatec_smart.h b/include/libdivecomputer/uwatec_smart.h index ec6ebe3..48a84b2 100644 --- a/include/libdivecomputer/uwatec_smart.h +++ b/include/libdivecomputer/uwatec_smart.h @@ -32,16 +32,16 @@ extern "C" { #define UWATEC_SMART_VERSION_SIZE 9 dc_status_t -uwatec_smart_device_open (device_t **device); +uwatec_smart_device_open (dc_device_t **device); dc_status_t -uwatec_smart_device_set_timestamp (device_t *device, unsigned int timestamp); +uwatec_smart_device_set_timestamp (dc_device_t *device, unsigned int timestamp); dc_status_t -uwatec_smart_extract_dives (device_t *device, const unsigned char data[], unsigned int size, dive_callback_t callback, void *userdata); +uwatec_smart_extract_dives (dc_device_t *device, const unsigned char data[], unsigned int size, dc_dive_callback_t callback, void *userdata); dc_status_t -uwatec_smart_parser_create (parser_t **parser, unsigned int model, unsigned int devtime, dc_ticks_t systime); +uwatec_smart_parser_create (dc_parser_t **parser, unsigned int model, unsigned int devtime, dc_ticks_t systime); #ifdef __cplusplus } diff --git a/include/libdivecomputer/zeagle_n2ition3.h b/include/libdivecomputer/zeagle_n2ition3.h index eb7e50f..4e1de7a 100644 --- a/include/libdivecomputer/zeagle_n2ition3.h +++ b/include/libdivecomputer/zeagle_n2ition3.h @@ -32,7 +32,7 @@ extern "C" { #define ZEAGLE_N2ITION3_PACKET_SIZE 64 dc_status_t -zeagle_n2ition3_device_open (device_t **device, const char* name); +zeagle_n2ition3_device_open (dc_device_t **device, const char *name); #ifdef __cplusplus } diff --git a/src/atomics_cobalt.c b/src/atomics_cobalt.c index c89a725..66907a3 100644 --- a/src/atomics_cobalt.c +++ b/src/atomics_cobalt.c @@ -47,7 +47,7 @@ #define SZ_VERSION 14 typedef struct atomics_cobalt_device_t { - device_t base; + dc_device_t base; #ifdef HAVE_LIBUSB libusb_context *context; libusb_device_handle *handle; @@ -57,10 +57,10 @@ typedef struct atomics_cobalt_device_t { unsigned char version[SZ_VERSION]; } atomics_cobalt_device_t; -static dc_status_t atomics_cobalt_device_set_fingerprint (device_t *abstract, const unsigned char data[], unsigned int size); -static dc_status_t atomics_cobalt_device_version (device_t *abstract, unsigned char data[], unsigned int size); -static dc_status_t atomics_cobalt_device_foreach (device_t *abstract, dive_callback_t callback, void *userdata); -static dc_status_t atomics_cobalt_device_close (device_t *abstract); +static dc_status_t atomics_cobalt_device_set_fingerprint (dc_device_t *abstract, const unsigned char data[], unsigned int size); +static dc_status_t atomics_cobalt_device_version (dc_device_t *abstract, unsigned char data[], unsigned int size); +static dc_status_t atomics_cobalt_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, void *userdata); +static dc_status_t atomics_cobalt_device_close (dc_device_t *abstract); static const device_backend_t atomics_cobalt_device_backend = { DC_FAMILY_ATOMICS_COBALT, @@ -74,7 +74,7 @@ static const device_backend_t atomics_cobalt_device_backend = { }; static int -device_is_atomics_cobalt (device_t *abstract) +device_is_atomics_cobalt (dc_device_t *abstract) { if (abstract == NULL) return 0; @@ -84,7 +84,7 @@ device_is_atomics_cobalt (device_t *abstract) dc_status_t -atomics_cobalt_device_open (device_t **out) +atomics_cobalt_device_open (dc_device_t **out) { if (out == NULL) return DC_STATUS_INVALIDARGS; @@ -130,7 +130,7 @@ atomics_cobalt_device_open (device_t **out) return DC_STATUS_IO; } - dc_status_t status = atomics_cobalt_device_version ((device_t *) device, device->version, sizeof (device->version)); + dc_status_t status = atomics_cobalt_device_version ((dc_device_t *) device, device->version, sizeof (device->version)); if (status != DC_STATUS_SUCCESS) { WARNING ("Failed to identify the dive computer."); libusb_close (device->handle); @@ -139,7 +139,7 @@ atomics_cobalt_device_open (device_t **out) return status; } - *out = (device_t*) device; + *out = (dc_device_t*) device; return DC_STATUS_SUCCESS; #else @@ -149,7 +149,7 @@ atomics_cobalt_device_open (device_t **out) static dc_status_t -atomics_cobalt_device_close (device_t *abstract) +atomics_cobalt_device_close (dc_device_t *abstract) { atomics_cobalt_device_t *device = (atomics_cobalt_device_t *) abstract; @@ -170,7 +170,7 @@ atomics_cobalt_device_close (device_t *abstract) static dc_status_t -atomics_cobalt_device_set_fingerprint (device_t *abstract, const unsigned char data[], unsigned int size) +atomics_cobalt_device_set_fingerprint (dc_device_t *abstract, const unsigned char data[], unsigned int size) { atomics_cobalt_device_t *device = (atomics_cobalt_device_t *) abstract; @@ -190,7 +190,7 @@ atomics_cobalt_device_set_fingerprint (device_t *abstract, const unsigned char d dc_status_t -atomics_cobalt_device_set_simulation (device_t *abstract, unsigned int simulation) +atomics_cobalt_device_set_simulation (dc_device_t *abstract, unsigned int simulation) { atomics_cobalt_device_t *device = (atomics_cobalt_device_t *) abstract; @@ -204,7 +204,7 @@ atomics_cobalt_device_set_simulation (device_t *abstract, unsigned int simulatio static dc_status_t -atomics_cobalt_device_version (device_t *abstract, unsigned char data[], unsigned int size) +atomics_cobalt_device_version (dc_device_t *abstract, unsigned char data[], unsigned int size) { atomics_cobalt_device_t *device = (atomics_cobalt_device_t *) abstract; @@ -250,7 +250,7 @@ atomics_cobalt_device_version (device_t *abstract, unsigned char data[], unsigne static dc_status_t -atomics_cobalt_read_dive (device_t *abstract, dc_buffer_t *buffer, int init, device_progress_t *progress) +atomics_cobalt_read_dive (dc_device_t *abstract, dc_buffer_t *buffer, int init, dc_event_progress_t *progress) { #ifdef HAVE_LIBUSB atomics_cobalt_device_t *device = (atomics_cobalt_device_t *) abstract; @@ -293,7 +293,7 @@ atomics_cobalt_read_dive (device_t *abstract, dc_buffer_t *buffer, int init, dev // Update and emit a progress event. if (progress) { progress->current += length; - device_event_emit (abstract, DEVICE_EVENT_PROGRESS, progress); + device_event_emit (abstract, DC_EVENT_PROGRESS, progress); } // Append the packet to the output buffer. @@ -343,7 +343,7 @@ atomics_cobalt_read_dive (device_t *abstract, dc_buffer_t *buffer, int init, dev static dc_status_t -atomics_cobalt_device_foreach (device_t *abstract, dive_callback_t callback, void *userdata) +atomics_cobalt_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, void *userdata) { atomics_cobalt_device_t *device = (atomics_cobalt_device_t *) abstract; @@ -351,12 +351,12 @@ atomics_cobalt_device_foreach (device_t *abstract, dive_callback_t callback, voi return DC_STATUS_INVALIDARGS; // Enable progress notifications. - device_progress_t progress = DEVICE_PROGRESS_INITIALIZER; + dc_event_progress_t progress = EVENT_PROGRESS_INITIALIZER; progress.maximum = SZ_MEMORY + 2; - device_event_emit (abstract, DEVICE_EVENT_PROGRESS, &progress); + device_event_emit (abstract, DC_EVENT_PROGRESS, &progress); // Emit a device info event. - device_devinfo_t devinfo; + dc_event_devinfo_t devinfo; devinfo.model = array_uint16_le (device->version + 12); devinfo.firmware = (array_uint16_le (device->version + 8) << 16) + array_uint16_le (device->version + 10); @@ -365,7 +365,7 @@ atomics_cobalt_device_foreach (device_t *abstract, dive_callback_t callback, voi devinfo.serial *= 10; devinfo.serial += device->version[i] - '0'; } - device_event_emit (abstract, DEVICE_EVENT_DEVINFO, &devinfo); + device_event_emit (abstract, DC_EVENT_DEVINFO, &devinfo); // Allocate a memory buffer. dc_buffer_t *buffer = dc_buffer_new (0); diff --git a/src/atomics_cobalt_parser.c b/src/atomics_cobalt_parser.c index 495f448..c8c0c7f 100644 --- a/src/atomics_cobalt_parser.c +++ b/src/atomics_cobalt_parser.c @@ -36,17 +36,17 @@ typedef struct atomics_cobalt_parser_t atomics_cobalt_parser_t; struct atomics_cobalt_parser_t { - parser_t base; + dc_parser_t base; // Depth calibration. double atmospheric; double hydrostatic; }; -static dc_status_t atomics_cobalt_parser_set_data (parser_t *abstract, const unsigned char *data, unsigned int size); -static dc_status_t atomics_cobalt_parser_get_datetime (parser_t *abstract, dc_datetime_t *datetime); -static dc_status_t atomics_cobalt_parser_get_field (parser_t *abstract, parser_field_type_t type, unsigned int flags, void *value); -static dc_status_t atomics_cobalt_parser_samples_foreach (parser_t *abstract, sample_callback_t callback, void *userdata); -static dc_status_t atomics_cobalt_parser_destroy (parser_t *abstract); +static dc_status_t atomics_cobalt_parser_set_data (dc_parser_t *abstract, const unsigned char *data, unsigned int size); +static dc_status_t atomics_cobalt_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *datetime); +static dc_status_t atomics_cobalt_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsigned int flags, void *value); +static dc_status_t atomics_cobalt_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t callback, void *userdata); +static dc_status_t atomics_cobalt_parser_destroy (dc_parser_t *abstract); static const parser_backend_t atomics_cobalt_parser_backend = { DC_FAMILY_ATOMICS_COBALT, @@ -59,7 +59,7 @@ static const parser_backend_t atomics_cobalt_parser_backend = { static int -parser_is_atomics_cobalt (parser_t *abstract) +parser_is_atomics_cobalt (dc_parser_t *abstract) { if (abstract == NULL) return 0; @@ -69,7 +69,7 @@ parser_is_atomics_cobalt (parser_t *abstract) dc_status_t -atomics_cobalt_parser_create (parser_t **out) +atomics_cobalt_parser_create (dc_parser_t **out) { if (out == NULL) return DC_STATUS_INVALIDARGS; @@ -88,14 +88,14 @@ atomics_cobalt_parser_create (parser_t **out) parser->atmospheric = 0.0; parser->hydrostatic = 1025.0 * GRAVITY; - *out = (parser_t*) parser; + *out = (dc_parser_t*) parser; return DC_STATUS_SUCCESS; } static dc_status_t -atomics_cobalt_parser_destroy (parser_t *abstract) +atomics_cobalt_parser_destroy (dc_parser_t *abstract) { if (! parser_is_atomics_cobalt (abstract)) return DC_STATUS_INVALIDARGS; @@ -108,7 +108,7 @@ atomics_cobalt_parser_destroy (parser_t *abstract) static dc_status_t -atomics_cobalt_parser_set_data (parser_t *abstract, const unsigned char *data, unsigned int size) +atomics_cobalt_parser_set_data (dc_parser_t *abstract, const unsigned char *data, unsigned int size) { if (! parser_is_atomics_cobalt (abstract)) return DC_STATUS_INVALIDARGS; @@ -118,7 +118,7 @@ atomics_cobalt_parser_set_data (parser_t *abstract, const unsigned char *data, u dc_status_t -atomics_cobalt_parser_set_calibration (parser_t *abstract, double atmospheric, double hydrostatic) +atomics_cobalt_parser_set_calibration (dc_parser_t *abstract, double atmospheric, double hydrostatic) { atomics_cobalt_parser_t *parser = (atomics_cobalt_parser_t*) abstract; @@ -133,7 +133,7 @@ atomics_cobalt_parser_set_calibration (parser_t *abstract, double atmospheric, d static dc_status_t -atomics_cobalt_parser_get_datetime (parser_t *abstract, dc_datetime_t *datetime) +atomics_cobalt_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *datetime) { if (abstract->size < SZ_HEADER) return DC_STATUS_DATAFORMAT; @@ -154,7 +154,7 @@ atomics_cobalt_parser_get_datetime (parser_t *abstract, dc_datetime_t *datetime) static dc_status_t -atomics_cobalt_parser_get_field (parser_t *abstract, parser_field_type_t type, unsigned int flags, void *value) +atomics_cobalt_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsigned int flags, void *value) { atomics_cobalt_parser_t *parser = (atomics_cobalt_parser_t *) abstract; @@ -163,7 +163,7 @@ atomics_cobalt_parser_get_field (parser_t *abstract, parser_field_type_t type, u const unsigned char *p = abstract->data; - gasmix_t *gasmix = (gasmix_t *) value; + dc_gasmix_t *gasmix = (dc_gasmix_t *) value; double atmospheric = 0.0; if (parser->atmospheric) @@ -173,16 +173,16 @@ atomics_cobalt_parser_get_field (parser_t *abstract, parser_field_type_t type, u if (value) { switch (type) { - case FIELD_TYPE_DIVETIME: + case DC_FIELD_DIVETIME: *((unsigned int *) value) = array_uint16_le (p + 0x58) * 60; break; - case FIELD_TYPE_MAXDEPTH: + case DC_FIELD_MAXDEPTH: *((double *) value) = (array_uint16_le (p + 0x56) * BAR / 1000.0 - atmospheric) / parser->hydrostatic; break; - case FIELD_TYPE_GASMIX_COUNT: + case DC_FIELD_GASMIX_COUNT: *((unsigned int *) value) = p[0x2a]; break; - case FIELD_TYPE_GASMIX: + case DC_FIELD_GASMIX: gasmix->helium = p[SZ_HEADER + SZ_GASMIX * flags + 5] / 100.0; gasmix->oxygen = p[SZ_HEADER + SZ_GASMIX * flags + 4] / 100.0; gasmix->nitrogen = 1.0 - gasmix->oxygen - gasmix->helium; @@ -197,7 +197,7 @@ atomics_cobalt_parser_get_field (parser_t *abstract, parser_field_type_t type, u static dc_status_t -atomics_cobalt_parser_samples_foreach (parser_t *abstract, sample_callback_t callback, void *userdata) +atomics_cobalt_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t callback, void *userdata) { atomics_cobalt_parser_t *parser = (atomics_cobalt_parser_t *) abstract; @@ -227,28 +227,28 @@ atomics_cobalt_parser_samples_foreach (parser_t *abstract, sample_callback_t cal unsigned int time = 0; unsigned int offset = header; while (offset + SZ_SEGMENT <= size) { - parser_sample_value_t sample = {0}; + dc_sample_value_t sample = {0}; // Time (seconds). time += interval; sample.time = time; - if (callback) callback (SAMPLE_TYPE_TIME, sample, userdata); + if (callback) callback (DC_SAMPLE_TIME, sample, userdata); // Depth (1/1000 bar). unsigned int depth = array_uint16_le (data + offset + 0); sample.depth = (depth * BAR / 1000.0 - atmospheric) / parser->hydrostatic; - if (callback) callback (SAMPLE_TYPE_DEPTH, sample, userdata); + if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); // Pressure (1 psi). unsigned int pressure = array_uint16_le (data + offset + 2); sample.pressure.tank = 0; sample.pressure.value = pressure * PSI / BAR; - if (callback) callback (SAMPLE_TYPE_PRESSURE, sample, userdata); + if (callback) callback (DC_SAMPLE_PRESSURE, sample, userdata); // Temperature (1 °F). unsigned int temperature = data[offset + 8]; sample.temperature = (temperature - 32.0) * (5.0 / 9.0); - if (callback) callback (SAMPLE_TYPE_TEMPERATURE, sample, userdata); + if (callback) callback (DC_SAMPLE_TEMPERATURE, sample, userdata); offset += SZ_SEGMENT; } diff --git a/src/cressi_edy.c b/src/cressi_edy.c index 33f0f14..57b8f17 100644 --- a/src/cressi_edy.c +++ b/src/cressi_edy.c @@ -49,17 +49,17 @@ #define RB_LOGBOOK_END 60 typedef struct cressi_edy_device_t { - device_t base; + dc_device_t base; serial_t *port; unsigned char fingerprint[PAGESIZE / 2]; unsigned int model; } cressi_edy_device_t; -static dc_status_t cressi_edy_device_set_fingerprint (device_t *abstract, const unsigned char data[], unsigned int size); -static dc_status_t cressi_edy_device_read (device_t *abstract, unsigned int address, unsigned char data[], unsigned int size); -static dc_status_t cressi_edy_device_dump (device_t *abstract, dc_buffer_t *buffer); -static dc_status_t cressi_edy_device_foreach (device_t *abstract, dive_callback_t callback, void *userdata); -static dc_status_t cressi_edy_device_close (device_t *abstract); +static dc_status_t cressi_edy_device_set_fingerprint (dc_device_t *abstract, const unsigned char data[], unsigned int size); +static dc_status_t cressi_edy_device_read (dc_device_t *abstract, unsigned int address, unsigned char data[], unsigned int size); +static dc_status_t cressi_edy_device_dump (dc_device_t *abstract, dc_buffer_t *buffer); +static dc_status_t cressi_edy_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, void *userdata); +static dc_status_t cressi_edy_device_close (dc_device_t *abstract); static const device_backend_t cressi_edy_device_backend = { DC_FAMILY_CRESSI_EDY, @@ -73,7 +73,7 @@ static const device_backend_t cressi_edy_device_backend = { }; static int -device_is_cressi_edy (device_t *abstract) +device_is_cressi_edy (dc_device_t *abstract) { if (abstract == NULL) return 0; @@ -171,7 +171,7 @@ cressi_edy_quit (cressi_edy_device_t *device) dc_status_t -cressi_edy_device_open (device_t **out, const char* name) +cressi_edy_device_open (dc_device_t **out, const char *name) { if (out == NULL) return DC_STATUS_INVALIDARGS; @@ -238,14 +238,14 @@ cressi_edy_device_open (device_t **out, const char* name) return DC_STATUS_IO; } - *out = (device_t*) device; + *out = (dc_device_t*) device; return DC_STATUS_SUCCESS; } static dc_status_t -cressi_edy_device_close (device_t *abstract) +cressi_edy_device_close (dc_device_t *abstract) { cressi_edy_device_t *device = (cressi_edy_device_t*) abstract; @@ -269,7 +269,7 @@ cressi_edy_device_close (device_t *abstract) static dc_status_t -cressi_edy_device_read (device_t *abstract, unsigned int address, unsigned char data[], unsigned int size) +cressi_edy_device_read (dc_device_t *abstract, unsigned int address, unsigned char data[], unsigned int size) { cressi_edy_device_t *device = (cressi_edy_device_t*) abstract; @@ -307,7 +307,7 @@ cressi_edy_device_read (device_t *abstract, unsigned int address, unsigned char static dc_status_t -cressi_edy_device_set_fingerprint (device_t *abstract, const unsigned char data[], unsigned int size) +cressi_edy_device_set_fingerprint (dc_device_t *abstract, const unsigned char data[], unsigned int size) { cressi_edy_device_t *device = (cressi_edy_device_t *) abstract; @@ -324,7 +324,7 @@ cressi_edy_device_set_fingerprint (device_t *abstract, const unsigned char data[ static dc_status_t -cressi_edy_device_dump (device_t *abstract, dc_buffer_t *buffer) +cressi_edy_device_dump (dc_device_t *abstract, dc_buffer_t *buffer) { if (! device_is_cressi_edy (abstract)) return DC_STATUS_INVALIDARGS; @@ -342,22 +342,22 @@ cressi_edy_device_dump (device_t *abstract, dc_buffer_t *buffer) static dc_status_t -cressi_edy_device_foreach (device_t *abstract, dive_callback_t callback, void *userdata) +cressi_edy_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, void *userdata) { cressi_edy_device_t *device = (cressi_edy_device_t *) abstract; // Enable progress notifications. - device_progress_t progress = DEVICE_PROGRESS_INITIALIZER; + dc_event_progress_t progress = EVENT_PROGRESS_INITIALIZER; progress.maximum = CRESSI_EDY_PACKET_SIZE + (RB_PROFILE_END - RB_PROFILE_BEGIN); - device_event_emit (abstract, DEVICE_EVENT_PROGRESS, &progress); + device_event_emit (abstract, DC_EVENT_PROGRESS, &progress); // Emit a device info event. - device_devinfo_t devinfo; + dc_event_devinfo_t devinfo; devinfo.model = device->model; devinfo.firmware = 0; devinfo.serial = 0; - device_event_emit (abstract, DEVICE_EVENT_DEVINFO, &devinfo); + device_event_emit (abstract, DC_EVENT_DEVINFO, &devinfo); // Read the configuration data. unsigned char config[CRESSI_EDY_PACKET_SIZE] = {0}; @@ -369,7 +369,7 @@ cressi_edy_device_foreach (device_t *abstract, dive_callback_t callback, void *u // Update and emit a progress event. progress.current += CRESSI_EDY_PACKET_SIZE; - device_event_emit (abstract, DEVICE_EVENT_PROGRESS, &progress); + device_event_emit (abstract, DC_EVENT_PROGRESS, &progress); // Get the logbook pointers. unsigned int last = config[0x7C]; @@ -434,7 +434,7 @@ cressi_edy_device_foreach (device_t *abstract, dive_callback_t callback, void *u // Update and emit a progress event. progress.current += CRESSI_EDY_PACKET_SIZE; - device_event_emit (abstract, DEVICE_EVENT_PROGRESS, &progress); + device_event_emit (abstract, DC_EVENT_PROGRESS, &progress); nbytes += CRESSI_EDY_PACKET_SIZE; } diff --git a/src/cressi_edy_parser.c b/src/cressi_edy_parser.c index bad3a61..d0d1854 100644 --- a/src/cressi_edy_parser.c +++ b/src/cressi_edy_parser.c @@ -30,15 +30,15 @@ typedef struct cressi_edy_parser_t cressi_edy_parser_t; struct cressi_edy_parser_t { - parser_t base; + dc_parser_t base; unsigned int model; }; -static dc_status_t cressi_edy_parser_set_data (parser_t *abstract, const unsigned char *data, unsigned int size); -static dc_status_t cressi_edy_parser_get_datetime (parser_t *abstract, dc_datetime_t *datetime); -static dc_status_t cressi_edy_parser_get_field (parser_t *abstract, parser_field_type_t type, unsigned int flags, void *value); -static dc_status_t cressi_edy_parser_samples_foreach (parser_t *abstract, sample_callback_t callback, void *userdata); -static dc_status_t cressi_edy_parser_destroy (parser_t *abstract); +static dc_status_t cressi_edy_parser_set_data (dc_parser_t *abstract, const unsigned char *data, unsigned int size); +static dc_status_t cressi_edy_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *datetime); +static dc_status_t cressi_edy_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsigned int flags, void *value); +static dc_status_t cressi_edy_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t callback, void *userdata); +static dc_status_t cressi_edy_parser_destroy (dc_parser_t *abstract); static const parser_backend_t cressi_edy_parser_backend = { DC_FAMILY_CRESSI_EDY, @@ -51,7 +51,7 @@ static const parser_backend_t cressi_edy_parser_backend = { static int -parser_is_cressi_edy (parser_t *abstract) +parser_is_cressi_edy (dc_parser_t *abstract) { if (abstract == NULL) return 0; @@ -61,7 +61,7 @@ parser_is_cressi_edy (parser_t *abstract) dc_status_t -cressi_edy_parser_create (parser_t **out, unsigned int model) +cressi_edy_parser_create (dc_parser_t **out, unsigned int model) { if (out == NULL) return DC_STATUS_INVALIDARGS; @@ -79,14 +79,14 @@ cressi_edy_parser_create (parser_t **out, unsigned int model) // Set the default values. parser->model = model; - *out = (parser_t*) parser; + *out = (dc_parser_t*) parser; return DC_STATUS_SUCCESS; } static dc_status_t -cressi_edy_parser_destroy (parser_t *abstract) +cressi_edy_parser_destroy (dc_parser_t *abstract) { if (! parser_is_cressi_edy (abstract)) return DC_STATUS_INVALIDARGS; @@ -99,7 +99,7 @@ cressi_edy_parser_destroy (parser_t *abstract) static dc_status_t -cressi_edy_parser_set_data (parser_t *abstract, const unsigned char *data, unsigned int size) +cressi_edy_parser_set_data (dc_parser_t *abstract, const unsigned char *data, unsigned int size) { if (! parser_is_cressi_edy (abstract)) return DC_STATUS_INVALIDARGS; @@ -109,7 +109,7 @@ cressi_edy_parser_set_data (parser_t *abstract, const unsigned char *data, unsig static dc_status_t -cressi_edy_parser_get_datetime (parser_t *abstract, dc_datetime_t *datetime) +cressi_edy_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *datetime) { if (abstract->size < 32) return DC_STATUS_DATAFORMAT; @@ -130,7 +130,7 @@ cressi_edy_parser_get_datetime (parser_t *abstract, dc_datetime_t *datetime) static dc_status_t -cressi_edy_parser_get_field (parser_t *abstract, parser_field_type_t type, unsigned int flags, void *value) +cressi_edy_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsigned int flags, void *value) { cressi_edy_parser_t *parser = (cressi_edy_parser_t *) abstract; @@ -139,23 +139,23 @@ cressi_edy_parser_get_field (parser_t *abstract, parser_field_type_t type, unsig const unsigned char *p = abstract->data; - gasmix_t *gasmix = (gasmix_t *) value; + dc_gasmix_t *gasmix = (dc_gasmix_t *) value; if (value) { switch (type) { - case FIELD_TYPE_DIVETIME: + case DC_FIELD_DIVETIME: if (parser->model == 0x08) *((unsigned int *) value) = bcd2dec (p[0x0C] & 0x0F) * 60 + bcd2dec (p[0x0D]); else *((unsigned int *) value) = (bcd2dec (p[0x0C] & 0x0F) * 100 + bcd2dec (p[0x0D])) * 60; break; - case FIELD_TYPE_MAXDEPTH: + case DC_FIELD_MAXDEPTH: *((double *) value) = (bcd2dec (p[0x02] & 0x0F) * 100 + bcd2dec (p[0x03])) / 10.0; break; - case FIELD_TYPE_GASMIX_COUNT: + case DC_FIELD_GASMIX_COUNT: *((unsigned int *) value) = 3; break; - case FIELD_TYPE_GASMIX: + case DC_FIELD_GASMIX: gasmix->helium = 0.0; gasmix->oxygen = bcd2dec (p[0x17 - flags]) / 100.0; gasmix->nitrogen = 1.0 - gasmix->oxygen - gasmix->helium; @@ -170,7 +170,7 @@ cressi_edy_parser_get_field (parser_t *abstract, parser_field_type_t type, unsig static dc_status_t -cressi_edy_parser_samples_foreach (parser_t *abstract, sample_callback_t callback, void *userdata) +cressi_edy_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t callback, void *userdata) { cressi_edy_parser_t *parser = (cressi_edy_parser_t *) abstract; @@ -186,7 +186,7 @@ cressi_edy_parser_samples_foreach (parser_t *abstract, sample_callback_t callbac unsigned int offset = 32; while (offset + 2 <= size) { - parser_sample_value_t sample = {0}; + dc_sample_value_t sample = {0}; if (data[offset] == 0xFF) break; @@ -198,12 +198,12 @@ cressi_edy_parser_samples_foreach (parser_t *abstract, sample_callback_t callbac // Time (seconds). time += interval; sample.time = time; - if (callback) callback (SAMPLE_TYPE_TIME, sample, userdata); + if (callback) callback (DC_SAMPLE_TIME, sample, userdata); // Depth (1/10 m). unsigned int depth = bcd2dec (data[offset + 0] & 0x0F) * 100 + bcd2dec (data[offset + 1]); sample.depth = depth / 10.0; - if (callback) callback (SAMPLE_TYPE_DEPTH, sample, userdata); + if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); offset += 2 + extra; } diff --git a/src/device-private.h b/src/device-private.h index fb01ec4..8b3afea 100644 --- a/src/device-private.h +++ b/src/device-private.h @@ -30,53 +30,53 @@ extern "C" { #endif /* __cplusplus */ -#define DEVICE_PROGRESS_INITIALIZER {0, UINT_MAX} +#define EVENT_PROGRESS_INITIALIZER {0, UINT_MAX} -struct device_t; +struct dc_device_t; struct device_backend_t; typedef struct device_backend_t device_backend_t; -struct device_t { +struct dc_device_t { const device_backend_t *backend; // Event notifications. unsigned int event_mask; - device_event_callback_t event_callback; + dc_event_callback_t event_callback; void *event_userdata; // Cancellation support. - device_cancel_callback_t cancel_callback; + dc_cancel_callback_t cancel_callback; void *cancel_userdata; }; struct device_backend_t { dc_family_t type; - dc_status_t (*set_fingerprint) (device_t *device, const unsigned char data[], unsigned int size); + dc_status_t (*set_fingerprint) (dc_device_t *device, const unsigned char data[], unsigned int size); - dc_status_t (*version) (device_t *device, unsigned char data[], unsigned int size); + dc_status_t (*version) (dc_device_t *device, unsigned char data[], unsigned int size); - dc_status_t (*read) (device_t *device, unsigned int address, unsigned char data[], unsigned int size); + dc_status_t (*read) (dc_device_t *device, unsigned int address, unsigned char data[], unsigned int size); - dc_status_t (*write) (device_t *device, unsigned int address, const unsigned char data[], unsigned int size); + dc_status_t (*write) (dc_device_t *device, unsigned int address, const unsigned char data[], unsigned int size); - dc_status_t (*dump) (device_t *device, dc_buffer_t *buffer); + dc_status_t (*dump) (dc_device_t *device, dc_buffer_t *buffer); - dc_status_t (*foreach) (device_t *device, dive_callback_t callback, void *userdata); + dc_status_t (*foreach) (dc_device_t *device, dc_dive_callback_t callback, void *userdata); - dc_status_t (*close) (device_t *device); + dc_status_t (*close) (dc_device_t *device); }; void -device_init (device_t *device, const device_backend_t *backend); +device_init (dc_device_t *device, const device_backend_t *backend); void -device_event_emit (device_t *device, device_event_t event, const void *data); +device_event_emit (dc_device_t *device, dc_event_type_t event, const void *data); int -device_is_cancelled (device_t *device); +device_is_cancelled (dc_device_t *device); dc_status_t -device_dump_read (device_t *device, unsigned char data[], unsigned int size, unsigned int blocksize); +device_dump_read (dc_device_t *device, unsigned char data[], unsigned int size, unsigned int blocksize); #ifdef __cplusplus } diff --git a/src/device.c b/src/device.c index 9660805..d0b169d 100644 --- a/src/device.c +++ b/src/device.c @@ -26,7 +26,7 @@ void -device_init (device_t *device, const device_backend_t *backend) +device_init (dc_device_t *device, const device_backend_t *backend) { device->backend = backend; @@ -40,7 +40,7 @@ device_init (device_t *device, const device_backend_t *backend) dc_family_t -device_get_type (device_t *device) +dc_device_get_type (dc_device_t *device) { if (device == NULL) return DC_FAMILY_NULL; @@ -50,7 +50,7 @@ device_get_type (device_t *device) dc_status_t -device_set_cancel (device_t *device, device_cancel_callback_t callback, void *userdata) +dc_device_set_cancel (dc_device_t *device, dc_cancel_callback_t callback, void *userdata) { if (device == NULL) return DC_STATUS_UNSUPPORTED; @@ -63,7 +63,7 @@ device_set_cancel (device_t *device, device_cancel_callback_t callback, void *us dc_status_t -device_set_events (device_t *device, unsigned int events, device_event_callback_t callback, void *userdata) +dc_device_set_events (dc_device_t *device, unsigned int events, dc_event_callback_t callback, void *userdata) { if (device == NULL) return DC_STATUS_UNSUPPORTED; @@ -77,7 +77,7 @@ device_set_events (device_t *device, unsigned int events, device_event_callback_ dc_status_t -device_set_fingerprint (device_t *device, const unsigned char data[], unsigned int size) +dc_device_set_fingerprint (dc_device_t *device, const unsigned char data[], unsigned int size) { if (device == NULL) return DC_STATUS_UNSUPPORTED; @@ -90,7 +90,7 @@ device_set_fingerprint (device_t *device, const unsigned char data[], unsigned i dc_status_t -device_version (device_t *device, unsigned char data[], unsigned int size) +dc_device_version (dc_device_t *device, unsigned char data[], unsigned int size) { if (device == NULL) return DC_STATUS_UNSUPPORTED; @@ -103,7 +103,7 @@ device_version (device_t *device, unsigned char data[], unsigned int size) dc_status_t -device_read (device_t *device, unsigned int address, unsigned char data[], unsigned int size) +dc_device_read (dc_device_t *device, unsigned int address, unsigned char data[], unsigned int size) { if (device == NULL) return DC_STATUS_UNSUPPORTED; @@ -116,7 +116,7 @@ device_read (device_t *device, unsigned int address, unsigned char data[], unsig dc_status_t -device_write (device_t *device, unsigned int address, const unsigned char data[], unsigned int size) +dc_device_write (dc_device_t *device, unsigned int address, const unsigned char data[], unsigned int size) { if (device == NULL) return DC_STATUS_UNSUPPORTED; @@ -129,7 +129,7 @@ device_write (device_t *device, unsigned int address, const unsigned char data[] dc_status_t -device_dump (device_t *device, dc_buffer_t *buffer) +dc_device_dump (dc_device_t *device, dc_buffer_t *buffer) { if (device == NULL) return DC_STATUS_UNSUPPORTED; @@ -142,7 +142,7 @@ device_dump (device_t *device, dc_buffer_t *buffer) dc_status_t -device_dump_read (device_t *device, unsigned char data[], unsigned int size, unsigned int blocksize) +device_dump_read (dc_device_t *device, unsigned char data[], unsigned int size, unsigned int blocksize) { if (device == NULL) return DC_STATUS_UNSUPPORTED; @@ -151,9 +151,9 @@ device_dump_read (device_t *device, unsigned char data[], unsigned int size, uns return DC_STATUS_UNSUPPORTED; // Enable progress notifications. - device_progress_t progress = DEVICE_PROGRESS_INITIALIZER; + dc_event_progress_t progress = EVENT_PROGRESS_INITIALIZER; progress.maximum = size; - device_event_emit (device, DEVICE_EVENT_PROGRESS, &progress); + device_event_emit (device, DC_EVENT_PROGRESS, &progress); unsigned int nbytes = 0; while (nbytes < size) { @@ -169,7 +169,7 @@ device_dump_read (device_t *device, unsigned char data[], unsigned int size, uns // Update and emit a progress event. progress.current += len; - device_event_emit (device, DEVICE_EVENT_PROGRESS, &progress); + device_event_emit (device, DC_EVENT_PROGRESS, &progress); nbytes += len; } @@ -179,7 +179,7 @@ device_dump_read (device_t *device, unsigned char data[], unsigned int size, uns dc_status_t -device_foreach (device_t *device, dive_callback_t callback, void *userdata) +dc_device_foreach (dc_device_t *device, dc_dive_callback_t callback, void *userdata) { if (device == NULL) return DC_STATUS_UNSUPPORTED; @@ -192,7 +192,7 @@ device_foreach (device_t *device, dive_callback_t callback, void *userdata) dc_status_t -device_close (device_t *device) +dc_device_close (dc_device_t *device) { if (device == NULL) return DC_STATUS_SUCCESS; @@ -205,24 +205,24 @@ device_close (device_t *device) void -device_event_emit (device_t *device, device_event_t event, const void *data) +device_event_emit (dc_device_t *device, dc_event_type_t event, const void *data) { - device_progress_t *progress = (device_progress_t *) data; + dc_event_progress_t *progress = (dc_event_progress_t *) data; // Check the event data for errors. switch (event) { - case DEVICE_EVENT_WAITING: + case DC_EVENT_WAITING: assert (data == NULL); break; - case DEVICE_EVENT_PROGRESS: + case DC_EVENT_PROGRESS: assert (progress != NULL); assert (progress->maximum != 0); assert (progress->maximum >= progress->current); break; - case DEVICE_EVENT_DEVINFO: + case DC_EVENT_DEVINFO: assert (data != NULL); break; - case DEVICE_EVENT_CLOCK: + case DC_EVENT_CLOCK: assert (data != NULL); break; default: @@ -242,7 +242,7 @@ device_event_emit (device_t *device, device_event_t event, const void *data) int -device_is_cancelled (device_t *device) +device_is_cancelled (dc_device_t *device) { if (device == NULL) return 0; diff --git a/src/hw_frog.c b/src/hw_frog.c index 41a5129..19f26d0 100644 --- a/src/hw_frog.c +++ b/src/hw_frog.c @@ -58,15 +58,15 @@ #define EXIT 0xFF typedef struct hw_frog_device_t { - device_t base; + dc_device_t base; serial_t *port; unsigned char fingerprint[5]; } hw_frog_device_t; -static dc_status_t hw_frog_device_set_fingerprint (device_t *abstract, const unsigned char data[], unsigned int size); -static dc_status_t hw_frog_device_version (device_t *abstract, unsigned char data[], unsigned int size); -static dc_status_t hw_frog_device_foreach (device_t *abstract, dive_callback_t callback, void *userdata); -static dc_status_t hw_frog_device_close (device_t *abstract); +static dc_status_t hw_frog_device_set_fingerprint (dc_device_t *abstract, const unsigned char data[], unsigned int size); +static dc_status_t hw_frog_device_version (dc_device_t *abstract, unsigned char data[], unsigned int size); +static dc_status_t hw_frog_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, void *userdata); +static dc_status_t hw_frog_device_close (dc_device_t *abstract); static const device_backend_t hw_frog_device_backend = { DC_FAMILY_HW_FROG, @@ -81,7 +81,7 @@ static const device_backend_t hw_frog_device_backend = { static int -device_is_hw_frog (device_t *abstract) +device_is_hw_frog (dc_device_t *abstract) { if (abstract == NULL) return 0; @@ -92,7 +92,7 @@ device_is_hw_frog (device_t *abstract) static dc_status_t hw_frog_transfer (hw_frog_device_t *device, - device_progress_t *progress, + dc_event_progress_t *progress, unsigned char cmd, const unsigned char input[], unsigned int isize, @@ -157,7 +157,7 @@ hw_frog_transfer (hw_frog_device_t *device, // Update and emit a progress event. if (progress) { progress->current += len; - device_event_emit ((device_t *) device, DEVICE_EVENT_PROGRESS, progress); + device_event_emit ((dc_device_t *) device, DC_EVENT_PROGRESS, progress); } nbytes += len; @@ -185,7 +185,7 @@ hw_frog_transfer (hw_frog_device_t *device, dc_status_t -hw_frog_device_open (device_t **out, const char* name) +hw_frog_device_open (dc_device_t **out, const char *name) { if (out == NULL) return DC_STATUS_INVALIDARGS; @@ -242,14 +242,14 @@ hw_frog_device_open (device_t **out, const char* name) return status; } - *out = (device_t *) device; + *out = (dc_device_t *) device; return DC_STATUS_SUCCESS; } static dc_status_t -hw_frog_device_close (device_t *abstract) +hw_frog_device_close (dc_device_t *abstract) { hw_frog_device_t *device = (hw_frog_device_t*) abstract; @@ -276,7 +276,7 @@ hw_frog_device_close (device_t *abstract) static dc_status_t -hw_frog_device_set_fingerprint (device_t *abstract, const unsigned char data[], unsigned int size) +hw_frog_device_set_fingerprint (dc_device_t *abstract, const unsigned char data[], unsigned int size) { hw_frog_device_t *device = (hw_frog_device_t *) abstract; @@ -293,7 +293,7 @@ hw_frog_device_set_fingerprint (device_t *abstract, const unsigned char data[], static dc_status_t -hw_frog_device_version (device_t *abstract, unsigned char data[], unsigned int size) +hw_frog_device_version (dc_device_t *abstract, unsigned char data[], unsigned int size) { hw_frog_device_t *device = (hw_frog_device_t *) abstract; @@ -313,15 +313,15 @@ hw_frog_device_version (device_t *abstract, unsigned char data[], unsigned int s static dc_status_t -hw_frog_device_foreach (device_t *abstract, dive_callback_t callback, void *userdata) +hw_frog_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, void *userdata) { hw_frog_device_t *device = (hw_frog_device_t *) abstract; // Enable progress notifications. - device_progress_t progress = DEVICE_PROGRESS_INITIALIZER; + dc_event_progress_t progress = EVENT_PROGRESS_INITIALIZER; progress.maximum = (RB_LOGBOOK_SIZE * RB_LOGBOOK_COUNT) + (RB_PROFILE_END - RB_PROFILE_BEGIN); - device_event_emit (abstract, DEVICE_EVENT_PROGRESS, &progress); + device_event_emit (abstract, DC_EVENT_PROGRESS, &progress); // Download the version data. unsigned char id[SZ_VERSION] = {0}; @@ -332,11 +332,11 @@ hw_frog_device_foreach (device_t *abstract, dive_callback_t callback, void *user } // Emit a device info event. - device_devinfo_t devinfo; + dc_event_devinfo_t devinfo; devinfo.model = 0; devinfo.firmware = array_uint16_be (id + 2); devinfo.serial = array_uint16_le (id + 0); - device_event_emit (abstract, DEVICE_EVENT_DEVINFO, &devinfo); + device_event_emit (abstract, DC_EVENT_DEVINFO, &devinfo); // Allocate memory. unsigned char *header = malloc (RB_LOGBOOK_SIZE * RB_LOGBOOK_COUNT); @@ -414,7 +414,7 @@ hw_frog_device_foreach (device_t *abstract, dive_callback_t callback, void *user // Update and emit a progress event. progress.maximum = (RB_LOGBOOK_SIZE * RB_LOGBOOK_COUNT) + size; - device_event_emit (abstract, DEVICE_EVENT_PROGRESS, &progress); + device_event_emit (abstract, DC_EVENT_PROGRESS, &progress); // Allocate enough memory for the largest dive. unsigned char *profile = malloc (maxsize); @@ -459,7 +459,7 @@ hw_frog_device_foreach (device_t *abstract, dive_callback_t callback, void *user dc_status_t -hw_frog_device_clock (device_t *abstract, const dc_datetime_t *datetime) +hw_frog_device_clock (dc_device_t *abstract, const dc_datetime_t *datetime) { hw_frog_device_t *device = (hw_frog_device_t *) abstract; @@ -484,7 +484,7 @@ hw_frog_device_clock (device_t *abstract, const dc_datetime_t *datetime) dc_status_t -hw_frog_device_display (device_t *abstract, const char *text) +hw_frog_device_display (dc_device_t *abstract, const char *text) { hw_frog_device_t *device = (hw_frog_device_t *) abstract; @@ -514,7 +514,7 @@ hw_frog_device_display (device_t *abstract, const char *text) dc_status_t -hw_frog_device_customtext (device_t *abstract, const char *text) +hw_frog_device_customtext (dc_device_t *abstract, const char *text) { hw_frog_device_t *device = (hw_frog_device_t *) abstract; diff --git a/src/hw_ostc.c b/src/hw_ostc.c index c8f5787..7391474 100644 --- a/src/hw_ostc.c +++ b/src/hw_ostc.c @@ -49,15 +49,15 @@ #define WHITE 0xFF typedef struct hw_ostc_device_t { - device_t base; + dc_device_t base; serial_t *port; unsigned char fingerprint[5]; } hw_ostc_device_t; -static dc_status_t hw_ostc_device_set_fingerprint (device_t *abstract, const unsigned char data[], unsigned int size); -static dc_status_t hw_ostc_device_dump (device_t *abstract, dc_buffer_t *buffer); -static dc_status_t hw_ostc_device_foreach (device_t *abstract, dive_callback_t callback, void *userdata); -static dc_status_t hw_ostc_device_close (device_t *abstract); +static dc_status_t hw_ostc_device_set_fingerprint (dc_device_t *abstract, const unsigned char data[], unsigned int size); +static dc_status_t hw_ostc_device_dump (dc_device_t *abstract, dc_buffer_t *buffer); +static dc_status_t hw_ostc_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, void *userdata); +static dc_status_t hw_ostc_device_close (dc_device_t *abstract); static const device_backend_t hw_ostc_device_backend = { DC_FAMILY_HW_OSTC, @@ -72,7 +72,7 @@ static const device_backend_t hw_ostc_device_backend = { static int -device_is_hw_ostc (device_t *abstract) +device_is_hw_ostc (dc_device_t *abstract) { if (abstract == NULL) return 0; @@ -113,7 +113,7 @@ hw_ostc_send (hw_ostc_device_t *device, unsigned char cmd, unsigned int echo) dc_status_t -hw_ostc_device_open (device_t **out, const char* name) +hw_ostc_device_open (dc_device_t **out, const char *name) { if (out == NULL) return DC_STATUS_INVALIDARGS; @@ -161,14 +161,14 @@ hw_ostc_device_open (device_t **out, const char* name) serial_sleep (100); serial_flush (device->port, SERIAL_QUEUE_BOTH); - *out = (device_t*) device; + *out = (dc_device_t*) device; return DC_STATUS_SUCCESS; } static dc_status_t -hw_ostc_device_close (device_t *abstract) +hw_ostc_device_close (dc_device_t *abstract) { hw_ostc_device_t *device = (hw_ostc_device_t*) abstract; @@ -189,7 +189,7 @@ hw_ostc_device_close (device_t *abstract) static dc_status_t -hw_ostc_device_set_fingerprint (device_t *abstract, const unsigned char data[], unsigned int size) +hw_ostc_device_set_fingerprint (dc_device_t *abstract, const unsigned char data[], unsigned int size) { hw_ostc_device_t *device = (hw_ostc_device_t *) abstract; @@ -206,7 +206,7 @@ hw_ostc_device_set_fingerprint (device_t *abstract, const unsigned char data[], static dc_status_t -hw_ostc_device_dump (device_t *abstract, dc_buffer_t *buffer) +hw_ostc_device_dump (dc_device_t *abstract, dc_buffer_t *buffer) { hw_ostc_device_t *device = (hw_ostc_device_t*) abstract; @@ -220,9 +220,9 @@ hw_ostc_device_dump (device_t *abstract, dc_buffer_t *buffer) } // Enable progress notifications. - device_progress_t progress = DEVICE_PROGRESS_INITIALIZER; + dc_event_progress_t progress = EVENT_PROGRESS_INITIALIZER; progress.maximum = SZ_HEADER + SZ_FW_NEW; - device_event_emit (abstract, DEVICE_EVENT_PROGRESS, &progress); + device_event_emit (abstract, DC_EVENT_PROGRESS, &progress); // Send the command. unsigned char command[1] = {'a'}; @@ -260,7 +260,7 @@ hw_ostc_device_dump (device_t *abstract, dc_buffer_t *buffer) // Update and emit a progress event. progress.current = sizeof (header); progress.maximum = size; - device_event_emit (abstract, DEVICE_EVENT_PROGRESS, &progress); + device_event_emit (abstract, DC_EVENT_PROGRESS, &progress); // Allocate the required amount of memory. if (!dc_buffer_resize (buffer, size)) { @@ -296,7 +296,7 @@ hw_ostc_device_dump (device_t *abstract, dc_buffer_t *buffer) // Update and emit a progress event. progress.current += len; - device_event_emit (abstract, DEVICE_EVENT_PROGRESS, &progress); + device_event_emit (abstract, DC_EVENT_PROGRESS, &progress); nbytes += len; } @@ -306,7 +306,7 @@ hw_ostc_device_dump (device_t *abstract, dc_buffer_t *buffer) static dc_status_t -hw_ostc_device_foreach (device_t *abstract, dive_callback_t callback, void *userdata) +hw_ostc_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, void *userdata) { dc_buffer_t *buffer = dc_buffer_new (0); if (buffer == NULL) @@ -320,11 +320,11 @@ hw_ostc_device_foreach (device_t *abstract, dive_callback_t callback, void *user // Emit a device info event. unsigned char *data = dc_buffer_get_data (buffer); - device_devinfo_t devinfo; + dc_event_devinfo_t devinfo; devinfo.model = 0; devinfo.firmware = array_uint16_be (data + 264); devinfo.serial = array_uint16_le (data + 6); - device_event_emit (abstract, DEVICE_EVENT_DEVINFO, &devinfo); + device_event_emit (abstract, DC_EVENT_DEVINFO, &devinfo); rc = hw_ostc_extract_dives (abstract, dc_buffer_get_data (buffer), dc_buffer_get_size (buffer), callback, userdata); @@ -336,7 +336,7 @@ hw_ostc_device_foreach (device_t *abstract, dive_callback_t callback, void *user dc_status_t -hw_ostc_device_md2hash (device_t *abstract, unsigned char data[], unsigned int size) +hw_ostc_device_md2hash (dc_device_t *abstract, unsigned char data[], unsigned int size) { hw_ostc_device_t *device = (hw_ostc_device_t *) abstract; @@ -365,7 +365,7 @@ hw_ostc_device_md2hash (device_t *abstract, unsigned char data[], unsigned int s dc_status_t -hw_ostc_device_clock (device_t *abstract, const dc_datetime_t *datetime) +hw_ostc_device_clock (dc_device_t *abstract, const dc_datetime_t *datetime) { hw_ostc_device_t *device = (hw_ostc_device_t *) abstract; @@ -397,7 +397,7 @@ hw_ostc_device_clock (device_t *abstract, const dc_datetime_t *datetime) dc_status_t -hw_ostc_device_eeprom_read (device_t *abstract, unsigned int bank, unsigned char data[], unsigned int size) +hw_ostc_device_eeprom_read (dc_device_t *abstract, unsigned int bank, unsigned char data[], unsigned int size) { hw_ostc_device_t *device = (hw_ostc_device_t *) abstract; @@ -432,7 +432,7 @@ hw_ostc_device_eeprom_read (device_t *abstract, unsigned int bank, unsigned char dc_status_t -hw_ostc_device_eeprom_write (device_t *abstract, unsigned int bank, const unsigned char data[], unsigned int size) +hw_ostc_device_eeprom_write (dc_device_t *abstract, unsigned int bank, const unsigned char data[], unsigned int size) { hw_ostc_device_t *device = (hw_ostc_device_t *) abstract; @@ -467,7 +467,7 @@ hw_ostc_device_eeprom_write (device_t *abstract, unsigned int bank, const unsign dc_status_t -hw_ostc_device_reset (device_t *abstract) +hw_ostc_device_reset (dc_device_t *abstract) { hw_ostc_device_t *device = (hw_ostc_device_t *) abstract; @@ -484,7 +484,7 @@ hw_ostc_device_reset (device_t *abstract) dc_status_t -hw_ostc_device_screenshot (device_t *abstract, dc_buffer_t *buffer, hw_ostc_format_t format) +hw_ostc_device_screenshot (dc_device_t *abstract, dc_buffer_t *buffer, hw_ostc_format_t format) { hw_ostc_device_t *device = (hw_ostc_device_t *) abstract; @@ -520,9 +520,9 @@ hw_ostc_device_screenshot (device_t *abstract, dc_buffer_t *buffer, hw_ostc_form } // Enable progress notifications. - device_progress_t progress = DEVICE_PROGRESS_INITIALIZER; + dc_event_progress_t progress = EVENT_PROGRESS_INITIALIZER; progress.maximum = WIDTH * HEIGHT; - device_event_emit (abstract, DEVICE_EVENT_PROGRESS, &progress); + device_event_emit (abstract, DC_EVENT_PROGRESS, &progress); // Send the command. dc_status_t rc = hw_ostc_send (device, 'l', 1); @@ -609,7 +609,7 @@ hw_ostc_device_screenshot (device_t *abstract, dc_buffer_t *buffer, hw_ostc_form // Update and emit a progress event. progress.current += count; - device_event_emit (abstract, DEVICE_EVENT_PROGRESS, &progress); + device_event_emit (abstract, DC_EVENT_PROGRESS, &progress); npixels += count; } @@ -619,7 +619,7 @@ hw_ostc_device_screenshot (device_t *abstract, dc_buffer_t *buffer, hw_ostc_form dc_status_t -hw_ostc_extract_dives (device_t *abstract, const unsigned char data[], unsigned int size, dive_callback_t callback, void *userdata) +hw_ostc_extract_dives (dc_device_t *abstract, const unsigned char data[], unsigned int size, dc_dive_callback_t callback, void *userdata) { hw_ostc_device_t *device = (hw_ostc_device_t *) abstract; diff --git a/src/hw_ostc_parser.c b/src/hw_ostc_parser.c index 23b9315..371b1e5 100644 --- a/src/hw_ostc_parser.c +++ b/src/hw_ostc_parser.c @@ -32,7 +32,7 @@ typedef struct hw_ostc_parser_t hw_ostc_parser_t; struct hw_ostc_parser_t { - parser_t base; + dc_parser_t base; unsigned int frog; }; @@ -41,11 +41,11 @@ typedef struct hw_ostc_sample_info_t { unsigned int size; } hw_ostc_sample_info_t; -static dc_status_t hw_ostc_parser_set_data (parser_t *abstract, const unsigned char *data, unsigned int size); -static dc_status_t hw_ostc_parser_get_datetime (parser_t *abstract, dc_datetime_t *datetime); -static dc_status_t hw_ostc_parser_get_field (parser_t *abstract, parser_field_type_t type, unsigned int flags, void *value); -static dc_status_t hw_ostc_parser_samples_foreach (parser_t *abstract, sample_callback_t callback, void *userdata); -static dc_status_t hw_ostc_parser_destroy (parser_t *abstract); +static dc_status_t hw_ostc_parser_set_data (dc_parser_t *abstract, const unsigned char *data, unsigned int size); +static dc_status_t hw_ostc_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *datetime); +static dc_status_t hw_ostc_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsigned int flags, void *value); +static dc_status_t hw_ostc_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t callback, void *userdata); +static dc_status_t hw_ostc_parser_destroy (dc_parser_t *abstract); static const parser_backend_t hw_ostc_parser_backend = { DC_FAMILY_HW_OSTC, @@ -58,7 +58,7 @@ static const parser_backend_t hw_ostc_parser_backend = { static int -parser_is_hw_ostc (parser_t *abstract) +parser_is_hw_ostc (dc_parser_t *abstract) { if (abstract == NULL) return 0; @@ -68,7 +68,7 @@ parser_is_hw_ostc (parser_t *abstract) dc_status_t -hw_ostc_parser_create (parser_t **out, unsigned int frog) +hw_ostc_parser_create (dc_parser_t **out, unsigned int frog) { if (out == NULL) return DC_STATUS_INVALIDARGS; @@ -85,14 +85,14 @@ hw_ostc_parser_create (parser_t **out, unsigned int frog) parser->frog = frog; - *out = (parser_t*) parser; + *out = (dc_parser_t *) parser; return DC_STATUS_SUCCESS; } static dc_status_t -hw_ostc_parser_destroy (parser_t *abstract) +hw_ostc_parser_destroy (dc_parser_t *abstract) { if (! parser_is_hw_ostc (abstract)) return DC_STATUS_INVALIDARGS; @@ -105,7 +105,7 @@ hw_ostc_parser_destroy (parser_t *abstract) static dc_status_t -hw_ostc_parser_set_data (parser_t *abstract, const unsigned char *data, unsigned int size) +hw_ostc_parser_set_data (dc_parser_t *abstract, const unsigned char *data, unsigned int size) { if (! parser_is_hw_ostc (abstract)) return DC_STATUS_INVALIDARGS; @@ -115,7 +115,7 @@ hw_ostc_parser_set_data (parser_t *abstract, const unsigned char *data, unsigned static dc_status_t -hw_ostc_parser_get_datetime (parser_t *abstract, dc_datetime_t *datetime) +hw_ostc_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *datetime) { hw_ostc_parser_t *parser = (hw_ostc_parser_t *) abstract; const unsigned char *data = abstract->data; @@ -178,7 +178,7 @@ hw_ostc_parser_get_datetime (parser_t *abstract, dc_datetime_t *datetime) } static dc_status_t -hw_ostc_parser_get_field (parser_t *abstract, parser_field_type_t type, unsigned int flags, void *value) +hw_ostc_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsigned int flags, void *value) { hw_ostc_parser_t *parser = (hw_ostc_parser_t *) abstract; const unsigned char *data = abstract->data; @@ -210,23 +210,23 @@ hw_ostc_parser_get_field (parser_t *abstract, parser_field_type_t type, unsigned if (parser->frog) data += 6; - gasmix_t *gasmix = (gasmix_t *) value; + dc_gasmix_t *gasmix = (dc_gasmix_t *) value; if (value) { switch (type) { - case FIELD_TYPE_DIVETIME: + case DC_FIELD_DIVETIME: *((unsigned int *) value) = array_uint16_le (data + 10) * 60 + data[12]; break; - case FIELD_TYPE_MAXDEPTH: + case DC_FIELD_MAXDEPTH: *((double *) value) = array_uint16_le (data + 8) / 100.0; break; - case FIELD_TYPE_GASMIX_COUNT: + case DC_FIELD_GASMIX_COUNT: if (parser->frog) *((unsigned int *) value) = 3; else *((unsigned int *) value) = 6; break; - case FIELD_TYPE_GASMIX: + case DC_FIELD_GASMIX: gasmix->oxygen = data[19 + 2 * flags] / 100.0; if (parser->frog) gasmix->helium = 0.0; @@ -244,7 +244,7 @@ hw_ostc_parser_get_field (parser_t *abstract, parser_field_type_t type, unsigned static dc_status_t -hw_ostc_parser_samples_foreach (parser_t *abstract, sample_callback_t callback, void *userdata) +hw_ostc_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t callback, void *userdata) { hw_ostc_parser_t *parser = (hw_ostc_parser_t *) abstract; const unsigned char *data = abstract->data; @@ -296,19 +296,19 @@ hw_ostc_parser_samples_foreach (parser_t *abstract, sample_callback_t callback, unsigned int offset = header; while (offset + 3 <= size) { - parser_sample_value_t sample = {0}; + dc_sample_value_t sample = {0}; nsamples++; // Time (seconds). time += samplerate; sample.time = time; - if (callback) callback (SAMPLE_TYPE_TIME, sample, userdata); + if (callback) callback (DC_SAMPLE_TIME, sample, userdata); // Depth (mbar). unsigned int depth = array_uint16_le (data + offset); sample.depth = depth / 100.0; - if (callback) callback (SAMPLE_TYPE_DEPTH, sample, userdata); + if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); offset += 2; // Extended sample info. @@ -356,7 +356,7 @@ hw_ostc_parser_samples_foreach (parser_t *abstract, sample_callback_t callback, case 0: // Temperature (0.1 °C). value = array_uint16_le (data + offset); sample.temperature = value / 10.0; - if (callback) callback (SAMPLE_TYPE_TEMPERATURE, sample, userdata); + if (callback) callback (DC_SAMPLE_TEMPERATURE, sample, userdata); break; default: // Not yet used. break; diff --git a/src/libdivecomputer.symbols b/src/libdivecomputer.symbols index 81db2e5..ffe063a 100644 --- a/src/libdivecomputer.symbols +++ b/src/libdivecomputer.symbols @@ -17,12 +17,12 @@ dc_datetime_localtime dc_datetime_gmtime dc_datetime_mktime -parser_get_type -parser_set_data -parser_get_datetime -parser_get_field -parser_samples_foreach -parser_destroy +dc_parser_get_type +dc_parser_set_data +dc_parser_get_datetime +dc_parser_get_field +dc_parser_samples_foreach +dc_parser_destroy reefnet_sensus_parser_create reefnet_sensus_parser_set_calibration @@ -47,16 +47,16 @@ cressi_edy_parser_create atomics_cobalt_parser_create atomics_cobalt_parser_set_calibration -device_close -device_dump -device_foreach -device_get_type -device_read -device_set_cancel -device_set_events -device_set_fingerprint -device_version -device_write +dc_device_close +dc_device_dump +dc_device_foreach +dc_device_get_type +dc_device_read +dc_device_set_cancel +dc_device_set_events +dc_device_set_fingerprint +dc_device_version +dc_device_write message message_set_logfile diff --git a/src/mares_common.c b/src/mares_common.c index 1ed7c86..1b74809 100644 --- a/src/mares_common.c +++ b/src/mares_common.c @@ -125,7 +125,7 @@ mares_common_make_ascii (const unsigned char raw[], unsigned int rsize, unsigned static dc_status_t mares_common_packet (mares_common_device_t *device, const unsigned char command[], unsigned int csize, unsigned char answer[], unsigned int asize) { - device_t *abstract = (device_t *) device; + dc_device_t *abstract = (dc_device_t *) device; if (device_is_cancelled (abstract)) return DC_STATUS_CANCELLED; @@ -206,7 +206,7 @@ mares_common_transfer (mares_common_device_t *device, const unsigned char comman dc_status_t -mares_common_device_read (device_t *abstract, unsigned int address, unsigned char data[], unsigned int size) +mares_common_device_read (dc_device_t *abstract, unsigned int address, unsigned char data[], unsigned int size) { mares_common_device_t *device = (mares_common_device_t*) abstract; @@ -249,7 +249,7 @@ mares_common_device_read (device_t *abstract, unsigned int address, unsigned cha dc_status_t -mares_common_extract_dives (const mares_common_layout_t *layout, const unsigned char fingerprint[], const unsigned char data[], dive_callback_t callback, void *userdata) +mares_common_extract_dives (const mares_common_layout_t *layout, const unsigned char fingerprint[], const unsigned char data[], dc_dive_callback_t callback, void *userdata) { assert (layout != NULL); diff --git a/src/mares_common.h b/src/mares_common.h index ee2364c..2104465 100644 --- a/src/mares_common.h +++ b/src/mares_common.h @@ -40,7 +40,7 @@ typedef struct mares_common_layout_t { } mares_common_layout_t; typedef struct mares_common_device_t { - device_t base; + dc_device_t base; serial_t *port; unsigned int echo; unsigned int delay; @@ -50,10 +50,10 @@ void mares_common_device_init (mares_common_device_t *device, const device_backend_t *backend); dc_status_t -mares_common_device_read (device_t *abstract, unsigned int address, unsigned char data[], unsigned int size); +mares_common_device_read (dc_device_t *abstract, unsigned int address, unsigned char data[], unsigned int size); dc_status_t -mares_common_extract_dives (const mares_common_layout_t *layout, const unsigned char fingerprint[], const unsigned char data[], dive_callback_t callback, void *userdata); +mares_common_extract_dives (const mares_common_layout_t *layout, const unsigned char fingerprint[], const unsigned char data[], dc_dive_callback_t callback, void *userdata); #ifdef __cplusplus } diff --git a/src/mares_darwin.c b/src/mares_darwin.c index 2ceac38..45c5784 100644 --- a/src/mares_darwin.c +++ b/src/mares_darwin.c @@ -55,10 +55,10 @@ typedef struct mares_darwin_device_t { unsigned char fingerprint[6]; } mares_darwin_device_t; -static dc_status_t mares_darwin_device_set_fingerprint (device_t *abstract, const unsigned char data[], unsigned int size); -static dc_status_t mares_darwin_device_dump (device_t *abstract, dc_buffer_t *buffer); -static dc_status_t mares_darwin_device_foreach (device_t *abstract, dive_callback_t callback, void *userdata); -static dc_status_t mares_darwin_device_close (device_t *abstract); +static dc_status_t mares_darwin_device_set_fingerprint (dc_device_t *abstract, const unsigned char data[], unsigned int size); +static dc_status_t mares_darwin_device_dump (dc_device_t *abstract, dc_buffer_t *buffer); +static dc_status_t mares_darwin_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, void *userdata); +static dc_status_t mares_darwin_device_close (dc_device_t *abstract); static const device_backend_t mares_darwin_device_backend = { DC_FAMILY_MARES_DARWIN, @@ -92,7 +92,7 @@ static const mares_darwin_layout_t mares_darwinair_layout = { }; static int -device_is_mares_darwin (device_t *abstract) +device_is_mares_darwin (dc_device_t *abstract) { if (abstract == NULL) return 0; @@ -101,7 +101,7 @@ device_is_mares_darwin (device_t *abstract) } dc_status_t -mares_darwin_device_open (device_t **out, const char* name, unsigned int model) +mares_darwin_device_open (dc_device_t **out, const char *name, unsigned int model) { if (out == NULL) return DC_STATUS_INVALIDARGS; @@ -166,13 +166,13 @@ mares_darwin_device_open (device_t **out, const char* name, unsigned int model) device->base.echo = 1; device->base.delay = 50; - *out = (device_t *) device; + *out = (dc_device_t *) device; return DC_STATUS_SUCCESS; } static dc_status_t -mares_darwin_device_close (device_t *abstract) +mares_darwin_device_close (dc_device_t *abstract) { mares_darwin_device_t *device = (mares_darwin_device_t *) abstract; @@ -190,7 +190,7 @@ mares_darwin_device_close (device_t *abstract) static dc_status_t -mares_darwin_device_set_fingerprint (device_t *abstract, const unsigned char data[], unsigned int size) +mares_darwin_device_set_fingerprint (dc_device_t *abstract, const unsigned char data[], unsigned int size) { mares_darwin_device_t *device = (mares_darwin_device_t *) abstract; @@ -207,7 +207,7 @@ mares_darwin_device_set_fingerprint (device_t *abstract, const unsigned char dat static dc_status_t -mares_darwin_device_dump (device_t *abstract, dc_buffer_t *buffer) +mares_darwin_device_dump (dc_device_t *abstract, dc_buffer_t *buffer) { mares_darwin_device_t *device = (mares_darwin_device_t *) abstract; @@ -226,7 +226,7 @@ mares_darwin_device_dump (device_t *abstract, dc_buffer_t *buffer) static dc_status_t -mares_darwin_device_foreach (device_t *abstract, dive_callback_t callback, void *userdata) +mares_darwin_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, void *userdata) { mares_darwin_device_t *device = (mares_darwin_device_t *) abstract; @@ -244,11 +244,11 @@ mares_darwin_device_foreach (device_t *abstract, dive_callback_t callback, void // Emit a device info event. unsigned char *data = dc_buffer_get_data (buffer); - device_devinfo_t devinfo; + dc_event_devinfo_t devinfo; devinfo.model = device->model; devinfo.firmware = 0; devinfo.serial = array_uint16_be (data + 8); - device_event_emit (abstract, DEVICE_EVENT_DEVINFO, &devinfo); + device_event_emit (abstract, DC_EVENT_DEVINFO, &devinfo); rc = mares_darwin_extract_dives (abstract, dc_buffer_get_data (buffer), dc_buffer_get_size (buffer), callback, userdata); @@ -260,7 +260,7 @@ mares_darwin_device_foreach (device_t *abstract, dive_callback_t callback, void dc_status_t -mares_darwin_extract_dives (device_t *abstract, const unsigned char data[], unsigned int size, dive_callback_t callback, void *userdata) +mares_darwin_extract_dives (dc_device_t *abstract, const unsigned char data[], unsigned int size, dc_dive_callback_t callback, void *userdata) { mares_darwin_device_t *device = (mares_darwin_device_t *) abstract; diff --git a/src/mares_darwin_parser.c b/src/mares_darwin_parser.c index 903ef35..f5dea92 100644 --- a/src/mares_darwin_parser.c +++ b/src/mares_darwin_parser.c @@ -35,16 +35,16 @@ typedef struct mares_darwin_parser_t mares_darwin_parser_t; struct mares_darwin_parser_t { - parser_t base; + dc_parser_t base; unsigned int headersize; unsigned int samplesize; }; -static dc_status_t mares_darwin_parser_set_data (parser_t *abstract, const unsigned char *data, unsigned int size); -static dc_status_t mares_darwin_parser_get_datetime (parser_t *abstract, dc_datetime_t *datetime); -static dc_status_t mares_darwin_parser_get_field (parser_t *abstract, parser_field_type_t type, unsigned int flags, void *value); -static dc_status_t mares_darwin_parser_samples_foreach (parser_t *abstract, sample_callback_t callback, void *userdata); -static dc_status_t mares_darwin_parser_destroy (parser_t *abstract); +static dc_status_t mares_darwin_parser_set_data (dc_parser_t *abstract, const unsigned char *data, unsigned int size); +static dc_status_t mares_darwin_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *datetime); +static dc_status_t mares_darwin_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsigned int flags, void *value); +static dc_status_t mares_darwin_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t callback, void *userdata); +static dc_status_t mares_darwin_parser_destroy (dc_parser_t *abstract); static const parser_backend_t mares_darwin_parser_backend = { DC_FAMILY_MARES_DARWIN, @@ -57,7 +57,7 @@ static const parser_backend_t mares_darwin_parser_backend = { static int -parser_is_mares_darwin (parser_t *abstract) +parser_is_mares_darwin (dc_parser_t *abstract) { if (abstract == NULL) return 0; @@ -67,7 +67,7 @@ parser_is_mares_darwin (parser_t *abstract) dc_status_t -mares_darwin_parser_create (parser_t **out, unsigned int model) +mares_darwin_parser_create (dc_parser_t **out, unsigned int model) { if (out == NULL) return DC_STATUS_INVALIDARGS; @@ -90,14 +90,14 @@ mares_darwin_parser_create (parser_t **out, unsigned int model) parser->samplesize = 2; } - *out = (parser_t *) parser; + *out = (dc_parser_t *) parser; return DC_STATUS_SUCCESS; } static dc_status_t -mares_darwin_parser_destroy (parser_t *abstract) +mares_darwin_parser_destroy (dc_parser_t *abstract) { if (! parser_is_mares_darwin (abstract)) return DC_STATUS_INVALIDARGS; @@ -110,14 +110,14 @@ mares_darwin_parser_destroy (parser_t *abstract) static dc_status_t -mares_darwin_parser_set_data (parser_t *abstract, const unsigned char *data, unsigned int size) +mares_darwin_parser_set_data (dc_parser_t *abstract, const unsigned char *data, unsigned int size) { return DC_STATUS_SUCCESS; } static dc_status_t -mares_darwin_parser_get_datetime (parser_t *abstract, dc_datetime_t *datetime) +mares_darwin_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *datetime) { mares_darwin_parser_t *parser = (mares_darwin_parser_t *) abstract; @@ -140,7 +140,7 @@ mares_darwin_parser_get_datetime (parser_t *abstract, dc_datetime_t *datetime) static dc_status_t -mares_darwin_parser_get_field (parser_t *abstract, parser_field_type_t type, unsigned int flags, void *value) +mares_darwin_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsigned int flags, void *value) { mares_darwin_parser_t *parser = (mares_darwin_parser_t *) abstract; @@ -149,20 +149,20 @@ mares_darwin_parser_get_field (parser_t *abstract, parser_field_type_t type, uns const unsigned char *p = abstract->data; - gasmix_t *gasmix = (gasmix_t *) value; + dc_gasmix_t *gasmix = (dc_gasmix_t *) value; if (value) { switch (type) { - case FIELD_TYPE_DIVETIME: + case DC_FIELD_DIVETIME: *((unsigned int *) value) = array_uint16_be (p + 0x06) * 20; break; - case FIELD_TYPE_MAXDEPTH: + case DC_FIELD_MAXDEPTH: *((double *) value) = array_uint16_be (p + 0x08) / 10.0; break; - case FIELD_TYPE_GASMIX_COUNT: + case DC_FIELD_GASMIX_COUNT: *((unsigned int *) value) = 1; break; - case FIELD_TYPE_GASMIX: + case DC_FIELD_GASMIX: gasmix->helium = 0.0; gasmix->oxygen = 0.21; gasmix->nitrogen = 1.0 - gasmix->oxygen - gasmix->helium; @@ -177,7 +177,7 @@ mares_darwin_parser_get_field (parser_t *abstract, parser_field_type_t type, uns static dc_status_t -mares_darwin_parser_samples_foreach (parser_t *abstract, sample_callback_t callback, void *userdata) +mares_darwin_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t callback, void *userdata) { mares_darwin_parser_t *parser = (mares_darwin_parser_t *) abstract; @@ -190,7 +190,7 @@ mares_darwin_parser_samples_foreach (parser_t *abstract, sample_callback_t callb unsigned int offset = parser->headersize; while (offset + parser->samplesize <= abstract->size) { - parser_sample_value_t sample = {0}; + dc_sample_value_t sample = {0}; unsigned int value = array_uint16_le (abstract->data + offset); unsigned int depth = value & 0x07FF; @@ -201,11 +201,11 @@ mares_darwin_parser_samples_foreach (parser_t *abstract, sample_callback_t callb // Surface Time (seconds). time += 20; sample.time = time; - if (callback) callback (SAMPLE_TYPE_TIME, sample, userdata); + if (callback) callback (DC_SAMPLE_TIME, sample, userdata); // Depth (1/10 m). sample.depth = depth / 10.0; - if (callback) callback (SAMPLE_TYPE_DEPTH, sample, userdata); + if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); // Ascent rate if (ascent) { @@ -213,7 +213,7 @@ mares_darwin_parser_samples_foreach (parser_t *abstract, sample_callback_t callb sample.event.time = 0; sample.event.flags = 0; sample.event.value = ascent; - if (callback) callback (SAMPLE_TYPE_EVENT, sample, userdata); + if (callback) callback (DC_SAMPLE_EVENT, sample, userdata); } // Deco violation @@ -222,7 +222,7 @@ mares_darwin_parser_samples_foreach (parser_t *abstract, sample_callback_t callb sample.event.time = 0; sample.event.flags = 0; sample.event.value = 0; - if (callback) callback (SAMPLE_TYPE_EVENT, sample, userdata); + if (callback) callback (DC_SAMPLE_EVENT, sample, userdata); } // Deco stop @@ -231,7 +231,7 @@ mares_darwin_parser_samples_foreach (parser_t *abstract, sample_callback_t callb sample.event.time = 0; sample.event.flags = 0; sample.event.value = 0; - if (callback) callback (SAMPLE_TYPE_EVENT, sample, userdata); + if (callback) callback (DC_SAMPLE_EVENT, sample, userdata); } if (parser->samplesize == 3) { @@ -241,7 +241,7 @@ mares_darwin_parser_samples_foreach (parser_t *abstract, sample_callback_t callb pressure -= abstract->data[offset + 2]; sample.pressure.tank = 0; sample.pressure.value = pressure; - if (callback) callback (SAMPLE_TYPE_PRESSURE, sample, userdata); + if (callback) callback (DC_SAMPLE_PRESSURE, sample, userdata); } } diff --git a/src/mares_iconhd.c b/src/mares_iconhd.c index 349ee00..64b260b 100644 --- a/src/mares_iconhd.c +++ b/src/mares_iconhd.c @@ -50,17 +50,17 @@ #define RB_PROFILE_END MARES_ICONHD_MEMORY_SIZE typedef struct mares_iconhd_device_t { - device_t base; + dc_device_t base; serial_t *port; unsigned char fingerprint[10]; unsigned char version[140]; } mares_iconhd_device_t; -static dc_status_t mares_iconhd_device_set_fingerprint (device_t *abstract, const unsigned char data[], unsigned int size); -static dc_status_t mares_iconhd_device_read (device_t *abstract, unsigned int address, unsigned char data[], unsigned int size); -static dc_status_t mares_iconhd_device_dump (device_t *abstract, dc_buffer_t *buffer); -static dc_status_t mares_iconhd_device_foreach (device_t *abstract, dive_callback_t callback, void *userdata); -static dc_status_t mares_iconhd_device_close (device_t *abstract); +static dc_status_t mares_iconhd_device_set_fingerprint (dc_device_t *abstract, const unsigned char data[], unsigned int size); +static dc_status_t mares_iconhd_device_read (dc_device_t *abstract, unsigned int address, unsigned char data[], unsigned int size); +static dc_status_t mares_iconhd_device_dump (dc_device_t *abstract, dc_buffer_t *buffer); +static dc_status_t mares_iconhd_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, void *userdata); +static dc_status_t mares_iconhd_device_close (dc_device_t *abstract); static const device_backend_t mares_iconhd_device_backend = { DC_FAMILY_MARES_ICONHD, @@ -74,7 +74,7 @@ static const device_backend_t mares_iconhd_device_backend = { }; static int -device_is_mares_iconhd (device_t *abstract) +device_is_mares_iconhd (dc_device_t *abstract) { if (abstract == NULL) return 0; @@ -103,13 +103,13 @@ mares_iconhd_transfer (mares_iconhd_device_t *device, unsigned char answer[], unsigned int asize, unsigned int events) { - device_t *abstract = (device_t *) device; + dc_device_t *abstract = (dc_device_t *) device; // Enable progress notifications. - device_progress_t progress = DEVICE_PROGRESS_INITIALIZER; + dc_event_progress_t progress = EVENT_PROGRESS_INITIALIZER; if (events) { progress.maximum = asize; - device_event_emit (abstract, DEVICE_EVENT_PROGRESS, &progress); + device_event_emit (abstract, DC_EVENT_PROGRESS, &progress); } // Send the command to the dive computer. @@ -157,7 +157,7 @@ mares_iconhd_transfer (mares_iconhd_device_t *device, // Update and emit a progress event. if (events) { progress.current += len; - device_event_emit (abstract, DEVICE_EVENT_PROGRESS, &progress); + device_event_emit (abstract, DC_EVENT_PROGRESS, &progress); } nbytes += len; @@ -206,7 +206,7 @@ mares_iconhd_read (mares_iconhd_device_t *device, unsigned int address, unsigned dc_status_t -mares_iconhd_device_open (device_t **out, const char* name) +mares_iconhd_device_open (dc_device_t **out, const char *name) { if (out == NULL) return DC_STATUS_INVALIDARGS; @@ -272,14 +272,14 @@ mares_iconhd_device_open (device_t **out, const char* name) return status; } - *out = (device_t *) device; + *out = (dc_device_t *) device; return DC_STATUS_SUCCESS; } static dc_status_t -mares_iconhd_device_close (device_t *abstract) +mares_iconhd_device_close (dc_device_t *abstract) { mares_iconhd_device_t *device = (mares_iconhd_device_t*) abstract; @@ -300,7 +300,7 @@ mares_iconhd_device_close (device_t *abstract) static dc_status_t -mares_iconhd_device_set_fingerprint (device_t *abstract, const unsigned char data[], unsigned int size) +mares_iconhd_device_set_fingerprint (dc_device_t *abstract, const unsigned char data[], unsigned int size) { mares_iconhd_device_t *device = (mares_iconhd_device_t *) abstract; @@ -317,7 +317,7 @@ mares_iconhd_device_set_fingerprint (device_t *abstract, const unsigned char dat static dc_status_t -mares_iconhd_device_read (device_t *abstract, unsigned int address, unsigned char data[], unsigned int size) +mares_iconhd_device_read (dc_device_t *abstract, unsigned int address, unsigned char data[], unsigned int size) { mares_iconhd_device_t *device = (mares_iconhd_device_t *) abstract; @@ -326,7 +326,7 @@ mares_iconhd_device_read (device_t *abstract, unsigned int address, unsigned cha static dc_status_t -mares_iconhd_device_dump (device_t *abstract, dc_buffer_t *buffer) +mares_iconhd_device_dump (dc_device_t *abstract, dc_buffer_t *buffer) { mares_iconhd_device_t *device = (mares_iconhd_device_t *) abstract; @@ -343,7 +343,7 @@ mares_iconhd_device_dump (device_t *abstract, dc_buffer_t *buffer) static dc_status_t -mares_iconhd_device_foreach (device_t *abstract, dive_callback_t callback, void *userdata) +mares_iconhd_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, void *userdata) { mares_iconhd_device_t *device = (mares_iconhd_device_t *) abstract; @@ -359,11 +359,11 @@ mares_iconhd_device_foreach (device_t *abstract, dive_callback_t callback, void // Emit a device info event. unsigned char *data = dc_buffer_get_data (buffer); - device_devinfo_t devinfo; + dc_event_devinfo_t devinfo; devinfo.model = mares_iconhd_get_model (device, data[0]); devinfo.firmware = 0; devinfo.serial = array_uint16_le (data + 12); - device_event_emit (abstract, DEVICE_EVENT_DEVINFO, &devinfo); + device_event_emit (abstract, DC_EVENT_DEVINFO, &devinfo); rc = mares_iconhd_extract_dives (abstract, dc_buffer_get_data (buffer), dc_buffer_get_size (buffer), callback, userdata); @@ -375,7 +375,7 @@ mares_iconhd_device_foreach (device_t *abstract, dive_callback_t callback, void dc_status_t -mares_iconhd_extract_dives (device_t *abstract, const unsigned char data[], unsigned int size, dive_callback_t callback, void *userdata) +mares_iconhd_extract_dives (dc_device_t *abstract, const unsigned char data[], unsigned int size, dc_dive_callback_t callback, void *userdata) { mares_iconhd_device_t *device = (mares_iconhd_device_t *) abstract; diff --git a/src/mares_iconhd_parser.c b/src/mares_iconhd_parser.c index 23017e2..0ff0de5 100644 --- a/src/mares_iconhd_parser.c +++ b/src/mares_iconhd_parser.c @@ -33,15 +33,15 @@ typedef struct mares_iconhd_parser_t mares_iconhd_parser_t; struct mares_iconhd_parser_t { - parser_t base; + dc_parser_t base; unsigned int model; }; -static dc_status_t mares_iconhd_parser_set_data (parser_t *abstract, const unsigned char *data, unsigned int size); -static dc_status_t mares_iconhd_parser_get_datetime (parser_t *abstract, dc_datetime_t *datetime); -static dc_status_t mares_iconhd_parser_get_field (parser_t *abstract, parser_field_type_t type, unsigned int flags, void *value); -static dc_status_t mares_iconhd_parser_samples_foreach (parser_t *abstract, sample_callback_t callback, void *userdata); -static dc_status_t mares_iconhd_parser_destroy (parser_t *abstract); +static dc_status_t mares_iconhd_parser_set_data (dc_parser_t *abstract, const unsigned char *data, unsigned int size); +static dc_status_t mares_iconhd_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *datetime); +static dc_status_t mares_iconhd_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsigned int flags, void *value); +static dc_status_t mares_iconhd_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t callback, void *userdata); +static dc_status_t mares_iconhd_parser_destroy (dc_parser_t *abstract); static const parser_backend_t mares_iconhd_parser_backend = { DC_FAMILY_MARES_ICONHD, @@ -54,7 +54,7 @@ static const parser_backend_t mares_iconhd_parser_backend = { static int -parser_is_mares_iconhd (parser_t *abstract) +parser_is_mares_iconhd (dc_parser_t *abstract) { if (abstract == NULL) return 0; @@ -64,7 +64,7 @@ parser_is_mares_iconhd (parser_t *abstract) dc_status_t -mares_iconhd_parser_create (parser_t **out, unsigned int model) +mares_iconhd_parser_create (dc_parser_t **out, unsigned int model) { if (out == NULL) return DC_STATUS_INVALIDARGS; @@ -82,14 +82,14 @@ mares_iconhd_parser_create (parser_t **out, unsigned int model) // Set the default values. parser->model = model; - *out = (parser_t*) parser; + *out = (dc_parser_t*) parser; return DC_STATUS_SUCCESS; } static dc_status_t -mares_iconhd_parser_destroy (parser_t *abstract) +mares_iconhd_parser_destroy (dc_parser_t *abstract) { if (! parser_is_mares_iconhd (abstract)) return DC_STATUS_INVALIDARGS; @@ -102,14 +102,14 @@ mares_iconhd_parser_destroy (parser_t *abstract) static dc_status_t -mares_iconhd_parser_set_data (parser_t *abstract, const unsigned char *data, unsigned int size) +mares_iconhd_parser_set_data (dc_parser_t *abstract, const unsigned char *data, unsigned int size) { return DC_STATUS_SUCCESS; } static dc_status_t -mares_iconhd_parser_get_datetime (parser_t *abstract, dc_datetime_t *datetime) +mares_iconhd_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *datetime) { mares_iconhd_parser_t *parser = (mares_iconhd_parser_t *) abstract; @@ -142,7 +142,7 @@ mares_iconhd_parser_get_datetime (parser_t *abstract, dc_datetime_t *datetime) static dc_status_t -mares_iconhd_parser_get_field (parser_t *abstract, parser_field_type_t type, unsigned int flags, void *value) +mares_iconhd_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsigned int flags, void *value) { mares_iconhd_parser_t *parser = (mares_iconhd_parser_t *) abstract; @@ -161,20 +161,20 @@ mares_iconhd_parser_get_field (parser_t *abstract, parser_field_type_t type, uns const unsigned char *p = abstract->data + length - header; - gasmix_t *gasmix = (gasmix_t *) value; + dc_gasmix_t *gasmix = (dc_gasmix_t *) value; if (value) { switch (type) { - case FIELD_TYPE_DIVETIME: + case DC_FIELD_DIVETIME: *((unsigned int *) value) = array_uint16_le (p + 0x02) * 5; break; - case FIELD_TYPE_MAXDEPTH: + case DC_FIELD_MAXDEPTH: *((double *) value) = array_uint16_le (p + 0x04) / 10.0; break; - case FIELD_TYPE_GASMIX_COUNT: + case DC_FIELD_GASMIX_COUNT: *((unsigned int *) value) = 3; break; - case FIELD_TYPE_GASMIX: + case DC_FIELD_GASMIX: gasmix->helium = 0.0; gasmix->oxygen = p[0x14 + flags * 4] / 100.0; gasmix->nitrogen = 1.0 - gasmix->oxygen - gasmix->helium; @@ -189,7 +189,7 @@ mares_iconhd_parser_get_field (parser_t *abstract, parser_field_type_t type, uns static dc_status_t -mares_iconhd_parser_samples_foreach (parser_t *abstract, sample_callback_t callback, void *userdata) +mares_iconhd_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t callback, void *userdata) { mares_iconhd_parser_t *parser = (mares_iconhd_parser_t *) abstract; @@ -217,22 +217,22 @@ mares_iconhd_parser_samples_foreach (parser_t *abstract, sample_callback_t callb unsigned int offset = 4; unsigned int nsamples = 0; while (offset + samplesize <= size) { - parser_sample_value_t sample = {0}; + dc_sample_value_t sample = {0}; // Time (seconds). time += interval; sample.time = time; - if (callback) callback (SAMPLE_TYPE_TIME, sample, userdata); + if (callback) callback (DC_SAMPLE_TIME, sample, userdata); // Depth (1/10 m). unsigned int depth = array_uint16_le (data + offset + 0); sample.depth = depth / 10.0; - if (callback) callback (SAMPLE_TYPE_DEPTH, sample, userdata); + if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); // Temperature (1/10 °C). unsigned int temperature = array_uint16_le (data + offset + 2); sample.temperature = temperature / 10.0; - if (callback) callback (SAMPLE_TYPE_TEMPERATURE, sample, userdata); + if (callback) callback (DC_SAMPLE_TEMPERATURE, sample, userdata); offset += samplesize; nsamples++; @@ -246,7 +246,7 @@ mares_iconhd_parser_samples_foreach (parser_t *abstract, sample_callback_t callb unsigned int pressure = array_uint16_le(data + offset); sample.pressure.tank = 0; sample.pressure.value = pressure / 100.0; - if (callback) callback (SAMPLE_TYPE_PRESSURE, sample, userdata); + if (callback) callback (DC_SAMPLE_PRESSURE, sample, userdata); offset += 8; } diff --git a/src/mares_nemo.c b/src/mares_nemo.c index 574d151..83b4b6d 100644 --- a/src/mares_nemo.c +++ b/src/mares_nemo.c @@ -48,15 +48,15 @@ #define NEMOAPNEIST 18 typedef struct mares_nemo_device_t { - device_t base; + dc_device_t base; serial_t *port; unsigned char fingerprint[5]; } mares_nemo_device_t; -static dc_status_t mares_nemo_device_set_fingerprint (device_t *abstract, const unsigned char data[], unsigned int size); -static dc_status_t mares_nemo_device_dump (device_t *abstract, dc_buffer_t *buffer); -static dc_status_t mares_nemo_device_foreach (device_t *abstract, dive_callback_t callback, void *userdata); -static dc_status_t mares_nemo_device_close (device_t *abstract); +static dc_status_t mares_nemo_device_set_fingerprint (dc_device_t *abstract, const unsigned char data[], unsigned int size); +static dc_status_t mares_nemo_device_dump (dc_device_t *abstract, dc_buffer_t *buffer); +static dc_status_t mares_nemo_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, void *userdata); +static dc_status_t mares_nemo_device_close (dc_device_t *abstract); static const device_backend_t mares_nemo_device_backend = { DC_FAMILY_MARES_NEMO, @@ -86,7 +86,7 @@ static const mares_common_layout_t mares_nemo_apneist_layout = { }; static int -device_is_mares_nemo (device_t *abstract) +device_is_mares_nemo (dc_device_t *abstract) { if (abstract == NULL) return 0; @@ -96,7 +96,7 @@ device_is_mares_nemo (device_t *abstract) dc_status_t -mares_nemo_device_open (device_t **out, const char* name) +mares_nemo_device_open (dc_device_t **out, const char *name) { if (out == NULL) return DC_STATUS_INVALIDARGS; @@ -152,14 +152,14 @@ mares_nemo_device_open (device_t **out, const char* name) // Make sure everything is in a sane state. serial_flush (device->port, SERIAL_QUEUE_BOTH); - *out = (device_t*) device; + *out = (dc_device_t*) device; return DC_STATUS_SUCCESS; } static dc_status_t -mares_nemo_device_close (device_t *abstract) +mares_nemo_device_close (dc_device_t *abstract) { mares_nemo_device_t *device = (mares_nemo_device_t*) abstract; @@ -180,7 +180,7 @@ mares_nemo_device_close (device_t *abstract) static dc_status_t -mares_nemo_device_set_fingerprint (device_t *abstract, const unsigned char data[], unsigned int size) +mares_nemo_device_set_fingerprint (dc_device_t *abstract, const unsigned char data[], unsigned int size) { mares_nemo_device_t *device = (mares_nemo_device_t *) abstract; @@ -197,7 +197,7 @@ mares_nemo_device_set_fingerprint (device_t *abstract, const unsigned char data[ static dc_status_t -mares_nemo_device_dump (device_t *abstract, dc_buffer_t *buffer) +mares_nemo_device_dump (dc_device_t *abstract, dc_buffer_t *buffer) { mares_nemo_device_t *device = (mares_nemo_device_t *) abstract; @@ -209,16 +209,16 @@ mares_nemo_device_dump (device_t *abstract, dc_buffer_t *buffer) } // Enable progress notifications. - device_progress_t progress = DEVICE_PROGRESS_INITIALIZER; + dc_event_progress_t progress = EVENT_PROGRESS_INITIALIZER; progress.maximum = MEMORYSIZE + 20; - device_event_emit (abstract, DEVICE_EVENT_PROGRESS, &progress); + device_event_emit (abstract, DC_EVENT_PROGRESS, &progress); // Wait until some data arrives. while (serial_get_received (device->port) == 0) { if (device_is_cancelled (abstract)) return DC_STATUS_CANCELLED; - device_event_emit (abstract, DEVICE_EVENT_WAITING, NULL); + device_event_emit (abstract, DC_EVENT_WAITING, NULL); serial_sleep (100); } @@ -239,7 +239,7 @@ mares_nemo_device_dump (device_t *abstract, dc_buffer_t *buffer) // Update and emit a progress event. progress.current += 20; - device_event_emit (abstract, DEVICE_EVENT_PROGRESS, &progress); + device_event_emit (abstract, DC_EVENT_PROGRESS, &progress); unsigned int nbytes = 0; while (nbytes < MEMORYSIZE) { @@ -278,7 +278,7 @@ mares_nemo_device_dump (device_t *abstract, dc_buffer_t *buffer) // Update and emit a progress event. progress.current += PACKETSIZE; - device_event_emit (abstract, DEVICE_EVENT_PROGRESS, &progress); + device_event_emit (abstract, DC_EVENT_PROGRESS, &progress); nbytes += PACKETSIZE; } @@ -288,7 +288,7 @@ mares_nemo_device_dump (device_t *abstract, dc_buffer_t *buffer) static dc_status_t -mares_nemo_device_foreach (device_t *abstract, dive_callback_t callback, void *userdata) +mares_nemo_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, void *userdata) { dc_buffer_t *buffer = dc_buffer_new (MEMORYSIZE); if (buffer == NULL) @@ -302,11 +302,11 @@ mares_nemo_device_foreach (device_t *abstract, dive_callback_t callback, void *u // Emit a device info event. unsigned char *data = dc_buffer_get_data (buffer); - device_devinfo_t devinfo; + dc_event_devinfo_t devinfo; devinfo.model = data[1]; devinfo.firmware = 0; devinfo.serial = array_uint16_be (data + 8); - device_event_emit (abstract, DEVICE_EVENT_DEVINFO, &devinfo); + device_event_emit (abstract, DC_EVENT_DEVINFO, &devinfo); rc = mares_nemo_extract_dives (abstract, data, MEMORYSIZE, callback, userdata); @@ -317,7 +317,7 @@ mares_nemo_device_foreach (device_t *abstract, dive_callback_t callback, void *u dc_status_t -mares_nemo_extract_dives (device_t *abstract, const unsigned char data[], unsigned int size, dive_callback_t callback, void *userdata) +mares_nemo_extract_dives (dc_device_t *abstract, const unsigned char data[], unsigned int size, dc_dive_callback_t callback, void *userdata) { mares_nemo_device_t *device = (mares_nemo_device_t*) abstract; diff --git a/src/mares_nemo_parser.c b/src/mares_nemo_parser.c index 756ac93..ebf8cfb 100644 --- a/src/mares_nemo_parser.c +++ b/src/mares_nemo_parser.c @@ -40,7 +40,7 @@ typedef struct mares_nemo_parser_t mares_nemo_parser_t; struct mares_nemo_parser_t { - parser_t base; + dc_parser_t base; unsigned int model; unsigned int freedive; /* Internal state */ @@ -52,11 +52,11 @@ struct mares_nemo_parser_t { unsigned int extra; }; -static dc_status_t mares_nemo_parser_set_data (parser_t *abstract, const unsigned char *data, unsigned int size); -static dc_status_t mares_nemo_parser_get_datetime (parser_t *abstract, dc_datetime_t *datetime); -static dc_status_t mares_nemo_parser_get_field (parser_t *abstract, parser_field_type_t type, unsigned int flags, void *value); -static dc_status_t mares_nemo_parser_samples_foreach (parser_t *abstract, sample_callback_t callback, void *userdata); -static dc_status_t mares_nemo_parser_destroy (parser_t *abstract); +static dc_status_t mares_nemo_parser_set_data (dc_parser_t *abstract, const unsigned char *data, unsigned int size); +static dc_status_t mares_nemo_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *datetime); +static dc_status_t mares_nemo_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsigned int flags, void *value); +static dc_status_t mares_nemo_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t callback, void *userdata); +static dc_status_t mares_nemo_parser_destroy (dc_parser_t *abstract); static const parser_backend_t mares_nemo_parser_backend = { DC_FAMILY_MARES_NEMO, @@ -69,7 +69,7 @@ static const parser_backend_t mares_nemo_parser_backend = { static int -parser_is_mares_nemo (parser_t *abstract) +parser_is_mares_nemo (dc_parser_t *abstract) { if (abstract == NULL) return 0; @@ -79,7 +79,7 @@ parser_is_mares_nemo (parser_t *abstract) dc_status_t -mares_nemo_parser_create (parser_t **out, unsigned int model) +mares_nemo_parser_create (dc_parser_t **out, unsigned int model) { if (out == NULL) return DC_STATUS_INVALIDARGS; @@ -109,14 +109,14 @@ mares_nemo_parser_create (parser_t **out, unsigned int model) parser->header = 0; parser->extra = 0; - *out = (parser_t*) parser; + *out = (dc_parser_t*) parser; return DC_STATUS_SUCCESS; } static dc_status_t -mares_nemo_parser_destroy (parser_t *abstract) +mares_nemo_parser_destroy (dc_parser_t *abstract) { if (! parser_is_mares_nemo (abstract)) return DC_STATUS_INVALIDARGS; @@ -129,7 +129,7 @@ mares_nemo_parser_destroy (parser_t *abstract) static dc_status_t -mares_nemo_parser_set_data (parser_t *abstract, const unsigned char *data, unsigned int size) +mares_nemo_parser_set_data (dc_parser_t *abstract, const unsigned char *data, unsigned int size) { mares_nemo_parser_t *parser = (mares_nemo_parser_t *) abstract; @@ -201,7 +201,7 @@ mares_nemo_parser_set_data (parser_t *abstract, const unsigned char *data, unsig static dc_status_t -mares_nemo_parser_get_datetime (parser_t *abstract, dc_datetime_t *datetime) +mares_nemo_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *datetime) { mares_nemo_parser_t *parser = (mares_nemo_parser_t *) abstract; @@ -224,7 +224,7 @@ mares_nemo_parser_get_datetime (parser_t *abstract, dc_datetime_t *datetime) static dc_status_t -mares_nemo_parser_get_field (parser_t *abstract, parser_field_type_t type, unsigned int flags, void *value) +mares_nemo_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsigned int flags, void *value) { mares_nemo_parser_t *parser = (mares_nemo_parser_t *) abstract; @@ -236,21 +236,21 @@ mares_nemo_parser_get_field (parser_t *abstract, parser_field_type_t type, unsig if (value) { if (parser->mode != parser->freedive) { - gasmix_t *gasmix = (gasmix_t *) value; + dc_gasmix_t *gasmix = (dc_gasmix_t *) value; switch (type) { - case FIELD_TYPE_DIVETIME: + case DC_FIELD_DIVETIME: *((unsigned int *) value) = parser->sample_count * 20; break; - case FIELD_TYPE_MAXDEPTH: + case DC_FIELD_MAXDEPTH: *((double *) value) = array_uint16_le (p + 53 - 10) / 10.0; break; - case FIELD_TYPE_GASMIX_COUNT: + case DC_FIELD_GASMIX_COUNT: if (parser->mode == 0 || parser->mode == 1) *((unsigned int *) value) = 1; else *((unsigned int *) value) = 0; break; - case FIELD_TYPE_GASMIX: + case DC_FIELD_GASMIX: switch (parser->mode) { case 0: // Air gasmix->oxygen = 0.21; @@ -270,17 +270,17 @@ mares_nemo_parser_get_field (parser_t *abstract, parser_field_type_t type, unsig } else { unsigned int divetime = 0; switch (type) { - case FIELD_TYPE_DIVETIME: + case DC_FIELD_DIVETIME: for (unsigned int i = 0; i < parser->sample_count; ++i) { unsigned int idx = 2 + parser->sample_size * i; divetime += data[idx + 2] + data[idx + 3] * 60; } *((unsigned int *) value) = divetime; break; - case FIELD_TYPE_MAXDEPTH: + case DC_FIELD_MAXDEPTH: *((double *) value) = array_uint16_le (p + 28 - 10) / 10.0; break; - case FIELD_TYPE_GASMIX_COUNT: + case DC_FIELD_GASMIX_COUNT: *((unsigned int *) value) = 0; break; default: @@ -294,7 +294,7 @@ mares_nemo_parser_get_field (parser_t *abstract, parser_field_type_t type, unsig static dc_status_t -mares_nemo_parser_samples_foreach (parser_t *abstract, sample_callback_t callback, void *userdata) +mares_nemo_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t callback, void *userdata) { mares_nemo_parser_t *parser = (mares_nemo_parser_t *) abstract; @@ -307,7 +307,7 @@ mares_nemo_parser_samples_foreach (parser_t *abstract, sample_callback_t callbac if (parser->mode != parser->freedive) { unsigned int time = 0; for (unsigned int i = 0; i < parser->sample_count; ++i) { - parser_sample_value_t sample = {0}; + dc_sample_value_t sample = {0}; unsigned int idx = 2 + parser->sample_size * i; unsigned int value = array_uint16_le (data + idx); @@ -319,11 +319,11 @@ mares_nemo_parser_samples_foreach (parser_t *abstract, sample_callback_t callbac // Time (seconds). time += 20; sample.time = time; - if (callback) callback (SAMPLE_TYPE_TIME, sample, userdata); + if (callback) callback (DC_SAMPLE_TIME, sample, userdata); // Depth (1/10 m). sample.depth = depth / 10.0; - if (callback) callback (SAMPLE_TYPE_DEPTH, sample, userdata); + if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); // Ascent rate if (ascent) { @@ -331,7 +331,7 @@ mares_nemo_parser_samples_foreach (parser_t *abstract, sample_callback_t callbac sample.event.time = 0; sample.event.flags = 0; sample.event.value = ascent; - if (callback) callback (SAMPLE_TYPE_EVENT, sample, userdata); + if (callback) callback (DC_SAMPLE_EVENT, sample, userdata); } // Deco violation @@ -340,7 +340,7 @@ mares_nemo_parser_samples_foreach (parser_t *abstract, sample_callback_t callbac sample.event.time = 0; sample.event.flags = 0; sample.event.value = 0; - if (callback) callback (SAMPLE_TYPE_EVENT, sample, userdata); + if (callback) callback (DC_SAMPLE_EVENT, sample, userdata); } // Deco stop @@ -349,14 +349,14 @@ mares_nemo_parser_samples_foreach (parser_t *abstract, sample_callback_t callbac sample.event.time = 0; sample.event.flags = 0; sample.event.value = 0; - if (callback) callback (SAMPLE_TYPE_EVENT, sample, userdata); + if (callback) callback (DC_SAMPLE_EVENT, sample, userdata); } // Pressure (1 bar). if (parser->sample_size == 3) { sample.pressure.tank = 0; sample.pressure.value = data[idx + 2]; - if (callback) callback (SAMPLE_TYPE_PRESSURE, sample, userdata); + if (callback) callback (DC_SAMPLE_PRESSURE, sample, userdata); } } } else { @@ -370,7 +370,7 @@ mares_nemo_parser_samples_foreach (parser_t *abstract, sample_callback_t callbac unsigned int time = 0; unsigned int offset = parser->length; for (unsigned int i = 0; i < parser->sample_count; ++i) { - parser_sample_value_t sample = {0}; + dc_sample_value_t sample = {0}; unsigned int idx = 2 + parser->sample_size * i; unsigned int maxdepth = array_uint16_le (data + idx); @@ -380,11 +380,11 @@ mares_nemo_parser_samples_foreach (parser_t *abstract, sample_callback_t callbac // Surface Time (seconds). time += surftime; sample.time = time; - if (callback) callback (SAMPLE_TYPE_TIME, sample, userdata); + if (callback) callback (DC_SAMPLE_TIME, sample, userdata); // Surface Depth (0 m). sample.depth = 0.0; - if (callback) callback (SAMPLE_TYPE_DEPTH, sample, userdata); + if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); if (profiles) { // Get the freedive sample interval for this model. @@ -421,11 +421,11 @@ mares_nemo_parser_samples_foreach (parser_t *abstract, sample_callback_t callbac if (time > maxtime) time = maxtime; // Adjust the last sample. sample.time = time; - if (callback) callback (SAMPLE_TYPE_TIME, sample, userdata); + if (callback) callback (DC_SAMPLE_TIME, sample, userdata); // Depth (1/10 m). sample.depth = depth / 10.0; - if (callback) callback (SAMPLE_TYPE_DEPTH, sample, userdata); + if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); } // Verify that the number of samples in the profile data @@ -440,11 +440,11 @@ mares_nemo_parser_samples_foreach (parser_t *abstract, sample_callback_t callbac // Dive Time (seconds). time += divetime; sample.time = time; - if (callback) callback (SAMPLE_TYPE_TIME, sample, userdata); + if (callback) callback (DC_SAMPLE_TIME, sample, userdata); // Maximum Depth (1/10 m). sample.depth = maxdepth / 10.0; - if (callback) callback (SAMPLE_TYPE_DEPTH, sample, userdata); + if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); } } } diff --git a/src/mares_puck.c b/src/mares_puck.c index b99b4a0..250c2f1 100644 --- a/src/mares_puck.c +++ b/src/mares_puck.c @@ -43,10 +43,10 @@ typedef struct mares_puck_device_t { unsigned char fingerprint[5]; } mares_puck_device_t; -static dc_status_t mares_puck_device_set_fingerprint (device_t *abstract, const unsigned char data[], unsigned int size); -static dc_status_t mares_puck_device_dump (device_t *abstract, dc_buffer_t *buffer); -static dc_status_t mares_puck_device_foreach (device_t *abstract, dive_callback_t callback, void *userdata); -static dc_status_t mares_puck_device_close (device_t *abstract); +static dc_status_t mares_puck_device_set_fingerprint (dc_device_t *abstract, const unsigned char data[], unsigned int size); +static dc_status_t mares_puck_device_dump (dc_device_t *abstract, dc_buffer_t *buffer); +static dc_status_t mares_puck_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, void *userdata); +static dc_status_t mares_puck_device_close (dc_device_t *abstract); static const device_backend_t mares_puck_device_backend = { DC_FAMILY_MARES_PUCK, @@ -84,7 +84,7 @@ static const mares_common_layout_t mares_nemowide_layout = { }; static int -device_is_mares_puck (device_t *abstract) +device_is_mares_puck (dc_device_t *abstract) { if (abstract == NULL) return 0; @@ -94,7 +94,7 @@ device_is_mares_puck (device_t *abstract) dc_status_t -mares_puck_device_open (device_t **out, const char* name) +mares_puck_device_open (dc_device_t **out, const char *name) { if (out == NULL) return DC_STATUS_INVALIDARGS; @@ -152,7 +152,7 @@ mares_puck_device_open (device_t **out, const char* name) // Identify the model number. unsigned char header[PACKETSIZE] = {0}; - dc_status_t status = mares_common_device_read ((device_t *) device, 0, header, sizeof (header)); + dc_status_t status = mares_common_device_read ((dc_device_t *) device, 0, header, sizeof (header)); if (status != DC_STATUS_SUCCESS) { serial_close (device->base.port); free (device); @@ -176,14 +176,14 @@ mares_puck_device_open (device_t **out, const char* name) break; } - *out = (device_t*) device; + *out = (dc_device_t*) device; return DC_STATUS_SUCCESS; } static dc_status_t -mares_puck_device_close (device_t *abstract) +mares_puck_device_close (dc_device_t *abstract) { mares_puck_device_t *device = (mares_puck_device_t*) abstract; @@ -201,7 +201,7 @@ mares_puck_device_close (device_t *abstract) static dc_status_t -mares_puck_device_set_fingerprint (device_t *abstract, const unsigned char data[], unsigned int size) +mares_puck_device_set_fingerprint (dc_device_t *abstract, const unsigned char data[], unsigned int size) { mares_puck_device_t *device = (mares_puck_device_t *) abstract; @@ -218,7 +218,7 @@ mares_puck_device_set_fingerprint (device_t *abstract, const unsigned char data[ static dc_status_t -mares_puck_device_dump (device_t *abstract, dc_buffer_t *buffer) +mares_puck_device_dump (dc_device_t *abstract, dc_buffer_t *buffer) { mares_puck_device_t *device = (mares_puck_device_t *) abstract; @@ -237,7 +237,7 @@ mares_puck_device_dump (device_t *abstract, dc_buffer_t *buffer) static dc_status_t -mares_puck_device_foreach (device_t *abstract, dive_callback_t callback, void *userdata) +mares_puck_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, void *userdata) { mares_puck_device_t *device = (mares_puck_device_t *) abstract; @@ -255,11 +255,11 @@ mares_puck_device_foreach (device_t *abstract, dive_callback_t callback, void *u // Emit a device info event. unsigned char *data = dc_buffer_get_data (buffer); - device_devinfo_t devinfo; + dc_event_devinfo_t devinfo; devinfo.model = data[1]; devinfo.firmware = 0; devinfo.serial = array_uint16_be (data + 8); - device_event_emit (abstract, DEVICE_EVENT_DEVINFO, &devinfo); + device_event_emit (abstract, DC_EVENT_DEVINFO, &devinfo); rc = mares_common_extract_dives (device->layout, device->fingerprint, data, callback, userdata); @@ -270,7 +270,7 @@ mares_puck_device_foreach (device_t *abstract, dive_callback_t callback, void *u dc_status_t -mares_puck_extract_dives (device_t *abstract, const unsigned char data[], unsigned int size, dive_callback_t callback, void *userdata) +mares_puck_extract_dives (dc_device_t *abstract, const unsigned char data[], unsigned int size, dc_dive_callback_t callback, void *userdata) { mares_puck_device_t *device = (mares_puck_device_t*) abstract; diff --git a/src/oceanic_atom2.c b/src/oceanic_atom2.c index da67e46..5bdf973 100644 --- a/src/oceanic_atom2.c +++ b/src/oceanic_atom2.c @@ -48,10 +48,10 @@ typedef struct oceanic_atom2_device_t { unsigned char version[PAGESIZE]; } oceanic_atom2_device_t; -static dc_status_t oceanic_atom2_device_version (device_t *abstract, unsigned char data[], unsigned int size); -static dc_status_t oceanic_atom2_device_read (device_t *abstract, unsigned int address, unsigned char data[], unsigned int size); -static dc_status_t oceanic_atom2_device_write (device_t *abstract, unsigned int address, const unsigned char data[], unsigned int size); -static dc_status_t oceanic_atom2_device_close (device_t *abstract); +static dc_status_t oceanic_atom2_device_version (dc_device_t *abstract, unsigned char data[], unsigned int size); +static dc_status_t oceanic_atom2_device_read (dc_device_t *abstract, unsigned int address, unsigned char data[], unsigned int size); +static dc_status_t oceanic_atom2_device_write (dc_device_t *abstract, unsigned int address, const unsigned char data[], unsigned int size); +static dc_status_t oceanic_atom2_device_close (dc_device_t *abstract); static const device_backend_t oceanic_atom2_device_backend = { DC_FAMILY_OCEANIC_ATOM2, @@ -206,7 +206,7 @@ static const oceanic_common_layout_t oceanic_veo1_layout = { static int -device_is_oceanic_atom2 (device_t *abstract) +device_is_oceanic_atom2 (dc_device_t *abstract) { if (abstract == NULL) return 0; @@ -218,7 +218,7 @@ device_is_oceanic_atom2 (device_t *abstract) static dc_status_t oceanic_atom2_send (oceanic_atom2_device_t *device, const unsigned char command[], unsigned int csize, unsigned char ack) { - device_t *abstract = (device_t *) device; + dc_device_t *abstract = (dc_device_t *) device; if (device_is_cancelled (abstract)) return DC_STATUS_CANCELLED; @@ -307,7 +307,7 @@ oceanic_atom2_quit (oceanic_atom2_device_t *device) dc_status_t -oceanic_atom2_device_open (device_t **out, const char* name) +oceanic_atom2_device_open (dc_device_t **out, const char *name) { if (out == NULL) return DC_STATUS_INVALIDARGS; @@ -360,7 +360,7 @@ oceanic_atom2_device_open (device_t **out, const char* name) // Switch the device from surface mode into download mode. Before sending // this command, the device needs to be in PC mode (automatically activated // by connecting the device), or already in download mode. - dc_status_t status = oceanic_atom2_device_version ((device_t *) device, device->version, sizeof (device->version)); + dc_status_t status = oceanic_atom2_device_version ((dc_device_t *) device, device->version, sizeof (device->version)); if (status != DC_STATUS_SUCCESS) { serial_close (device->port); free (device); @@ -402,14 +402,14 @@ oceanic_atom2_device_open (device_t **out, const char* name) else device->base.layout = &oceanic_default_layout; - *out = (device_t*) device; + *out = (dc_device_t*) device; return DC_STATUS_SUCCESS; } static dc_status_t -oceanic_atom2_device_close (device_t *abstract) +oceanic_atom2_device_close (dc_device_t *abstract) { oceanic_atom2_device_t *device = (oceanic_atom2_device_t*) abstract; @@ -433,7 +433,7 @@ oceanic_atom2_device_close (device_t *abstract) dc_status_t -oceanic_atom2_device_keepalive (device_t *abstract) +oceanic_atom2_device_keepalive (dc_device_t *abstract) { oceanic_atom2_device_t *device = (oceanic_atom2_device_t*) abstract; @@ -451,7 +451,7 @@ oceanic_atom2_device_keepalive (device_t *abstract) static dc_status_t -oceanic_atom2_device_version (device_t *abstract, unsigned char data[], unsigned int size) +oceanic_atom2_device_version (dc_device_t *abstract, unsigned char data[], unsigned int size) { oceanic_atom2_device_t *device = (oceanic_atom2_device_t*) abstract; @@ -474,7 +474,7 @@ oceanic_atom2_device_version (device_t *abstract, unsigned char data[], unsigned static dc_status_t -oceanic_atom2_device_read (device_t *abstract, unsigned int address, unsigned char data[], unsigned int size) +oceanic_atom2_device_read (dc_device_t *abstract, unsigned int address, unsigned char data[], unsigned int size) { oceanic_atom2_device_t *device = (oceanic_atom2_device_t*) abstract; @@ -513,7 +513,7 @@ oceanic_atom2_device_read (device_t *abstract, unsigned int address, unsigned ch static dc_status_t -oceanic_atom2_device_write (device_t *abstract, unsigned int address, const unsigned char data[], unsigned int size) +oceanic_atom2_device_write (dc_device_t *abstract, unsigned int address, const unsigned char data[], unsigned int size) { oceanic_atom2_device_t *device = (oceanic_atom2_device_t*) abstract; diff --git a/src/oceanic_atom2_parser.c b/src/oceanic_atom2_parser.c index 3eb89ee..67e4de2 100644 --- a/src/oceanic_atom2_parser.c +++ b/src/oceanic_atom2_parser.c @@ -53,7 +53,7 @@ typedef struct oceanic_atom2_parser_t oceanic_atom2_parser_t; struct oceanic_atom2_parser_t { - parser_t base; + dc_parser_t base; unsigned int model; // Cached fields. unsigned int cached; @@ -61,11 +61,11 @@ struct oceanic_atom2_parser_t { double maxdepth; }; -static dc_status_t oceanic_atom2_parser_set_data (parser_t *abstract, const unsigned char *data, unsigned int size); -static dc_status_t oceanic_atom2_parser_get_datetime (parser_t *abstract, dc_datetime_t *datetime); -static dc_status_t oceanic_atom2_parser_get_field (parser_t *abstract, parser_field_type_t type, unsigned int flags, void *value); -static dc_status_t oceanic_atom2_parser_samples_foreach (parser_t *abstract, sample_callback_t callback, void *userdata); -static dc_status_t oceanic_atom2_parser_destroy (parser_t *abstract); +static dc_status_t oceanic_atom2_parser_set_data (dc_parser_t *abstract, const unsigned char *data, unsigned int size); +static dc_status_t oceanic_atom2_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *datetime); +static dc_status_t oceanic_atom2_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsigned int flags, void *value); +static dc_status_t oceanic_atom2_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t callback, void *userdata); +static dc_status_t oceanic_atom2_parser_destroy (dc_parser_t *abstract); static const parser_backend_t oceanic_atom2_parser_backend = { DC_FAMILY_OCEANIC_ATOM2, @@ -78,7 +78,7 @@ static const parser_backend_t oceanic_atom2_parser_backend = { static int -parser_is_oceanic_atom2 (parser_t *abstract) +parser_is_oceanic_atom2 (dc_parser_t *abstract) { if (abstract == NULL) return 0; @@ -88,7 +88,7 @@ parser_is_oceanic_atom2 (parser_t *abstract) dc_status_t -oceanic_atom2_parser_create (parser_t **out, unsigned int model) +oceanic_atom2_parser_create (dc_parser_t **out, unsigned int model) { if (out == NULL) return DC_STATUS_INVALIDARGS; @@ -109,14 +109,14 @@ oceanic_atom2_parser_create (parser_t **out, unsigned int model) parser->divetime = 0; parser->maxdepth = 0.0; - *out = (parser_t*) parser; + *out = (dc_parser_t*) parser; return DC_STATUS_SUCCESS; } static dc_status_t -oceanic_atom2_parser_destroy (parser_t *abstract) +oceanic_atom2_parser_destroy (dc_parser_t *abstract) { if (! parser_is_oceanic_atom2 (abstract)) return DC_STATUS_INVALIDARGS; @@ -129,7 +129,7 @@ oceanic_atom2_parser_destroy (parser_t *abstract) static dc_status_t -oceanic_atom2_parser_set_data (parser_t *abstract, const unsigned char *data, unsigned int size) +oceanic_atom2_parser_set_data (dc_parser_t *abstract, const unsigned char *data, unsigned int size) { oceanic_atom2_parser_t *parser = (oceanic_atom2_parser_t *) abstract; @@ -146,7 +146,7 @@ oceanic_atom2_parser_set_data (parser_t *abstract, const unsigned char *data, un static dc_status_t -oceanic_atom2_parser_get_datetime (parser_t *abstract, dc_datetime_t *datetime) +oceanic_atom2_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *datetime) { oceanic_atom2_parser_t *parser = (oceanic_atom2_parser_t *) abstract; @@ -255,7 +255,7 @@ oceanic_atom2_parser_get_datetime (parser_t *abstract, dc_datetime_t *datetime) static dc_status_t -oceanic_atom2_parser_get_field (parser_t *abstract, parser_field_type_t type, unsigned int flags, void *value) +oceanic_atom2_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsigned int flags, void *value) { oceanic_atom2_parser_t *parser = (oceanic_atom2_parser_t *) abstract; @@ -300,25 +300,25 @@ oceanic_atom2_parser_get_field (parser_t *abstract, parser_field_type_t type, un parser->maxdepth = statistics.maxdepth; } - gasmix_t *gasmix = (gasmix_t *) value; + dc_gasmix_t *gasmix = (dc_gasmix_t *) value; unsigned int nitrox = 0; if (value) { switch (type) { - case FIELD_TYPE_DIVETIME: + case DC_FIELD_DIVETIME: if (parser->model == F10) *((unsigned int *) value) = bcd2dec (data[2]) + bcd2dec (data[3]) * 60 + bcd2dec (data[1]) * 3600; else *((unsigned int *) value) = parser->divetime; break; - case FIELD_TYPE_MAXDEPTH: + case DC_FIELD_MAXDEPTH: if (parser->model == F10) *((double *) value) = array_uint16_le (data + 4) / 16.0 * FEET; else *((double *) value) = array_uint16_le (data + footer + 4) / 16.0 * FEET; break; - case FIELD_TYPE_GASMIX_COUNT: + case DC_FIELD_GASMIX_COUNT: if (parser->model == DATAMASK || parser->model == COMPUMASK) *((unsigned int *) value) = 1; else if (parser->model == VT4 || parser->model == VT41) @@ -326,7 +326,7 @@ oceanic_atom2_parser_get_field (parser_t *abstract, parser_field_type_t type, un else *((unsigned int *) value) = 3; break; - case FIELD_TYPE_GASMIX: + case DC_FIELD_GASMIX: if (parser->model == DATAMASK || parser->model == COMPUMASK) nitrox = data[header + 3]; else @@ -345,7 +345,7 @@ oceanic_atom2_parser_get_field (parser_t *abstract, parser_field_type_t type, un static dc_status_t -oceanic_atom2_parser_samples_foreach (parser_t *abstract, sample_callback_t callback, void *userdata) +oceanic_atom2_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t callback, void *userdata) { oceanic_atom2_parser_t *parser = (oceanic_atom2_parser_t *) abstract; @@ -428,7 +428,7 @@ oceanic_atom2_parser_samples_foreach (parser_t *abstract, sample_callback_t call unsigned int complete = 1; unsigned int offset = headersize; while (offset + samplesize <= size - footersize) { - parser_sample_value_t sample = {0}; + dc_sample_value_t sample = {0}; // Ignore empty samples. if (array_isequal (data + offset, samplesize, 0x00) || @@ -441,7 +441,7 @@ oceanic_atom2_parser_samples_foreach (parser_t *abstract, sample_callback_t call if (complete) { time += interval; sample.time = time; - if (callback) callback (SAMPLE_TYPE_TIME, sample, userdata); + if (callback) callback (DC_SAMPLE_TIME, sample, userdata); complete = 0; } @@ -464,7 +464,7 @@ oceanic_atom2_parser_samples_foreach (parser_t *abstract, sample_callback_t call sample.vendor.type = SAMPLE_VENDOR_OCEANIC_ATOM2; sample.vendor.size = length; sample.vendor.data = data + offset; - if (callback) callback (SAMPLE_TYPE_VENDOR, sample, userdata); + if (callback) callback (DC_SAMPLE_VENDOR, sample, userdata); // Check for a tank switch sample. if (sampletype == 0xAA) { @@ -491,11 +491,11 @@ oceanic_atom2_parser_samples_foreach (parser_t *abstract, sample_callback_t call if (complete) { time += interval; sample.time = time; - if (callback) callback (SAMPLE_TYPE_TIME, sample, userdata); + if (callback) callback (DC_SAMPLE_TIME, sample, userdata); } sample.depth = 0.0; - if (callback) callback (SAMPLE_TYPE_DEPTH, sample, userdata); + if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); complete = 1; } } else { @@ -521,7 +521,7 @@ oceanic_atom2_parser_samples_foreach (parser_t *abstract, sample_callback_t call temperature += (data[offset + 7] & 0x0C) >> 2; } sample.temperature = (temperature - 32.0) * (5.0 / 9.0); - if (callback) callback (SAMPLE_TYPE_TEMPERATURE, sample, userdata); + if (callback) callback (DC_SAMPLE_TEMPERATURE, sample, userdata); } // Tank Pressure (psi) @@ -534,7 +534,7 @@ oceanic_atom2_parser_samples_foreach (parser_t *abstract, sample_callback_t call pressure -= data[offset + 1]; sample.pressure.tank = tank; sample.pressure.value = pressure * PSI / BAR; - if (callback) callback (SAMPLE_TYPE_PRESSURE, sample, userdata); + if (callback) callback (DC_SAMPLE_PRESSURE, sample, userdata); } // Depth (1/16 ft) @@ -550,7 +550,7 @@ oceanic_atom2_parser_samples_foreach (parser_t *abstract, sample_callback_t call else depth = (data[offset + 2] + (data[offset + 3] << 8)) & 0x0FFF; sample.depth = depth / 16.0 * FEET; - if (callback) callback (SAMPLE_TYPE_DEPTH, sample, userdata); + if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); complete = 1; } diff --git a/src/oceanic_common.c b/src/oceanic_common.c index 446d276..6a39108 100644 --- a/src/oceanic_common.c +++ b/src/oceanic_common.c @@ -121,7 +121,7 @@ oceanic_common_device_init (oceanic_common_device_t *device, const device_backen dc_status_t -oceanic_common_device_set_fingerprint (device_t *abstract, const unsigned char data[], unsigned int size) +oceanic_common_device_set_fingerprint (dc_device_t *abstract, const unsigned char data[], unsigned int size) { oceanic_common_device_t *device = (oceanic_common_device_t *) abstract; @@ -144,7 +144,7 @@ oceanic_common_device_set_fingerprint (device_t *abstract, const unsigned char d dc_status_t -oceanic_common_device_dump (device_t *abstract, dc_buffer_t *buffer) +oceanic_common_device_dump (dc_device_t *abstract, dc_buffer_t *buffer) { oceanic_common_device_t *device = (oceanic_common_device_t *) abstract; @@ -164,7 +164,7 @@ oceanic_common_device_dump (device_t *abstract, dc_buffer_t *buffer) dc_status_t -oceanic_common_device_foreach (device_t *abstract, dive_callback_t callback, void *userdata) +oceanic_common_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, void *userdata) { oceanic_common_device_t *device = (oceanic_common_device_t *) abstract; @@ -175,15 +175,15 @@ oceanic_common_device_foreach (device_t *abstract, dive_callback_t callback, voi const oceanic_common_layout_t *layout = device->layout; // Enable progress notifications. - device_progress_t progress = DEVICE_PROGRESS_INITIALIZER; + dc_event_progress_t progress = EVENT_PROGRESS_INITIALIZER; progress.maximum = 2 * PAGESIZE + (layout->rb_profile_end - layout->rb_profile_begin) + (layout->rb_logbook_end - layout->rb_logbook_begin); - device_event_emit (abstract, DEVICE_EVENT_PROGRESS, &progress); + device_event_emit (abstract, DC_EVENT_PROGRESS, &progress); // Read the device id. unsigned char id[PAGESIZE] = {0}; - dc_status_t rc = device_read (abstract, layout->cf_devinfo, id, sizeof (id)); + dc_status_t rc = dc_device_read (abstract, layout->cf_devinfo, id, sizeof (id)); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot read device id."); return rc; @@ -191,21 +191,21 @@ oceanic_common_device_foreach (device_t *abstract, dive_callback_t callback, voi // Update and emit a progress event. progress.current += PAGESIZE; - device_event_emit (abstract, DEVICE_EVENT_PROGRESS, &progress); + device_event_emit (abstract, DC_EVENT_PROGRESS, &progress); // Emit a device info event. - device_devinfo_t devinfo; + dc_event_devinfo_t devinfo; devinfo.model = array_uint16_be (id + 8); devinfo.firmware = 0; if (layout->pt_mode_global == 0) devinfo.serial = bcd2dec (id[10]) * 10000 + bcd2dec (id[11]) * 100 + bcd2dec (id[12]); else devinfo.serial = id[11] * 10000 + id[12] * 100 + id[13]; - device_event_emit (abstract, DEVICE_EVENT_DEVINFO, &devinfo); + device_event_emit (abstract, DC_EVENT_DEVINFO, &devinfo); // Read the pointer data. unsigned char pointers[PAGESIZE] = {0}; - rc = device_read (abstract, layout->cf_pointers, pointers, sizeof (pointers)); + rc = dc_device_read (abstract, layout->cf_pointers, pointers, sizeof (pointers)); if (rc != DC_STATUS_SUCCESS) { WARNING ("Cannot read pointers."); return rc; @@ -277,7 +277,7 @@ oceanic_common_device_foreach (device_t *abstract, dive_callback_t callback, voi progress.maximum = 2 * PAGESIZE + (layout->rb_profile_end - layout->rb_profile_begin) + rb_logbook_page_size; - device_event_emit (abstract, DEVICE_EVENT_PROGRESS, &progress); + device_event_emit (abstract, DC_EVENT_PROGRESS, &progress); // Memory buffer for the logbook entries. unsigned char *logbooks = (unsigned char *) malloc (rb_logbook_page_size); @@ -328,7 +328,7 @@ oceanic_common_device_foreach (device_t *abstract, dive_callback_t callback, voi offset -= len; // Read the logbook page. - rc = device_read (abstract, address, logbooks + offset, len); + rc = dc_device_read (abstract, address, logbooks + offset, len); if (rc != DC_STATUS_SUCCESS) { free (logbooks); return rc; @@ -336,7 +336,7 @@ oceanic_common_device_foreach (device_t *abstract, dive_callback_t callback, voi // Update and emit a progress event. progress.current += len; - device_event_emit (abstract, DEVICE_EVENT_PROGRESS, &progress); + device_event_emit (abstract, DC_EVENT_PROGRESS, &progress); // A full ringbuffer needs some special treatment to avoid // having to download the first/last page twice. When a full @@ -513,7 +513,7 @@ oceanic_common_device_foreach (device_t *abstract, dive_callback_t callback, voi offset -= len; // Read the profile page. - rc = device_read (abstract, address, profiles + offset, len); + rc = dc_device_read (abstract, address, profiles + offset, len); if (rc != DC_STATUS_SUCCESS) { free (logbooks); free (profiles); @@ -522,7 +522,7 @@ oceanic_common_device_foreach (device_t *abstract, dive_callback_t callback, voi // Update and emit a progress event. progress.current += len; - device_event_emit (abstract, DEVICE_EVENT_PROGRESS, &progress); + device_event_emit (abstract, DC_EVENT_PROGRESS, &progress); nbytes += len; } diff --git a/src/oceanic_common.h b/src/oceanic_common.h index 7cc95e3..208c8f5 100644 --- a/src/oceanic_common.h +++ b/src/oceanic_common.h @@ -54,7 +54,7 @@ typedef struct oceanic_common_layout_t { } oceanic_common_layout_t; typedef struct oceanic_common_device_t { - device_t base; + dc_device_t base; unsigned char fingerprint[FPMAXSIZE]; const oceanic_common_layout_t *layout; unsigned int multipage; @@ -67,13 +67,13 @@ void oceanic_common_device_init (oceanic_common_device_t *device, const device_backend_t *backend); dc_status_t -oceanic_common_device_set_fingerprint (device_t *device, const unsigned char data[], unsigned int size); +oceanic_common_device_set_fingerprint (dc_device_t *device, const unsigned char data[], unsigned int size); dc_status_t -oceanic_common_device_dump (device_t *abstract, dc_buffer_t *buffer); +oceanic_common_device_dump (dc_device_t *abstract, dc_buffer_t *buffer); dc_status_t -oceanic_common_device_foreach (device_t *device, dive_callback_t callback, void *userdata); +oceanic_common_device_foreach (dc_device_t *device, dc_dive_callback_t callback, void *userdata); #ifdef __cplusplus } diff --git a/src/oceanic_veo250.c b/src/oceanic_veo250.c index fb48520..2445dac 100644 --- a/src/oceanic_veo250.c +++ b/src/oceanic_veo250.c @@ -49,9 +49,9 @@ typedef struct oceanic_veo250_device_t { unsigned char version[PAGESIZE]; } oceanic_veo250_device_t; -static dc_status_t oceanic_veo250_device_version (device_t *abstract, unsigned char data[], unsigned int size); -static dc_status_t oceanic_veo250_device_read (device_t *abstract, unsigned int address, unsigned char data[], unsigned int size); -static dc_status_t oceanic_veo250_device_close (device_t *abstract); +static dc_status_t oceanic_veo250_device_version (dc_device_t *abstract, unsigned char data[], unsigned int size); +static dc_status_t oceanic_veo250_device_read (dc_device_t *abstract, unsigned int address, unsigned char data[], unsigned int size); +static dc_status_t oceanic_veo250_device_close (dc_device_t *abstract); static const device_backend_t oceanic_veo250_device_backend = { DC_FAMILY_OCEANIC_VEO250, @@ -79,7 +79,7 @@ static const oceanic_common_layout_t oceanic_veo250_layout = { static int -device_is_oceanic_veo250 (device_t *abstract) +device_is_oceanic_veo250 (dc_device_t *abstract) { if (abstract == NULL) return 0; @@ -91,7 +91,7 @@ device_is_oceanic_veo250 (device_t *abstract) static dc_status_t oceanic_veo250_send (oceanic_veo250_device_t *device, const unsigned char command[], unsigned int csize) { - device_t *abstract = (device_t *) device; + dc_device_t *abstract = (dc_device_t *) device; if (device_is_cancelled (abstract)) return DC_STATUS_CANCELLED; @@ -214,7 +214,7 @@ oceanic_veo250_quit (oceanic_veo250_device_t *device) dc_status_t -oceanic_veo250_device_open (device_t **out, const char* name) +oceanic_veo250_device_open (dc_device_t **out, const char *name) { if (out == NULL) return DC_STATUS_INVALIDARGS; @@ -292,21 +292,21 @@ oceanic_veo250_device_open (device_t **out, const char* name) // Switch the device from surface mode into download mode. Before sending // this command, the device needs to be in PC mode (manually activated by // the user), or already in download mode. - status = oceanic_veo250_device_version ((device_t *) device, device->version, sizeof (device->version)); + status = oceanic_veo250_device_version ((dc_device_t *) device, device->version, sizeof (device->version)); if (status != DC_STATUS_SUCCESS) { serial_close (device->port); free (device); return status; } - *out = (device_t*) device; + *out = (dc_device_t*) device; return DC_STATUS_SUCCESS; } static dc_status_t -oceanic_veo250_device_close (device_t *abstract) +oceanic_veo250_device_close (dc_device_t *abstract) { oceanic_veo250_device_t *device = (oceanic_veo250_device_t*) abstract; @@ -330,7 +330,7 @@ oceanic_veo250_device_close (device_t *abstract) dc_status_t -oceanic_veo250_device_keepalive (device_t *abstract) +oceanic_veo250_device_keepalive (dc_device_t *abstract) { oceanic_veo250_device_t *device = (oceanic_veo250_device_t*) abstract; @@ -357,7 +357,7 @@ oceanic_veo250_device_keepalive (device_t *abstract) static dc_status_t -oceanic_veo250_device_version (device_t *abstract, unsigned char data[], unsigned int size) +oceanic_veo250_device_version (dc_device_t *abstract, unsigned char data[], unsigned int size) { oceanic_veo250_device_t *device = (oceanic_veo250_device_t*) abstract; @@ -388,7 +388,7 @@ oceanic_veo250_device_version (device_t *abstract, unsigned char data[], unsigne static dc_status_t -oceanic_veo250_device_read (device_t *abstract, unsigned int address, unsigned char data[], unsigned int size) +oceanic_veo250_device_read (dc_device_t *abstract, unsigned int address, unsigned char data[], unsigned int size) { oceanic_veo250_device_t *device = (oceanic_veo250_device_t*) abstract; diff --git a/src/oceanic_veo250_parser.c b/src/oceanic_veo250_parser.c index bee7447..728fc30 100644 --- a/src/oceanic_veo250_parser.c +++ b/src/oceanic_veo250_parser.c @@ -32,7 +32,7 @@ typedef struct oceanic_veo250_parser_t oceanic_veo250_parser_t; struct oceanic_veo250_parser_t { - parser_t base; + dc_parser_t base; unsigned int model; // Cached fields. unsigned int cached; @@ -40,11 +40,11 @@ struct oceanic_veo250_parser_t { double maxdepth; }; -static dc_status_t oceanic_veo250_parser_set_data (parser_t *abstract, const unsigned char *data, unsigned int size); -static dc_status_t oceanic_veo250_parser_get_datetime (parser_t *abstract, dc_datetime_t *datetime); -static dc_status_t oceanic_veo250_parser_get_field (parser_t *abstract, parser_field_type_t type, unsigned int flags, void *value); -static dc_status_t oceanic_veo250_parser_samples_foreach (parser_t *abstract, sample_callback_t callback, void *userdata); -static dc_status_t oceanic_veo250_parser_destroy (parser_t *abstract); +static dc_status_t oceanic_veo250_parser_set_data (dc_parser_t *abstract, const unsigned char *data, unsigned int size); +static dc_status_t oceanic_veo250_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *datetime); +static dc_status_t oceanic_veo250_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsigned int flags, void *value); +static dc_status_t oceanic_veo250_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t callback, void *userdata); +static dc_status_t oceanic_veo250_parser_destroy (dc_parser_t *abstract); static const parser_backend_t oceanic_veo250_parser_backend = { DC_FAMILY_OCEANIC_VEO250, @@ -57,7 +57,7 @@ static const parser_backend_t oceanic_veo250_parser_backend = { static int -parser_is_oceanic_veo250 (parser_t *abstract) +parser_is_oceanic_veo250 (dc_parser_t *abstract) { if (abstract == NULL) return 0; @@ -67,7 +67,7 @@ parser_is_oceanic_veo250 (parser_t *abstract) dc_status_t -oceanic_veo250_parser_create (parser_t **out, unsigned int model) +oceanic_veo250_parser_create (dc_parser_t **out, unsigned int model) { if (out == NULL) return DC_STATUS_INVALIDARGS; @@ -88,14 +88,14 @@ oceanic_veo250_parser_create (parser_t **out, unsigned int model) parser->divetime = 0; parser->maxdepth = 0.0; - *out = (parser_t*) parser; + *out = (dc_parser_t*) parser; return DC_STATUS_SUCCESS; } static dc_status_t -oceanic_veo250_parser_destroy (parser_t *abstract) +oceanic_veo250_parser_destroy (dc_parser_t *abstract) { if (! parser_is_oceanic_veo250 (abstract)) return DC_STATUS_INVALIDARGS; @@ -108,7 +108,7 @@ oceanic_veo250_parser_destroy (parser_t *abstract) static dc_status_t -oceanic_veo250_parser_set_data (parser_t *abstract, const unsigned char *data, unsigned int size) +oceanic_veo250_parser_set_data (dc_parser_t *abstract, const unsigned char *data, unsigned int size) { oceanic_veo250_parser_t *parser = (oceanic_veo250_parser_t *) abstract; @@ -125,7 +125,7 @@ oceanic_veo250_parser_set_data (parser_t *abstract, const unsigned char *data, u static dc_status_t -oceanic_veo250_parser_get_datetime (parser_t *abstract, dc_datetime_t *datetime) +oceanic_veo250_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *datetime) { oceanic_veo250_parser_t *parser = (oceanic_veo250_parser_t *) abstract; @@ -151,7 +151,7 @@ oceanic_veo250_parser_get_datetime (parser_t *abstract, dc_datetime_t *datetime) static dc_status_t -oceanic_veo250_parser_get_field (parser_t *abstract, parser_field_type_t type, unsigned int flags, void *value) +oceanic_veo250_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsigned int flags, void *value) { oceanic_veo250_parser_t *parser = (oceanic_veo250_parser_t *) abstract; @@ -175,20 +175,20 @@ oceanic_veo250_parser_get_field (parser_t *abstract, parser_field_type_t type, u unsigned int footer = size - PAGESIZE; - gasmix_t *gasmix = (gasmix_t *) value; + dc_gasmix_t *gasmix = (dc_gasmix_t *) value; if (value) { switch (type) { - case FIELD_TYPE_DIVETIME: + case DC_FIELD_DIVETIME: *((unsigned int *) value) = data[footer + 3] * 60; break; - case FIELD_TYPE_MAXDEPTH: + case DC_FIELD_MAXDEPTH: *((double *) value) = parser->maxdepth; break; - case FIELD_TYPE_GASMIX_COUNT: + case DC_FIELD_GASMIX_COUNT: *((unsigned int *) value) = 1; break; - case FIELD_TYPE_GASMIX: + case DC_FIELD_GASMIX: gasmix->helium = 0.0; if (data[footer + 6]) gasmix->oxygen = data[footer + 6] / 100.0; @@ -206,7 +206,7 @@ oceanic_veo250_parser_get_field (parser_t *abstract, parser_field_type_t type, u static dc_status_t -oceanic_veo250_parser_samples_foreach (parser_t *abstract, sample_callback_t callback, void *userdata) +oceanic_veo250_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t callback, void *userdata) { if (! parser_is_oceanic_veo250 (abstract)) return DC_STATUS_INVALIDARGS; @@ -236,7 +236,7 @@ oceanic_veo250_parser_samples_foreach (parser_t *abstract, sample_callback_t cal unsigned int offset = 5 * PAGESIZE / 2; while (offset + PAGESIZE / 2 <= size - PAGESIZE) { - parser_sample_value_t sample = {0}; + dc_sample_value_t sample = {0}; // Ignore empty samples. if (array_isequal (data + offset, PAGESIZE / 2, 0x00)) { @@ -247,23 +247,23 @@ oceanic_veo250_parser_samples_foreach (parser_t *abstract, sample_callback_t cal // Time. time += interval; sample.time = time; - if (callback) callback (SAMPLE_TYPE_TIME, sample, userdata); + if (callback) callback (DC_SAMPLE_TIME, sample, userdata); // Vendor specific data sample.vendor.type = SAMPLE_VENDOR_OCEANIC_VEO250; sample.vendor.size = PAGESIZE / 2; sample.vendor.data = data + offset; - if (callback) callback (SAMPLE_TYPE_VENDOR, sample, userdata); + if (callback) callback (DC_SAMPLE_VENDOR, sample, userdata); // Depth (ft) unsigned int depth = data[offset + 2]; sample.depth = depth * FEET; - if (callback) callback (SAMPLE_TYPE_DEPTH, sample, userdata); + if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); // Temperature (°F) unsigned int temperature = data[offset + 7]; sample.temperature = (temperature - 32.0) * (5.0 / 9.0); - if (callback) callback (SAMPLE_TYPE_TEMPERATURE, sample, userdata); + if (callback) callback (DC_SAMPLE_TEMPERATURE, sample, userdata); offset += PAGESIZE / 2; } diff --git a/src/oceanic_vtpro.c b/src/oceanic_vtpro.c index a22bd7d..fabd0d4 100644 --- a/src/oceanic_vtpro.c +++ b/src/oceanic_vtpro.c @@ -49,9 +49,9 @@ typedef struct oceanic_vtpro_device_t { unsigned char version[PAGESIZE]; } oceanic_vtpro_device_t; -static dc_status_t oceanic_vtpro_device_version (device_t *abstract, unsigned char data[], unsigned int size); -static dc_status_t oceanic_vtpro_device_read (device_t *abstract, unsigned int address, unsigned char data[], unsigned int size); -static dc_status_t oceanic_vtpro_device_close (device_t *abstract); +static dc_status_t oceanic_vtpro_device_version (dc_device_t *abstract, unsigned char data[], unsigned int size); +static dc_status_t oceanic_vtpro_device_read (dc_device_t *abstract, unsigned int address, unsigned char data[], unsigned int size); +static dc_status_t oceanic_vtpro_device_close (dc_device_t *abstract); static const device_backend_t oceanic_vtpro_device_backend = { DC_FAMILY_OCEANIC_VTPRO, @@ -94,7 +94,7 @@ static const oceanic_common_layout_t oceanic_wisdom_layout = { }; static int -device_is_oceanic_vtpro (device_t *abstract) +device_is_oceanic_vtpro (dc_device_t *abstract) { if (abstract == NULL) return 0; @@ -106,7 +106,7 @@ device_is_oceanic_vtpro (device_t *abstract) static dc_status_t oceanic_vtpro_send (oceanic_vtpro_device_t *device, const unsigned char command[], unsigned int csize) { - device_t *abstract = (device_t *) device; + dc_device_t *abstract = (dc_device_t *) device; if (device_is_cancelled (abstract)) return DC_STATUS_CANCELLED; @@ -244,7 +244,7 @@ oceanic_vtpro_calibrate (oceanic_vtpro_device_t *device) dc_status_t -oceanic_vtpro_device_open (device_t **out, const char* name) +oceanic_vtpro_device_open (dc_device_t **out, const char *name) { if (out == NULL) return DC_STATUS_INVALIDARGS; @@ -317,7 +317,7 @@ oceanic_vtpro_device_open (device_t **out, const char* name) // Switch the device from surface mode into download mode. Before sending // this command, the device needs to be in PC mode (manually activated by // the user), or already in download mode. - status = oceanic_vtpro_device_version ((device_t *) device, device->version, sizeof (device->version)); + status = oceanic_vtpro_device_version ((dc_device_t *) device, device->version, sizeof (device->version)); if (status != DC_STATUS_SUCCESS) { serial_close (device->port); free (device); @@ -340,14 +340,14 @@ oceanic_vtpro_device_open (device_t **out, const char* name) else device->base.layout = &oceanic_vtpro_layout; - *out = (device_t*) device; + *out = (dc_device_t*) device; return DC_STATUS_SUCCESS; } static dc_status_t -oceanic_vtpro_device_close (device_t *abstract) +oceanic_vtpro_device_close (dc_device_t *abstract) { oceanic_vtpro_device_t *device = (oceanic_vtpro_device_t*) abstract; @@ -371,7 +371,7 @@ oceanic_vtpro_device_close (device_t *abstract) dc_status_t -oceanic_vtpro_device_keepalive (device_t *abstract) +oceanic_vtpro_device_keepalive (dc_device_t *abstract) { oceanic_vtpro_device_t *device = (oceanic_vtpro_device_t*) abstract; @@ -396,7 +396,7 @@ oceanic_vtpro_device_keepalive (device_t *abstract) static dc_status_t -oceanic_vtpro_device_version (device_t *abstract, unsigned char data[], unsigned int size) +oceanic_vtpro_device_version (dc_device_t *abstract, unsigned char data[], unsigned int size) { oceanic_vtpro_device_t *device = (oceanic_vtpro_device_t*) abstract; @@ -457,7 +457,7 @@ oceanic_vtpro_device_version (device_t *abstract, unsigned char data[], unsigned static dc_status_t -oceanic_vtpro_device_read (device_t *abstract, unsigned int address, unsigned char data[], unsigned int size) +oceanic_vtpro_device_read (dc_device_t *abstract, unsigned int address, unsigned char data[], unsigned int size) { oceanic_vtpro_device_t *device = (oceanic_vtpro_device_t*) abstract; diff --git a/src/oceanic_vtpro_parser.c b/src/oceanic_vtpro_parser.c index a375566..0db5d5b 100644 --- a/src/oceanic_vtpro_parser.c +++ b/src/oceanic_vtpro_parser.c @@ -32,18 +32,18 @@ typedef struct oceanic_vtpro_parser_t oceanic_vtpro_parser_t; struct oceanic_vtpro_parser_t { - parser_t base; + dc_parser_t base; // Cached fields. unsigned int cached; unsigned int divetime; double maxdepth; }; -static dc_status_t oceanic_vtpro_parser_set_data (parser_t *abstract, const unsigned char *data, unsigned int size); -static dc_status_t oceanic_vtpro_parser_get_datetime (parser_t *abstract, dc_datetime_t *datetime); -static dc_status_t oceanic_vtpro_parser_get_field (parser_t *abstract, parser_field_type_t type, unsigned int flags, void *value); -static dc_status_t oceanic_vtpro_parser_samples_foreach (parser_t *abstract, sample_callback_t callback, void *userdata); -static dc_status_t oceanic_vtpro_parser_destroy (parser_t *abstract); +static dc_status_t oceanic_vtpro_parser_set_data (dc_parser_t *abstract, const unsigned char *data, unsigned int size); +static dc_status_t oceanic_vtpro_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *datetime); +static dc_status_t oceanic_vtpro_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsigned int flags, void *value); +static dc_status_t oceanic_vtpro_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t callback, void *userdata); +static dc_status_t oceanic_vtpro_parser_destroy (dc_parser_t *abstract); static const parser_backend_t oceanic_vtpro_parser_backend = { DC_FAMILY_OCEANIC_VTPRO, @@ -56,7 +56,7 @@ static const parser_backend_t oceanic_vtpro_parser_backend = { static int -parser_is_oceanic_vtpro (parser_t *abstract) +parser_is_oceanic_vtpro (dc_parser_t *abstract) { if (abstract == NULL) return 0; @@ -66,7 +66,7 @@ parser_is_oceanic_vtpro (parser_t *abstract) dc_status_t -oceanic_vtpro_parser_create (parser_t **out) +oceanic_vtpro_parser_create (dc_parser_t **out) { if (out == NULL) return DC_STATUS_INVALIDARGS; @@ -86,14 +86,14 @@ oceanic_vtpro_parser_create (parser_t **out) parser->divetime = 0; parser->maxdepth = 0.0; - *out = (parser_t*) parser; + *out = (dc_parser_t*) parser; return DC_STATUS_SUCCESS; } static dc_status_t -oceanic_vtpro_parser_destroy (parser_t *abstract) +oceanic_vtpro_parser_destroy (dc_parser_t *abstract) { if (! parser_is_oceanic_vtpro (abstract)) return DC_STATUS_INVALIDARGS; @@ -106,7 +106,7 @@ oceanic_vtpro_parser_destroy (parser_t *abstract) static dc_status_t -oceanic_vtpro_parser_set_data (parser_t *abstract, const unsigned char *data, unsigned int size) +oceanic_vtpro_parser_set_data (dc_parser_t *abstract, const unsigned char *data, unsigned int size) { oceanic_vtpro_parser_t *parser = (oceanic_vtpro_parser_t *) abstract; @@ -123,7 +123,7 @@ oceanic_vtpro_parser_set_data (parser_t *abstract, const unsigned char *data, un static dc_status_t -oceanic_vtpro_parser_get_datetime (parser_t *abstract, dc_datetime_t *datetime) +oceanic_vtpro_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *datetime) { if (abstract->size < 8) return DC_STATUS_DATAFORMAT; @@ -154,7 +154,7 @@ oceanic_vtpro_parser_get_datetime (parser_t *abstract, dc_datetime_t *datetime) static dc_status_t -oceanic_vtpro_parser_get_field (parser_t *abstract, parser_field_type_t type, unsigned int flags, void *value) +oceanic_vtpro_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsigned int flags, void *value) { oceanic_vtpro_parser_t *parser = (oceanic_vtpro_parser_t *) abstract; @@ -178,20 +178,20 @@ oceanic_vtpro_parser_get_field (parser_t *abstract, parser_field_type_t type, un unsigned int footer = size - PAGESIZE; - gasmix_t *gasmix = (gasmix_t *) value; + dc_gasmix_t *gasmix = (dc_gasmix_t *) value; if (value) { switch (type) { - case FIELD_TYPE_DIVETIME: + case DC_FIELD_DIVETIME: *((unsigned int *) value) = parser->divetime; break; - case FIELD_TYPE_MAXDEPTH: + case DC_FIELD_MAXDEPTH: *((double *) value) = (data[footer + 0] + ((data[footer + 1] & 0x0F) << 8)) * 1; break; - case FIELD_TYPE_GASMIX_COUNT: + case DC_FIELD_GASMIX_COUNT: *((unsigned int *) value) = 1; break; - case FIELD_TYPE_GASMIX: + case DC_FIELD_GASMIX: gasmix->helium = 0.0; if (data[footer + 3]) gasmix->oxygen = data[footer + 3] / 100.0; @@ -209,7 +209,7 @@ oceanic_vtpro_parser_get_field (parser_t *abstract, parser_field_type_t type, un static dc_status_t -oceanic_vtpro_parser_samples_foreach (parser_t *abstract, sample_callback_t callback, void *userdata) +oceanic_vtpro_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t callback, void *userdata) { if (! parser_is_oceanic_vtpro (abstract)) return DC_STATUS_INVALIDARGS; @@ -245,7 +245,7 @@ oceanic_vtpro_parser_samples_foreach (parser_t *abstract, sample_callback_t call unsigned int offset = 5 * PAGESIZE / 2; while (offset + PAGESIZE / 2 <= size - PAGESIZE) { - parser_sample_value_t sample = {0}; + dc_sample_value_t sample = {0}; // Ignore empty samples. if (array_isequal (data + offset, PAGESIZE / 2, 0x00)) { @@ -312,23 +312,23 @@ oceanic_vtpro_parser_samples_foreach (parser_t *abstract, sample_callback_t call else time = timestamp * 60 + (i + 1) * 60.0 / count + 0.5; sample.time = time; - if (callback) callback (SAMPLE_TYPE_TIME, sample, userdata); + if (callback) callback (DC_SAMPLE_TIME, sample, userdata); // Vendor specific data sample.vendor.type = SAMPLE_VENDOR_OCEANIC_VTPRO; sample.vendor.size = PAGESIZE / 2; sample.vendor.data = data + offset; - if (callback) callback (SAMPLE_TYPE_VENDOR, sample, userdata); + if (callback) callback (DC_SAMPLE_VENDOR, sample, userdata); // Depth (ft) unsigned int depth = data[offset + 3]; sample.depth = depth * FEET; - if (callback) callback (SAMPLE_TYPE_DEPTH, sample, userdata); + if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); // Temperature (°F) unsigned int temperature = data[offset + 6]; sample.temperature = (temperature - 32.0) * (5.0 / 9.0); - if (callback) callback (SAMPLE_TYPE_TEMPERATURE, sample, userdata); + if (callback) callback (DC_SAMPLE_TEMPERATURE, sample, userdata); offset += PAGESIZE / 2; } diff --git a/src/parser-private.h b/src/parser-private.h index dd87918..c8bbf10 100644 --- a/src/parser-private.h +++ b/src/parser-private.h @@ -28,12 +28,12 @@ extern "C" { #endif /* __cplusplus */ -struct parser_t; +struct dc_parser_t; struct parser_backend_t; typedef struct parser_backend_t parser_backend_t; -struct parser_t { +struct dc_parser_t { const parser_backend_t *backend; const unsigned char *data; unsigned int size; @@ -42,19 +42,19 @@ struct parser_t { struct parser_backend_t { dc_family_t type; - dc_status_t (*set_data) (parser_t *parser, const unsigned char *data, unsigned int size); + dc_status_t (*set_data) (dc_parser_t *parser, const unsigned char *data, unsigned int size); - dc_status_t (*datetime) (parser_t *parser, dc_datetime_t *datetime); + dc_status_t (*datetime) (dc_parser_t *parser, dc_datetime_t *datetime); - dc_status_t (*field) (parser_t *parser, parser_field_type_t type, unsigned int flags, void *value); + dc_status_t (*field) (dc_parser_t *parser, dc_field_type_t type, unsigned int flags, void *value); - dc_status_t (*samples_foreach) (parser_t *parser, sample_callback_t callback, void *userdata); + dc_status_t (*samples_foreach) (dc_parser_t *parser, dc_sample_callback_t callback, void *userdata); - dc_status_t (*destroy) (parser_t *parser); + dc_status_t (*destroy) (dc_parser_t *parser); }; void -parser_init (parser_t *parser, const parser_backend_t *backend); +parser_init (dc_parser_t *parser, const parser_backend_t *backend); typedef struct sample_statistics_t { unsigned int divetime; @@ -64,7 +64,7 @@ typedef struct sample_statistics_t { #define SAMPLE_STATISTICS_INITIALIZER {0, 0.0} void -sample_statistics_cb (parser_sample_type_t type, parser_sample_value_t value, void *userdata); +sample_statistics_cb (dc_sample_type_t type, dc_sample_value_t value, void *userdata); #ifdef __cplusplus } diff --git a/src/parser.c b/src/parser.c index 7b1ca84..89007a7 100644 --- a/src/parser.c +++ b/src/parser.c @@ -25,7 +25,7 @@ void -parser_init (parser_t *parser, const parser_backend_t *backend) +parser_init (dc_parser_t *parser, const parser_backend_t *backend) { parser->backend = backend; parser->data = NULL; @@ -34,7 +34,7 @@ parser_init (parser_t *parser, const parser_backend_t *backend) dc_family_t -parser_get_type (parser_t *parser) +dc_parser_get_type (dc_parser_t *parser) { if (parser == NULL) return DC_FAMILY_NULL; @@ -44,7 +44,7 @@ parser_get_type (parser_t *parser) dc_status_t -parser_set_data (parser_t *parser, const unsigned char *data, unsigned int size) +dc_parser_set_data (dc_parser_t *parser, const unsigned char *data, unsigned int size) { if (parser == NULL) return DC_STATUS_UNSUPPORTED; @@ -60,7 +60,7 @@ parser_set_data (parser_t *parser, const unsigned char *data, unsigned int size) dc_status_t -parser_get_datetime (parser_t *parser, dc_datetime_t *datetime) +dc_parser_get_datetime (dc_parser_t *parser, dc_datetime_t *datetime) { if (parser == NULL) return DC_STATUS_UNSUPPORTED; @@ -72,7 +72,7 @@ parser_get_datetime (parser_t *parser, dc_datetime_t *datetime) } dc_status_t -parser_get_field (parser_t *parser, parser_field_type_t type, unsigned int flags, void *value) +dc_parser_get_field (dc_parser_t *parser, dc_field_type_t type, unsigned int flags, void *value) { if (parser == NULL) return DC_STATUS_UNSUPPORTED; @@ -85,7 +85,7 @@ parser_get_field (parser_t *parser, parser_field_type_t type, unsigned int flags dc_status_t -parser_samples_foreach (parser_t *parser, sample_callback_t callback, void *userdata) +dc_parser_samples_foreach (dc_parser_t *parser, dc_sample_callback_t callback, void *userdata) { if (parser == NULL) return DC_STATUS_UNSUPPORTED; @@ -98,7 +98,7 @@ parser_samples_foreach (parser_t *parser, sample_callback_t callback, void *user dc_status_t -parser_destroy (parser_t *parser) +dc_parser_destroy (dc_parser_t *parser) { if (parser == NULL) return DC_STATUS_SUCCESS; @@ -111,15 +111,15 @@ parser_destroy (parser_t *parser) void -sample_statistics_cb (parser_sample_type_t type, parser_sample_value_t value, void *userdata) +sample_statistics_cb (dc_sample_type_t type, dc_sample_value_t value, void *userdata) { sample_statistics_t *statistics = (sample_statistics_t *) userdata; switch (type) { - case SAMPLE_TYPE_TIME: + case DC_SAMPLE_TIME: statistics->divetime = value.time; break; - case SAMPLE_TYPE_DEPTH: + case DC_SAMPLE_DEPTH: if (statistics->maxdepth < value.depth) statistics->maxdepth = value.depth; break; diff --git a/src/reefnet_sensus.c b/src/reefnet_sensus.c index 6633d01..35187df 100644 --- a/src/reefnet_sensus.c +++ b/src/reefnet_sensus.c @@ -36,7 +36,7 @@ ) typedef struct reefnet_sensus_device_t { - device_t base; + dc_device_t base; serial_t *port; unsigned char handshake[REEFNET_SENSUS_HANDSHAKE_SIZE]; unsigned int waiting; @@ -45,10 +45,10 @@ typedef struct reefnet_sensus_device_t { dc_ticks_t systime; } reefnet_sensus_device_t; -static dc_status_t reefnet_sensus_device_set_fingerprint (device_t *abstract, const unsigned char data[], unsigned int size); -static dc_status_t reefnet_sensus_device_dump (device_t *abstract, dc_buffer_t *buffer); -static dc_status_t reefnet_sensus_device_foreach (device_t *abstract, dive_callback_t callback, void *userdata); -static dc_status_t reefnet_sensus_device_close (device_t *abstract); +static dc_status_t reefnet_sensus_device_set_fingerprint (dc_device_t *abstract, const unsigned char data[], unsigned int size); +static dc_status_t reefnet_sensus_device_dump (dc_device_t *abstract, dc_buffer_t *buffer); +static dc_status_t reefnet_sensus_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, void *userdata); +static dc_status_t reefnet_sensus_device_close (dc_device_t *abstract); static const device_backend_t reefnet_sensus_device_backend = { DC_FAMILY_REEFNET_SENSUS, @@ -62,7 +62,7 @@ static const device_backend_t reefnet_sensus_device_backend = { }; static int -device_is_reefnet_sensus (device_t *abstract) +device_is_reefnet_sensus (dc_device_t *abstract) { if (abstract == NULL) return 0; @@ -90,7 +90,7 @@ reefnet_sensus_cancel (reefnet_sensus_device_t *device) dc_status_t -reefnet_sensus_device_open (device_t **out, const char* name) +reefnet_sensus_device_open (dc_device_t **out, const char *name) { if (out == NULL) return DC_STATUS_INVALIDARGS; @@ -141,14 +141,14 @@ reefnet_sensus_device_open (device_t **out, const char* name) // Make sure everything is in a sane state. serial_flush (device->port, SERIAL_QUEUE_BOTH); - *out = (device_t*) device; + *out = (dc_device_t*) device; return DC_STATUS_SUCCESS; } static dc_status_t -reefnet_sensus_device_close (device_t *abstract) +reefnet_sensus_device_close (dc_device_t *abstract) { reefnet_sensus_device_t *device = (reefnet_sensus_device_t*) abstract; @@ -174,7 +174,7 @@ reefnet_sensus_device_close (device_t *abstract) dc_status_t -reefnet_sensus_device_get_handshake (device_t *abstract, unsigned char data[], unsigned int size) +reefnet_sensus_device_get_handshake (dc_device_t *abstract, unsigned char data[], unsigned int size) { reefnet_sensus_device_t *device = (reefnet_sensus_device_t*) abstract; @@ -193,7 +193,7 @@ reefnet_sensus_device_get_handshake (device_t *abstract, unsigned char data[], u dc_status_t -reefnet_sensus_device_set_timestamp (device_t *abstract, unsigned int timestamp) +reefnet_sensus_device_set_timestamp (dc_device_t *abstract, unsigned int timestamp) { reefnet_sensus_device_t *device = (reefnet_sensus_device_t*) abstract; @@ -207,7 +207,7 @@ reefnet_sensus_device_set_timestamp (device_t *abstract, unsigned int timestamp) static dc_status_t -reefnet_sensus_device_set_fingerprint (device_t *abstract, const unsigned char data[], unsigned int size) +reefnet_sensus_device_set_fingerprint (dc_device_t *abstract, const unsigned char data[], unsigned int size) { reefnet_sensus_device_t *device = (reefnet_sensus_device_t*) abstract; @@ -262,17 +262,17 @@ reefnet_sensus_handshake (reefnet_sensus_device_t *device) memcpy (device->handshake, handshake + 2, REEFNET_SENSUS_HANDSHAKE_SIZE); // Emit a clock event. - device_clock_t clock; + dc_event_clock_t clock; clock.systime = device->systime; clock.devtime = device->devtime; - device_event_emit (&device->base, DEVICE_EVENT_CLOCK, &clock); + device_event_emit (&device->base, DC_EVENT_CLOCK, &clock); // Emit a device info event. - device_devinfo_t devinfo; + dc_event_devinfo_t devinfo; devinfo.model = handshake[2] - '0'; devinfo.firmware = handshake[3] - '0'; devinfo.serial = array_uint16_le (handshake + 6); - device_event_emit (&device->base, DEVICE_EVENT_DEVINFO, &devinfo); + device_event_emit (&device->base, DC_EVENT_DEVINFO, &devinfo); // Wait at least 10 ms to ensures the data line is // clear before transmission from the host begins. @@ -284,7 +284,7 @@ reefnet_sensus_handshake (reefnet_sensus_device_t *device) static dc_status_t -reefnet_sensus_device_dump (device_t *abstract, dc_buffer_t *buffer) +reefnet_sensus_device_dump (dc_device_t *abstract, dc_buffer_t *buffer) { reefnet_sensus_device_t *device = (reefnet_sensus_device_t*) abstract; @@ -299,9 +299,9 @@ reefnet_sensus_device_dump (device_t *abstract, dc_buffer_t *buffer) } // Enable progress notifications. - device_progress_t progress = DEVICE_PROGRESS_INITIALIZER; + dc_event_progress_t progress = EVENT_PROGRESS_INITIALIZER; progress.maximum = 4 + REEFNET_SENSUS_MEMORY_SIZE + 2 + 3; - device_event_emit (abstract, DEVICE_EVENT_PROGRESS, &progress); + device_event_emit (abstract, DC_EVENT_PROGRESS, &progress); // Wake-up the device. dc_status_t rc = reefnet_sensus_handshake (device); @@ -335,7 +335,7 @@ reefnet_sensus_device_dump (device_t *abstract, dc_buffer_t *buffer) // Update and emit a progress event. progress.current += len; - device_event_emit (abstract, DEVICE_EVENT_PROGRESS, &progress); + device_event_emit (abstract, DC_EVENT_PROGRESS, &progress); nbytes += len; } @@ -362,7 +362,7 @@ reefnet_sensus_device_dump (device_t *abstract, dc_buffer_t *buffer) static dc_status_t -reefnet_sensus_device_foreach (device_t *abstract, dive_callback_t callback, void *userdata) +reefnet_sensus_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, void *userdata) { if (! device_is_reefnet_sensus (abstract)) return DC_STATUS_INVALIDARGS; @@ -387,7 +387,7 @@ reefnet_sensus_device_foreach (device_t *abstract, dive_callback_t callback, voi dc_status_t -reefnet_sensus_extract_dives (device_t *abstract, const unsigned char data[], unsigned int size, dive_callback_t callback, void *userdata) +reefnet_sensus_extract_dives (dc_device_t *abstract, const unsigned char data[], unsigned int size, dc_dive_callback_t callback, void *userdata) { reefnet_sensus_device_t *device = (reefnet_sensus_device_t*) abstract; diff --git a/src/reefnet_sensus_parser.c b/src/reefnet_sensus_parser.c index 8282c74..3afcfc5 100644 --- a/src/reefnet_sensus_parser.c +++ b/src/reefnet_sensus_parser.c @@ -33,7 +33,7 @@ typedef struct reefnet_sensus_parser_t reefnet_sensus_parser_t; struct reefnet_sensus_parser_t { - parser_t base; + dc_parser_t base; // Depth calibration. double atmospheric; double hydrostatic; @@ -46,11 +46,11 @@ struct reefnet_sensus_parser_t { unsigned int maxdepth; }; -static dc_status_t reefnet_sensus_parser_set_data (parser_t *abstract, const unsigned char *data, unsigned int size); -static dc_status_t reefnet_sensus_parser_get_datetime (parser_t *abstract, dc_datetime_t *datetime); -static dc_status_t reefnet_sensus_parser_get_field (parser_t *abstract, parser_field_type_t type, unsigned int flags, void *value); -static dc_status_t reefnet_sensus_parser_samples_foreach (parser_t *abstract, sample_callback_t callback, void *userdata); -static dc_status_t reefnet_sensus_parser_destroy (parser_t *abstract); +static dc_status_t reefnet_sensus_parser_set_data (dc_parser_t *abstract, const unsigned char *data, unsigned int size); +static dc_status_t reefnet_sensus_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *datetime); +static dc_status_t reefnet_sensus_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsigned int flags, void *value); +static dc_status_t reefnet_sensus_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t callback, void *userdata); +static dc_status_t reefnet_sensus_parser_destroy (dc_parser_t *abstract); static const parser_backend_t reefnet_sensus_parser_backend = { DC_FAMILY_REEFNET_SENSUS, @@ -63,7 +63,7 @@ static const parser_backend_t reefnet_sensus_parser_backend = { static int -parser_is_reefnet_sensus (parser_t *abstract) +parser_is_reefnet_sensus (dc_parser_t *abstract) { if (abstract == NULL) return 0; @@ -73,7 +73,7 @@ parser_is_reefnet_sensus (parser_t *abstract) dc_status_t -reefnet_sensus_parser_create (parser_t **out, unsigned int devtime, dc_ticks_t systime) +reefnet_sensus_parser_create (dc_parser_t **out, unsigned int devtime, dc_ticks_t systime) { if (out == NULL) return DC_STATUS_INVALIDARGS; @@ -97,14 +97,14 @@ reefnet_sensus_parser_create (parser_t **out, unsigned int devtime, dc_ticks_t s parser->divetime = 0; parser->maxdepth = 0; - *out = (parser_t*) parser; + *out = (dc_parser_t*) parser; return DC_STATUS_SUCCESS; } static dc_status_t -reefnet_sensus_parser_destroy (parser_t *abstract) +reefnet_sensus_parser_destroy (dc_parser_t *abstract) { if (! parser_is_reefnet_sensus (abstract)) return DC_STATUS_INVALIDARGS; @@ -117,7 +117,7 @@ reefnet_sensus_parser_destroy (parser_t *abstract) static dc_status_t -reefnet_sensus_parser_set_data (parser_t *abstract, const unsigned char *data, unsigned int size) +reefnet_sensus_parser_set_data (dc_parser_t *abstract, const unsigned char *data, unsigned int size) { reefnet_sensus_parser_t *parser = (reefnet_sensus_parser_t*) abstract; @@ -134,7 +134,7 @@ reefnet_sensus_parser_set_data (parser_t *abstract, const unsigned char *data, u dc_status_t -reefnet_sensus_parser_set_calibration (parser_t *abstract, double atmospheric, double hydrostatic) +reefnet_sensus_parser_set_calibration (dc_parser_t *abstract, double atmospheric, double hydrostatic) { reefnet_sensus_parser_t *parser = (reefnet_sensus_parser_t*) abstract; @@ -149,7 +149,7 @@ reefnet_sensus_parser_set_calibration (parser_t *abstract, double atmospheric, d static dc_status_t -reefnet_sensus_parser_get_datetime (parser_t *abstract, dc_datetime_t *datetime) +reefnet_sensus_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *datetime) { reefnet_sensus_parser_t *parser = (reefnet_sensus_parser_t *) abstract; @@ -168,7 +168,7 @@ reefnet_sensus_parser_get_datetime (parser_t *abstract, dc_datetime_t *datetime) static dc_status_t -reefnet_sensus_parser_get_field (parser_t *abstract, parser_field_type_t type, unsigned int flags, void *value) +reefnet_sensus_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsigned int flags, void *value) { reefnet_sensus_parser_t *parser = (reefnet_sensus_parser_t *) abstract; @@ -216,13 +216,13 @@ reefnet_sensus_parser_get_field (parser_t *abstract, parser_field_type_t type, u if (value) { switch (type) { - case FIELD_TYPE_DIVETIME: + case DC_FIELD_DIVETIME: *((unsigned int *) value) = parser->divetime; break; - case FIELD_TYPE_MAXDEPTH: + case DC_FIELD_MAXDEPTH: *((double *) value) = ((parser->maxdepth + 33.0 - (double) SAMPLE_DEPTH_ADJUST) * FSW - parser->atmospheric) / parser->hydrostatic; break; - case FIELD_TYPE_GASMIX_COUNT: + case DC_FIELD_GASMIX_COUNT: *((unsigned int *) value) = 0; break; default: @@ -235,7 +235,7 @@ reefnet_sensus_parser_get_field (parser_t *abstract, parser_field_type_t type, u static dc_status_t -reefnet_sensus_parser_samples_foreach (parser_t *abstract, sample_callback_t callback, void *userdata) +reefnet_sensus_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t callback, void *userdata) { reefnet_sensus_parser_t *parser = (reefnet_sensus_parser_t*) abstract; @@ -255,17 +255,17 @@ reefnet_sensus_parser_samples_foreach (parser_t *abstract, sample_callback_t cal offset += 7; while (offset + 1 <= size) { - parser_sample_value_t sample = {0}; + dc_sample_value_t sample = {0}; // Time (seconds) time += interval; sample.time = time; - if (callback) callback (SAMPLE_TYPE_TIME, sample, userdata); + if (callback) callback (DC_SAMPLE_TIME, sample, userdata); // Depth (adjusted feet of seawater). unsigned int depth = data[offset++]; sample.depth = ((depth + 33.0 - (double) SAMPLE_DEPTH_ADJUST) * FSW - parser->atmospheric) / parser->hydrostatic; - if (callback) callback (SAMPLE_TYPE_DEPTH, sample, userdata); + if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); // Temperature (degrees Fahrenheit) if ((nsamples % 6) == 0) { @@ -273,7 +273,7 @@ reefnet_sensus_parser_samples_foreach (parser_t *abstract, sample_callback_t cal return DC_STATUS_DATAFORMAT; unsigned int temperature = data[offset++]; sample.temperature = (temperature - 32.0) * (5.0 / 9.0); - if (callback) callback (SAMPLE_TYPE_TEMPERATURE, sample, userdata); + if (callback) callback (DC_SAMPLE_TEMPERATURE, sample, userdata); } // Current sample is complete. diff --git a/src/reefnet_sensuspro.c b/src/reefnet_sensuspro.c index 1a0a94d..210f147 100644 --- a/src/reefnet_sensuspro.c +++ b/src/reefnet_sensuspro.c @@ -36,7 +36,7 @@ ) typedef struct reefnet_sensuspro_device_t { - device_t base; + dc_device_t base; serial_t *port; unsigned char handshake[REEFNET_SENSUSPRO_HANDSHAKE_SIZE]; unsigned int timestamp; @@ -44,10 +44,10 @@ typedef struct reefnet_sensuspro_device_t { dc_ticks_t systime; } reefnet_sensuspro_device_t; -static dc_status_t reefnet_sensuspro_device_set_fingerprint (device_t *abstract, const unsigned char data[], unsigned int size); -static dc_status_t reefnet_sensuspro_device_dump (device_t *abstract, dc_buffer_t *buffer); -static dc_status_t reefnet_sensuspro_device_foreach (device_t *abstract, dive_callback_t callback, void *userdata); -static dc_status_t reefnet_sensuspro_device_close (device_t *abstract); +static dc_status_t reefnet_sensuspro_device_set_fingerprint (dc_device_t *abstract, const unsigned char data[], unsigned int size); +static dc_status_t reefnet_sensuspro_device_dump (dc_device_t *abstract, dc_buffer_t *buffer); +static dc_status_t reefnet_sensuspro_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, void *userdata); +static dc_status_t reefnet_sensuspro_device_close (dc_device_t *abstract); static const device_backend_t reefnet_sensuspro_device_backend = { DC_FAMILY_REEFNET_SENSUSPRO, @@ -61,7 +61,7 @@ static const device_backend_t reefnet_sensuspro_device_backend = { }; static int -device_is_reefnet_sensuspro (device_t *abstract) +device_is_reefnet_sensuspro (dc_device_t *abstract) { if (abstract == NULL) return 0; @@ -71,7 +71,7 @@ device_is_reefnet_sensuspro (device_t *abstract) dc_status_t -reefnet_sensuspro_device_open (device_t **out, const char* name) +reefnet_sensuspro_device_open (dc_device_t **out, const char *name) { if (out == NULL) return DC_STATUS_INVALIDARGS; @@ -121,14 +121,14 @@ reefnet_sensuspro_device_open (device_t **out, const char* name) // Make sure everything is in a sane state. serial_flush (device->port, SERIAL_QUEUE_BOTH); - *out = (device_t*) device; + *out = (dc_device_t*) device; return DC_STATUS_SUCCESS; } static dc_status_t -reefnet_sensuspro_device_close (device_t *abstract) +reefnet_sensuspro_device_close (dc_device_t *abstract) { reefnet_sensuspro_device_t *device = (reefnet_sensuspro_device_t*) abstract; @@ -149,7 +149,7 @@ reefnet_sensuspro_device_close (device_t *abstract) dc_status_t -reefnet_sensuspro_device_get_handshake (device_t *abstract, unsigned char data[], unsigned int size) +reefnet_sensuspro_device_get_handshake (dc_device_t *abstract, unsigned char data[], unsigned int size) { reefnet_sensuspro_device_t *device = (reefnet_sensuspro_device_t*) abstract; @@ -168,7 +168,7 @@ reefnet_sensuspro_device_get_handshake (device_t *abstract, unsigned char data[] dc_status_t -reefnet_sensuspro_device_set_timestamp (device_t *abstract, unsigned int timestamp) +reefnet_sensuspro_device_set_timestamp (dc_device_t *abstract, unsigned int timestamp) { reefnet_sensuspro_device_t *device = (reefnet_sensuspro_device_t*) abstract; @@ -182,7 +182,7 @@ reefnet_sensuspro_device_set_timestamp (device_t *abstract, unsigned int timesta static dc_status_t -reefnet_sensuspro_device_set_fingerprint (device_t *abstract, const unsigned char data[], unsigned int size) +reefnet_sensuspro_device_set_fingerprint (dc_device_t *abstract, const unsigned char data[], unsigned int size) { reefnet_sensuspro_device_t *device = (reefnet_sensuspro_device_t*) abstract; @@ -234,17 +234,17 @@ reefnet_sensuspro_handshake (reefnet_sensuspro_device_t *device) memcpy (device->handshake, handshake, REEFNET_SENSUSPRO_HANDSHAKE_SIZE); // Emit a clock event. - device_clock_t clock; + dc_event_clock_t clock; clock.systime = device->systime; clock.devtime = device->devtime; - device_event_emit (&device->base, DEVICE_EVENT_CLOCK, &clock); + device_event_emit (&device->base, DC_EVENT_CLOCK, &clock); // Emit a device info event. - device_devinfo_t devinfo; + dc_event_devinfo_t devinfo; devinfo.model = handshake[0]; devinfo.firmware = handshake[1]; devinfo.serial = array_uint16_le (handshake + 4); - device_event_emit (&device->base, DEVICE_EVENT_DEVINFO, &devinfo); + device_event_emit (&device->base, DC_EVENT_DEVINFO, &devinfo); serial_sleep (10); @@ -272,7 +272,7 @@ reefnet_sensuspro_send (reefnet_sensuspro_device_t *device, unsigned char comman static dc_status_t -reefnet_sensuspro_device_dump (device_t *abstract, dc_buffer_t *buffer) +reefnet_sensuspro_device_dump (dc_device_t *abstract, dc_buffer_t *buffer) { reefnet_sensuspro_device_t *device = (reefnet_sensuspro_device_t*) abstract; @@ -287,9 +287,9 @@ reefnet_sensuspro_device_dump (device_t *abstract, dc_buffer_t *buffer) } // Enable progress notifications. - device_progress_t progress = DEVICE_PROGRESS_INITIALIZER; + dc_event_progress_t progress = EVENT_PROGRESS_INITIALIZER; progress.maximum = REEFNET_SENSUSPRO_MEMORY_SIZE + 2; - device_event_emit (abstract, DEVICE_EVENT_PROGRESS, &progress); + device_event_emit (abstract, DC_EVENT_PROGRESS, &progress); // Wake-up the device and send the instruction code. dc_status_t rc = reefnet_sensuspro_send (device, 0xB4); @@ -311,7 +311,7 @@ reefnet_sensuspro_device_dump (device_t *abstract, dc_buffer_t *buffer) // Update and emit a progress event. progress.current += len; - device_event_emit (abstract, DEVICE_EVENT_PROGRESS, &progress); + device_event_emit (abstract, DC_EVENT_PROGRESS, &progress); nbytes += len; } @@ -330,7 +330,7 @@ reefnet_sensuspro_device_dump (device_t *abstract, dc_buffer_t *buffer) static dc_status_t -reefnet_sensuspro_device_foreach (device_t *abstract, dive_callback_t callback, void *userdata) +reefnet_sensuspro_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, void *userdata) { if (! device_is_reefnet_sensuspro (abstract)) return DC_STATUS_INVALIDARGS; @@ -355,7 +355,7 @@ reefnet_sensuspro_device_foreach (device_t *abstract, dive_callback_t callback, dc_status_t -reefnet_sensuspro_device_write_interval (device_t *abstract, unsigned char interval) +reefnet_sensuspro_device_write_interval (dc_device_t *abstract, unsigned char interval) { reefnet_sensuspro_device_t *device = (reefnet_sensuspro_device_t*) abstract; @@ -383,7 +383,7 @@ reefnet_sensuspro_device_write_interval (device_t *abstract, unsigned char inter dc_status_t -reefnet_sensuspro_extract_dives (device_t *abstract, const unsigned char data[], unsigned int size, dive_callback_t callback, void *userdata) +reefnet_sensuspro_extract_dives (dc_device_t *abstract, const unsigned char data[], unsigned int size, dc_dive_callback_t callback, void *userdata) { reefnet_sensuspro_device_t *device = (reefnet_sensuspro_device_t*) abstract; diff --git a/src/reefnet_sensuspro_parser.c b/src/reefnet_sensuspro_parser.c index 23770b3..cf14296 100644 --- a/src/reefnet_sensuspro_parser.c +++ b/src/reefnet_sensuspro_parser.c @@ -32,7 +32,7 @@ typedef struct reefnet_sensuspro_parser_t reefnet_sensuspro_parser_t; struct reefnet_sensuspro_parser_t { - parser_t base; + dc_parser_t base; // Depth calibration. double atmospheric; double hydrostatic; @@ -45,11 +45,11 @@ struct reefnet_sensuspro_parser_t { unsigned int maxdepth; }; -static dc_status_t reefnet_sensuspro_parser_set_data (parser_t *abstract, const unsigned char *data, unsigned int size); -static dc_status_t reefnet_sensuspro_parser_get_datetime (parser_t *abstract, dc_datetime_t *datetime); -static dc_status_t reefnet_sensuspro_parser_get_field (parser_t *abstract, parser_field_type_t type, unsigned int flags, void *value); -static dc_status_t reefnet_sensuspro_parser_samples_foreach (parser_t *abstract, sample_callback_t callback, void *userdata); -static dc_status_t reefnet_sensuspro_parser_destroy (parser_t *abstract); +static dc_status_t reefnet_sensuspro_parser_set_data (dc_parser_t *abstract, const unsigned char *data, unsigned int size); +static dc_status_t reefnet_sensuspro_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *datetime); +static dc_status_t reefnet_sensuspro_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsigned int flags, void *value); +static dc_status_t reefnet_sensuspro_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t callback, void *userdata); +static dc_status_t reefnet_sensuspro_parser_destroy (dc_parser_t *abstract); static const parser_backend_t reefnet_sensuspro_parser_backend = { DC_FAMILY_REEFNET_SENSUSPRO, @@ -62,7 +62,7 @@ static const parser_backend_t reefnet_sensuspro_parser_backend = { static int -parser_is_reefnet_sensuspro (parser_t *abstract) +parser_is_reefnet_sensuspro (dc_parser_t *abstract) { if (abstract == NULL) return 0; @@ -72,7 +72,7 @@ parser_is_reefnet_sensuspro (parser_t *abstract) dc_status_t -reefnet_sensuspro_parser_create (parser_t **out, unsigned int devtime, dc_ticks_t systime) +reefnet_sensuspro_parser_create (dc_parser_t **out, unsigned int devtime, dc_ticks_t systime) { if (out == NULL) return DC_STATUS_INVALIDARGS; @@ -96,14 +96,14 @@ reefnet_sensuspro_parser_create (parser_t **out, unsigned int devtime, dc_ticks_ parser->divetime = 0; parser->maxdepth = 0; - *out = (parser_t*) parser; + *out = (dc_parser_t*) parser; return DC_STATUS_SUCCESS; } static dc_status_t -reefnet_sensuspro_parser_destroy (parser_t *abstract) +reefnet_sensuspro_parser_destroy (dc_parser_t *abstract) { if (! parser_is_reefnet_sensuspro (abstract)) return DC_STATUS_INVALIDARGS; @@ -116,7 +116,7 @@ reefnet_sensuspro_parser_destroy (parser_t *abstract) static dc_status_t -reefnet_sensuspro_parser_set_data (parser_t *abstract, const unsigned char *data, unsigned int size) +reefnet_sensuspro_parser_set_data (dc_parser_t *abstract, const unsigned char *data, unsigned int size) { reefnet_sensuspro_parser_t *parser = (reefnet_sensuspro_parser_t*) abstract; @@ -133,7 +133,7 @@ reefnet_sensuspro_parser_set_data (parser_t *abstract, const unsigned char *data dc_status_t -reefnet_sensuspro_parser_set_calibration (parser_t *abstract, double atmospheric, double hydrostatic) +reefnet_sensuspro_parser_set_calibration (dc_parser_t *abstract, double atmospheric, double hydrostatic) { reefnet_sensuspro_parser_t *parser = (reefnet_sensuspro_parser_t*) abstract; @@ -148,7 +148,7 @@ reefnet_sensuspro_parser_set_calibration (parser_t *abstract, double atmospheric static dc_status_t -reefnet_sensuspro_parser_get_datetime (parser_t *abstract, dc_datetime_t *datetime) +reefnet_sensuspro_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *datetime) { reefnet_sensuspro_parser_t *parser = (reefnet_sensuspro_parser_t *) abstract; @@ -167,7 +167,7 @@ reefnet_sensuspro_parser_get_datetime (parser_t *abstract, dc_datetime_t *dateti static dc_status_t -reefnet_sensuspro_parser_get_field (parser_t *abstract, parser_field_type_t type, unsigned int flags, void *value) +reefnet_sensuspro_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsigned int flags, void *value) { reefnet_sensuspro_parser_t *parser = (reefnet_sensuspro_parser_t *) abstract; @@ -205,13 +205,13 @@ reefnet_sensuspro_parser_get_field (parser_t *abstract, parser_field_type_t type if (value) { switch (type) { - case FIELD_TYPE_DIVETIME: + case DC_FIELD_DIVETIME: *((unsigned int *) value) = parser->divetime; break; - case FIELD_TYPE_MAXDEPTH: + case DC_FIELD_MAXDEPTH: *((double *) value) = (parser->maxdepth * FSW - parser->atmospheric) / parser->hydrostatic; break; - case FIELD_TYPE_GASMIX_COUNT: + case DC_FIELD_GASMIX_COUNT: *((unsigned int *) value) = 0; break; default: @@ -224,7 +224,7 @@ reefnet_sensuspro_parser_get_field (parser_t *abstract, parser_field_type_t type static dc_status_t -reefnet_sensuspro_parser_samples_foreach (parser_t *abstract, sample_callback_t callback, void *userdata) +reefnet_sensuspro_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t callback, void *userdata) { reefnet_sensuspro_parser_t *parser = (reefnet_sensuspro_parser_t*) abstract; @@ -254,20 +254,20 @@ reefnet_sensuspro_parser_samples_foreach (parser_t *abstract, sample_callback_t unsigned int depth = (value & 0x01FF); unsigned int temperature = (value & 0xFE00) >> 9; - parser_sample_value_t sample = {0}; + dc_sample_value_t sample = {0}; // Time (seconds) time += interval; sample.time = time; - if (callback) callback (SAMPLE_TYPE_TIME, sample, userdata); + if (callback) callback (DC_SAMPLE_TIME, sample, userdata); // Temperature (°F) sample.temperature = (temperature - 32.0) * (5.0 / 9.0); - if (callback) callback (SAMPLE_TYPE_TEMPERATURE, sample, userdata); + if (callback) callback (DC_SAMPLE_TEMPERATURE, sample, userdata); // Depth (absolute pressure in fsw) sample.depth = (depth * FSW - parser->atmospheric) / parser->hydrostatic; - if (callback) callback (SAMPLE_TYPE_DEPTH, sample, userdata); + if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); offset += 2; } diff --git a/src/reefnet_sensusultra.c b/src/reefnet_sensusultra.c index 3d8ec5e..7a53ecf 100644 --- a/src/reefnet_sensusultra.c +++ b/src/reefnet_sensusultra.c @@ -41,7 +41,7 @@ #define REJECT 0x00 typedef struct reefnet_sensusultra_device_t { - device_t base; + dc_device_t base; serial_t *port; unsigned char handshake[REEFNET_SENSUSULTRA_HANDSHAKE_SIZE]; unsigned int maxretries; @@ -50,10 +50,10 @@ typedef struct reefnet_sensusultra_device_t { dc_ticks_t systime; } reefnet_sensusultra_device_t; -static dc_status_t reefnet_sensusultra_device_set_fingerprint (device_t *abstract, const unsigned char data[], unsigned int size); -static dc_status_t reefnet_sensusultra_device_dump (device_t *abstract, dc_buffer_t *buffer); -static dc_status_t reefnet_sensusultra_device_foreach (device_t *abstract, dive_callback_t callback, void *userdata); -static dc_status_t reefnet_sensusultra_device_close (device_t *abstract); +static dc_status_t reefnet_sensusultra_device_set_fingerprint (dc_device_t *abstract, const unsigned char data[], unsigned int size); +static dc_status_t reefnet_sensusultra_device_dump (dc_device_t *abstract, dc_buffer_t *buffer); +static dc_status_t reefnet_sensusultra_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, void *userdata); +static dc_status_t reefnet_sensusultra_device_close (dc_device_t *abstract); static const device_backend_t reefnet_sensusultra_device_backend = { DC_FAMILY_REEFNET_SENSUSULTRA, @@ -67,7 +67,7 @@ static const device_backend_t reefnet_sensusultra_device_backend = { }; static int -device_is_reefnet_sensusultra (device_t *abstract) +device_is_reefnet_sensusultra (dc_device_t *abstract) { if (abstract == NULL) return 0; @@ -77,7 +77,7 @@ device_is_reefnet_sensusultra (device_t *abstract) dc_status_t -reefnet_sensusultra_device_open (device_t **out, const char* name) +reefnet_sensusultra_device_open (dc_device_t **out, const char *name) { if (out == NULL) return DC_STATUS_INVALIDARGS; @@ -128,14 +128,14 @@ reefnet_sensusultra_device_open (device_t **out, const char* name) // Make sure everything is in a sane state. serial_flush (device->port, SERIAL_QUEUE_BOTH); - *out = (device_t*) device; + *out = (dc_device_t*) device; return DC_STATUS_SUCCESS; } static dc_status_t -reefnet_sensusultra_device_close (device_t *abstract) +reefnet_sensusultra_device_close (dc_device_t *abstract) { reefnet_sensusultra_device_t *device = (reefnet_sensusultra_device_t*) abstract; @@ -156,7 +156,7 @@ reefnet_sensusultra_device_close (device_t *abstract) dc_status_t -reefnet_sensusultra_device_get_handshake (device_t *abstract, unsigned char data[], unsigned int size) +reefnet_sensusultra_device_get_handshake (dc_device_t *abstract, unsigned char data[], unsigned int size) { reefnet_sensusultra_device_t *device = (reefnet_sensusultra_device_t*) abstract; @@ -175,7 +175,7 @@ reefnet_sensusultra_device_get_handshake (device_t *abstract, unsigned char data dc_status_t -reefnet_sensusultra_device_set_maxretries (device_t *abstract, unsigned int maxretries) +reefnet_sensusultra_device_set_maxretries (dc_device_t *abstract, unsigned int maxretries) { reefnet_sensusultra_device_t *device = (reefnet_sensusultra_device_t*) abstract; @@ -189,7 +189,7 @@ reefnet_sensusultra_device_set_maxretries (device_t *abstract, unsigned int maxr dc_status_t -reefnet_sensusultra_device_set_timestamp (device_t *abstract, unsigned int timestamp) +reefnet_sensusultra_device_set_timestamp (dc_device_t *abstract, unsigned int timestamp) { reefnet_sensusultra_device_t *device = (reefnet_sensusultra_device_t*) abstract; @@ -203,7 +203,7 @@ reefnet_sensusultra_device_set_timestamp (device_t *abstract, unsigned int times static dc_status_t -reefnet_sensusultra_device_set_fingerprint (device_t *abstract, const unsigned char data[], unsigned int size) +reefnet_sensusultra_device_set_fingerprint (dc_device_t *abstract, const unsigned char data[], unsigned int size) { reefnet_sensusultra_device_t *device = (reefnet_sensusultra_device_t*) abstract; @@ -274,7 +274,7 @@ reefnet_sensusultra_packet (reefnet_sensusultra_device_t *device, unsigned char { assert (size >= header + 2); - device_t *abstract = (device_t *) device; + dc_device_t *abstract = (dc_device_t *) device; if (device_is_cancelled (abstract)) return DC_STATUS_CANCELLED; @@ -315,17 +315,17 @@ reefnet_sensusultra_handshake (reefnet_sensusultra_device_t *device, unsigned sh memcpy (device->handshake, handshake, REEFNET_SENSUSULTRA_HANDSHAKE_SIZE); // Emit a clock event. - device_clock_t clock; + dc_event_clock_t clock; clock.systime = device->systime; clock.devtime = device->devtime; - device_event_emit (&device->base, DEVICE_EVENT_CLOCK, &clock); + device_event_emit (&device->base, DC_EVENT_CLOCK, &clock); // Emit a device info event. - device_devinfo_t devinfo; + dc_event_devinfo_t devinfo; devinfo.model = handshake[1]; devinfo.firmware = handshake[0]; devinfo.serial = array_uint16_le (handshake + 2); - device_event_emit (&device->base, DEVICE_EVENT_DEVINFO, &devinfo); + device_event_emit (&device->base, DC_EVENT_DEVINFO, &devinfo); // Send the instruction code to the device. rc = reefnet_sensusultra_send_ushort (device, value); @@ -403,7 +403,7 @@ reefnet_sensusultra_send (reefnet_sensusultra_device_t *device, unsigned short c static dc_status_t -reefnet_sensusultra_device_dump (device_t *abstract, dc_buffer_t *buffer) +reefnet_sensusultra_device_dump (dc_device_t *abstract, dc_buffer_t *buffer) { reefnet_sensusultra_device_t *device = (reefnet_sensusultra_device_t*) abstract; @@ -418,9 +418,9 @@ reefnet_sensusultra_device_dump (device_t *abstract, dc_buffer_t *buffer) } // Enable progress notifications. - device_progress_t progress = DEVICE_PROGRESS_INITIALIZER; + dc_event_progress_t progress = EVENT_PROGRESS_INITIALIZER; progress.maximum = REEFNET_SENSUSULTRA_MEMORY_DATA_SIZE; - device_event_emit (abstract, DEVICE_EVENT_PROGRESS, &progress); + device_event_emit (abstract, DC_EVENT_PROGRESS, &progress); // Wake-up the device and send the instruction code. dc_status_t rc = reefnet_sensusultra_send (device, 0xB421); @@ -438,7 +438,7 @@ reefnet_sensusultra_device_dump (device_t *abstract, dc_buffer_t *buffer) // Update and emit a progress event. progress.current += REEFNET_SENSUSULTRA_PACKET_SIZE; - device_event_emit (abstract, DEVICE_EVENT_PROGRESS, &progress); + device_event_emit (abstract, DC_EVENT_PROGRESS, &progress); // Prepend the packet to the buffer. if (!dc_buffer_prepend (buffer, packet + 2, REEFNET_SENSUSULTRA_PACKET_SIZE)) { @@ -460,7 +460,7 @@ reefnet_sensusultra_device_dump (device_t *abstract, dc_buffer_t *buffer) dc_status_t -reefnet_sensusultra_device_read_user (device_t *abstract, unsigned char *data, unsigned int size) +reefnet_sensusultra_device_read_user (dc_device_t *abstract, unsigned char *data, unsigned int size) { reefnet_sensusultra_device_t *device = (reefnet_sensusultra_device_t*) abstract; @@ -503,7 +503,7 @@ reefnet_sensusultra_device_read_user (device_t *abstract, unsigned char *data, u dc_status_t -reefnet_sensusultra_device_write_user (device_t *abstract, const unsigned char *data, unsigned int size) +reefnet_sensusultra_device_write_user (dc_device_t *abstract, const unsigned char *data, unsigned int size) { reefnet_sensusultra_device_t *device = (reefnet_sensusultra_device_t*) abstract; @@ -516,9 +516,9 @@ reefnet_sensusultra_device_write_user (device_t *abstract, const unsigned char * } // Enable progress notifications. - device_progress_t progress = DEVICE_PROGRESS_INITIALIZER; + dc_event_progress_t progress = EVENT_PROGRESS_INITIALIZER; progress.maximum = REEFNET_SENSUSULTRA_MEMORY_USER_SIZE + 2; - device_event_emit (abstract, DEVICE_EVENT_PROGRESS, &progress); + device_event_emit (abstract, DC_EVENT_PROGRESS, &progress); // Wake-up the device and send the instruction code. dc_status_t rc = reefnet_sensusultra_send (device, 0xB430); @@ -533,7 +533,7 @@ reefnet_sensusultra_device_write_user (device_t *abstract, const unsigned char * // Update and emit a progress event. progress.current += 1; - device_event_emit (abstract, DEVICE_EVENT_PROGRESS, &progress); + device_event_emit (abstract, DC_EVENT_PROGRESS, &progress); } // Send the checksum to the device. @@ -544,14 +544,14 @@ reefnet_sensusultra_device_write_user (device_t *abstract, const unsigned char * // Update and emit a progress event. progress.current += 2; - device_event_emit (abstract, DEVICE_EVENT_PROGRESS, &progress); + device_event_emit (abstract, DC_EVENT_PROGRESS, &progress); return DC_STATUS_SUCCESS; } dc_status_t -reefnet_sensusultra_device_write_parameter (device_t *abstract, reefnet_sensusultra_parameter_t parameter, unsigned int value) +reefnet_sensusultra_device_write_parameter (dc_device_t *abstract, reefnet_sensusultra_parameter_t parameter, unsigned int value) { reefnet_sensusultra_device_t *device = (reefnet_sensusultra_device_t*) abstract; @@ -600,7 +600,7 @@ reefnet_sensusultra_device_write_parameter (device_t *abstract, reefnet_sensusul dc_status_t -reefnet_sensusultra_device_sense (device_t *abstract, unsigned char *data, unsigned int size) +reefnet_sensusultra_device_sense (dc_device_t *abstract, unsigned char *data, unsigned int size) { reefnet_sensusultra_device_t *device = (reefnet_sensusultra_device_t*) abstract; @@ -632,7 +632,7 @@ reefnet_sensusultra_device_sense (device_t *abstract, unsigned char *data, unsig static dc_status_t reefnet_sensusultra_parse (reefnet_sensusultra_device_t *device, const unsigned char data[], unsigned int *premaining, unsigned int *pprevious, - int *aborted, dive_callback_t callback, void *userdata) + int *aborted, dc_dive_callback_t callback, void *userdata) { const unsigned char header[4] = {0x00, 0x00, 0x00, 0x00}; const unsigned char footer[4] = {0xFF, 0xFF, 0xFF, 0xFF}; @@ -700,7 +700,7 @@ reefnet_sensusultra_parse (reefnet_sensusultra_device_t *device, static dc_status_t -reefnet_sensusultra_device_foreach (device_t *abstract, dive_callback_t callback, void *userdata) +reefnet_sensusultra_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, void *userdata) { reefnet_sensusultra_device_t *device = (reefnet_sensusultra_device_t*) abstract; @@ -714,9 +714,9 @@ reefnet_sensusultra_device_foreach (device_t *abstract, dive_callback_t callback } // Enable progress notifications. - device_progress_t progress = DEVICE_PROGRESS_INITIALIZER; + dc_event_progress_t progress = EVENT_PROGRESS_INITIALIZER; progress.maximum = REEFNET_SENSUSULTRA_MEMORY_DATA_SIZE; - device_event_emit (abstract, DEVICE_EVENT_PROGRESS, &progress); + device_event_emit (abstract, DC_EVENT_PROGRESS, &progress); // Wake-up the device and send the instruction code. dc_status_t rc = reefnet_sensusultra_send (device, 0xB421); @@ -742,7 +742,7 @@ reefnet_sensusultra_device_foreach (device_t *abstract, dive_callback_t callback // Update and emit a progress event. progress.current += REEFNET_SENSUSULTRA_PACKET_SIZE; - device_event_emit (abstract, DEVICE_EVENT_PROGRESS, &progress); + device_event_emit (abstract, DC_EVENT_PROGRESS, &progress); // Abort the transfer if the page contains no useful data. if (array_isequal (packet + 2, REEFNET_SENSUSULTRA_PACKET_SIZE, 0xFF) && nbytes != 0) @@ -787,7 +787,7 @@ reefnet_sensusultra_device_foreach (device_t *abstract, dive_callback_t callback dc_status_t -reefnet_sensusultra_extract_dives (device_t *abstract, const unsigned char data[], unsigned int size, dive_callback_t callback, void *userdata) +reefnet_sensusultra_extract_dives (dc_device_t *abstract, const unsigned char data[], unsigned int size, dc_dive_callback_t callback, void *userdata) { reefnet_sensusultra_device_t *device = (reefnet_sensusultra_device_t *) abstract; diff --git a/src/reefnet_sensusultra_parser.c b/src/reefnet_sensusultra_parser.c index d600139..49d7113 100644 --- a/src/reefnet_sensusultra_parser.c +++ b/src/reefnet_sensusultra_parser.c @@ -32,7 +32,7 @@ typedef struct reefnet_sensusultra_parser_t reefnet_sensusultra_parser_t; struct reefnet_sensusultra_parser_t { - parser_t base; + dc_parser_t base; // Depth calibration. double atmospheric; double hydrostatic; @@ -45,11 +45,11 @@ struct reefnet_sensusultra_parser_t { unsigned int maxdepth; }; -static dc_status_t reefnet_sensusultra_parser_set_data (parser_t *abstract, const unsigned char *data, unsigned int size); -static dc_status_t reefnet_sensusultra_parser_get_datetime (parser_t *abstract, dc_datetime_t *datetime); -static dc_status_t reefnet_sensusultra_parser_get_field (parser_t *abstract, parser_field_type_t type, unsigned int flags, void *value); -static dc_status_t reefnet_sensusultra_parser_samples_foreach (parser_t *abstract, sample_callback_t callback, void *userdata); -static dc_status_t reefnet_sensusultra_parser_destroy (parser_t *abstract); +static dc_status_t reefnet_sensusultra_parser_set_data (dc_parser_t *abstract, const unsigned char *data, unsigned int size); +static dc_status_t reefnet_sensusultra_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *datetime); +static dc_status_t reefnet_sensusultra_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsigned int flags, void *value); +static dc_status_t reefnet_sensusultra_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t callback, void *userdata); +static dc_status_t reefnet_sensusultra_parser_destroy (dc_parser_t *abstract); static const parser_backend_t reefnet_sensusultra_parser_backend = { DC_FAMILY_REEFNET_SENSUSULTRA, @@ -62,7 +62,7 @@ static const parser_backend_t reefnet_sensusultra_parser_backend = { static int -parser_is_reefnet_sensusultra (parser_t *abstract) +parser_is_reefnet_sensusultra (dc_parser_t *abstract) { if (abstract == NULL) return 0; @@ -72,7 +72,7 @@ parser_is_reefnet_sensusultra (parser_t *abstract) dc_status_t -reefnet_sensusultra_parser_create (parser_t **out, unsigned int devtime, dc_ticks_t systime) +reefnet_sensusultra_parser_create (dc_parser_t **out, unsigned int devtime, dc_ticks_t systime) { if (out == NULL) return DC_STATUS_INVALIDARGS; @@ -96,14 +96,14 @@ reefnet_sensusultra_parser_create (parser_t **out, unsigned int devtime, dc_tick parser->divetime = 0; parser->maxdepth = 0; - *out = (parser_t*) parser; + *out = (dc_parser_t*) parser; return DC_STATUS_SUCCESS; } static dc_status_t -reefnet_sensusultra_parser_destroy (parser_t *abstract) +reefnet_sensusultra_parser_destroy (dc_parser_t *abstract) { if (! parser_is_reefnet_sensusultra (abstract)) return DC_STATUS_INVALIDARGS; @@ -116,7 +116,7 @@ reefnet_sensusultra_parser_destroy (parser_t *abstract) static dc_status_t -reefnet_sensusultra_parser_set_data (parser_t *abstract, const unsigned char *data, unsigned int size) +reefnet_sensusultra_parser_set_data (dc_parser_t *abstract, const unsigned char *data, unsigned int size) { reefnet_sensusultra_parser_t *parser = (reefnet_sensusultra_parser_t*) abstract; @@ -133,7 +133,7 @@ reefnet_sensusultra_parser_set_data (parser_t *abstract, const unsigned char *da dc_status_t -reefnet_sensusultra_parser_set_calibration (parser_t *abstract, double atmospheric, double hydrostatic) +reefnet_sensusultra_parser_set_calibration (dc_parser_t *abstract, double atmospheric, double hydrostatic) { reefnet_sensusultra_parser_t *parser = (reefnet_sensusultra_parser_t*) abstract; @@ -148,7 +148,7 @@ reefnet_sensusultra_parser_set_calibration (parser_t *abstract, double atmospher static dc_status_t -reefnet_sensusultra_parser_get_datetime (parser_t *abstract, dc_datetime_t *datetime) +reefnet_sensusultra_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *datetime) { reefnet_sensusultra_parser_t *parser = (reefnet_sensusultra_parser_t *) abstract; @@ -167,7 +167,7 @@ reefnet_sensusultra_parser_get_datetime (parser_t *abstract, dc_datetime_t *date static dc_status_t -reefnet_sensusultra_parser_get_field (parser_t *abstract, parser_field_type_t type, unsigned int flags, void *value) +reefnet_sensusultra_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsigned int flags, void *value) { reefnet_sensusultra_parser_t *parser = (reefnet_sensusultra_parser_t *) abstract; @@ -206,13 +206,13 @@ reefnet_sensusultra_parser_get_field (parser_t *abstract, parser_field_type_t ty if (value) { switch (type) { - case FIELD_TYPE_DIVETIME: + case DC_FIELD_DIVETIME: *((unsigned int *) value) = parser->divetime; break; - case FIELD_TYPE_MAXDEPTH: + case DC_FIELD_MAXDEPTH: *((double *) value) = (parser->maxdepth * BAR / 1000.0 - parser->atmospheric) / parser->hydrostatic; break; - case FIELD_TYPE_GASMIX_COUNT: + case DC_FIELD_GASMIX_COUNT: *((unsigned int *) value) = 0; break; default: @@ -225,7 +225,7 @@ reefnet_sensusultra_parser_get_field (parser_t *abstract, parser_field_type_t ty static dc_status_t -reefnet_sensusultra_parser_samples_foreach (parser_t *abstract, sample_callback_t callback, void *userdata) +reefnet_sensusultra_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t callback, void *userdata) { reefnet_sensusultra_parser_t *parser = (reefnet_sensusultra_parser_t*) abstract; @@ -251,22 +251,22 @@ reefnet_sensusultra_parser_samples_foreach (parser_t *abstract, sample_callback_ while (offset + sizeof (footer) <= size && memcmp (data + offset, footer, sizeof (footer)) != 0) { - parser_sample_value_t sample = {0}; + dc_sample_value_t sample = {0}; // Time (seconds) time += interval; sample.time = time; - if (callback) callback (SAMPLE_TYPE_TIME, sample, userdata); + if (callback) callback (DC_SAMPLE_TIME, sample, userdata); // Temperature (0.01 °K) unsigned int temperature = array_uint16_le (data + offset); sample.temperature = temperature / 100.0 - 273.15; - if (callback) callback (SAMPLE_TYPE_TEMPERATURE, sample, userdata); + if (callback) callback (DC_SAMPLE_TEMPERATURE, sample, userdata); // Depth (absolute pressure in millibar) unsigned int depth = array_uint16_le (data + offset + 2); sample.depth = (depth * BAR / 1000.0 - parser->atmospheric) / parser->hydrostatic; - if (callback) callback (SAMPLE_TYPE_DEPTH, sample, userdata); + if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); offset += 4; } diff --git a/src/suunto_common.c b/src/suunto_common.c index c463528..cd7fbcd 100644 --- a/src/suunto_common.c +++ b/src/suunto_common.c @@ -44,7 +44,7 @@ suunto_common_device_init (suunto_common_device_t *device, const device_backend_ dc_status_t -suunto_common_device_set_fingerprint (device_t *abstract, const unsigned char data[], unsigned int size) +suunto_common_device_set_fingerprint (dc_device_t *abstract, const unsigned char data[], unsigned int size) { suunto_common_device_t *device = (suunto_common_device_t *) abstract; @@ -63,7 +63,7 @@ suunto_common_device_set_fingerprint (device_t *abstract, const unsigned char da dc_status_t -suunto_common_extract_dives (suunto_common_device_t *device, const suunto_common_layout_t *layout, const unsigned char data[], dive_callback_t callback, void *userdata) +suunto_common_extract_dives (suunto_common_device_t *device, const suunto_common_layout_t *layout, const unsigned char data[], dc_dive_callback_t callback, void *userdata) { assert (layout != NULL); diff --git a/src/suunto_common.h b/src/suunto_common.h index ac515f0..66d6dc2 100644 --- a/src/suunto_common.h +++ b/src/suunto_common.h @@ -29,7 +29,7 @@ extern "C" { #endif /* __cplusplus */ typedef struct suunto_common_device_t { - device_t base; + dc_device_t base; unsigned char fingerprint[5]; } suunto_common_device_t; @@ -49,10 +49,10 @@ void suunto_common_device_init (suunto_common_device_t *device, const device_backend_t *backend); dc_status_t -suunto_common_device_set_fingerprint (device_t *device, const unsigned char data[], unsigned int size); +suunto_common_device_set_fingerprint (dc_device_t *device, const unsigned char data[], unsigned int size); dc_status_t -suunto_common_extract_dives (suunto_common_device_t *device, const suunto_common_layout_t *layout, const unsigned char data[], dive_callback_t callback, void *userdata); +suunto_common_extract_dives (suunto_common_device_t *device, const suunto_common_layout_t *layout, const unsigned char data[], dc_dive_callback_t callback, void *userdata); #ifdef __cplusplus } diff --git a/src/suunto_common2.c b/src/suunto_common2.c index 74de410..f471085 100644 --- a/src/suunto_common2.c +++ b/src/suunto_common2.c @@ -57,7 +57,7 @@ suunto_common2_device_init (suunto_common2_device_t *device, const suunto_common static dc_status_t -suunto_common2_transfer (device_t *abstract, const unsigned char command[], unsigned int csize, unsigned char answer[], unsigned int asize, unsigned int size) +suunto_common2_transfer (dc_device_t *abstract, const unsigned char command[], unsigned int csize, unsigned char answer[], unsigned int asize, unsigned int size) { assert (asize >= size + 4); @@ -87,7 +87,7 @@ suunto_common2_transfer (device_t *abstract, const unsigned char command[], unsi dc_status_t -suunto_common2_device_set_fingerprint (device_t *abstract, const unsigned char data[], unsigned int size) +suunto_common2_device_set_fingerprint (dc_device_t *abstract, const unsigned char data[], unsigned int size) { suunto_common2_device_t *device = (suunto_common2_device_t*) abstract; @@ -104,7 +104,7 @@ suunto_common2_device_set_fingerprint (device_t *abstract, const unsigned char d dc_status_t -suunto_common2_device_version (device_t *abstract, unsigned char data[], unsigned int size) +suunto_common2_device_version (dc_device_t *abstract, unsigned char data[], unsigned int size) { if (size < SZ_VERSION) { WARNING ("Insufficient buffer space available."); @@ -124,7 +124,7 @@ suunto_common2_device_version (device_t *abstract, unsigned char data[], unsigne dc_status_t -suunto_common2_device_reset_maxdepth (device_t *abstract) +suunto_common2_device_reset_maxdepth (dc_device_t *abstract) { unsigned char answer[4] = {0}; unsigned char command[4] = {0x20, 0x00, 0x00, 0x20}; @@ -137,7 +137,7 @@ suunto_common2_device_reset_maxdepth (device_t *abstract) dc_status_t -suunto_common2_device_read (device_t *abstract, unsigned int address, unsigned char data[], unsigned int size) +suunto_common2_device_read (dc_device_t *abstract, unsigned int address, unsigned char data[], unsigned int size) { // The data transmission is split in packages // of maximum $SZ_PACKET bytes. @@ -173,7 +173,7 @@ suunto_common2_device_read (device_t *abstract, unsigned int address, unsigned c dc_status_t -suunto_common2_device_write (device_t *abstract, unsigned int address, const unsigned char data[], unsigned int size) +suunto_common2_device_write (dc_device_t *abstract, unsigned int address, const unsigned char data[], unsigned int size) { // The data transmission is split in packages // of maximum $SZ_PACKET bytes. @@ -208,7 +208,7 @@ suunto_common2_device_write (device_t *abstract, unsigned int address, const uns dc_status_t -suunto_common2_device_dump (device_t *abstract, dc_buffer_t *buffer) +suunto_common2_device_dump (dc_device_t *abstract, dc_buffer_t *buffer) { suunto_common2_device_t *device = (suunto_common2_device_t *) abstract; @@ -228,7 +228,7 @@ suunto_common2_device_dump (device_t *abstract, dc_buffer_t *buffer) dc_status_t -suunto_common2_device_foreach (device_t *abstract, dive_callback_t callback, void *userdata) +suunto_common2_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, void *userdata) { suunto_common2_device_t *device = (suunto_common2_device_t*) abstract; @@ -241,10 +241,10 @@ suunto_common2_device_foreach (device_t *abstract, dive_callback_t callback, voi dc_status_t status = DC_STATUS_SUCCESS; // Enable progress notifications. - device_progress_t progress = DEVICE_PROGRESS_INITIALIZER; + dc_event_progress_t progress = EVENT_PROGRESS_INITIALIZER; progress.maximum = layout->rb_profile_end - layout->rb_profile_begin + 8 + SZ_VERSION + (SZ_MINIMUM > 4 ? SZ_MINIMUM : 4); - device_event_emit (abstract, DEVICE_EVENT_PROGRESS, &progress); + device_event_emit (abstract, DC_EVENT_PROGRESS, &progress); // Read the version info. unsigned char version[SZ_VERSION] = {0}; @@ -256,7 +256,7 @@ suunto_common2_device_foreach (device_t *abstract, dive_callback_t callback, voi // Update and emit a progress event. progress.current += sizeof (version); - device_event_emit (abstract, DEVICE_EVENT_PROGRESS, &progress); + device_event_emit (abstract, DC_EVENT_PROGRESS, &progress); // Read the serial number. unsigned char serial[SZ_MINIMUM > 4 ? SZ_MINIMUM : 4] = {0}; @@ -268,14 +268,14 @@ suunto_common2_device_foreach (device_t *abstract, dive_callback_t callback, voi // Update and emit a progress event. progress.current += sizeof (serial); - device_event_emit (abstract, DEVICE_EVENT_PROGRESS, &progress); + device_event_emit (abstract, DC_EVENT_PROGRESS, &progress); // Emit a device info event. - device_devinfo_t devinfo; + dc_event_devinfo_t devinfo; devinfo.model = version[0]; devinfo.firmware = array_uint24_be (version + 1); devinfo.serial = array_uint32_be (serial); - device_event_emit (abstract, DEVICE_EVENT_DEVINFO, &devinfo); + device_event_emit (abstract, DC_EVENT_DEVINFO, &devinfo); // Read the header bytes. unsigned char header[8] = {0}; @@ -317,7 +317,7 @@ suunto_common2_device_foreach (device_t *abstract, dive_callback_t callback, voi progress.maximum -= (layout->rb_profile_end - layout->rb_profile_begin) - remaining; progress.current += sizeof (header); - device_event_emit (abstract, DEVICE_EVENT_PROGRESS, &progress); + device_event_emit (abstract, DC_EVENT_PROGRESS, &progress); // To reduce the number of read operations, we always try to read // packages with the largest possible size. As a consequence, the @@ -383,7 +383,7 @@ suunto_common2_device_foreach (device_t *abstract, dive_callback_t callback, voi // Update and emit a progress event. progress.current += len; - device_event_emit (abstract, DEVICE_EVENT_PROGRESS, &progress); + device_event_emit (abstract, DC_EVENT_PROGRESS, &progress); // Next package. nbytes += len; diff --git a/src/suunto_common2.h b/src/suunto_common2.h index c462585..7d71264 100644 --- a/src/suunto_common2.h +++ b/src/suunto_common2.h @@ -39,39 +39,39 @@ typedef struct suunto_common2_layout_t { } suunto_common2_layout_t; typedef struct suunto_common2_device_t { - device_t base; + dc_device_t base; const suunto_common2_layout_t *layout; unsigned char fingerprint[7]; } suunto_common2_device_t; typedef struct suunto_common2_device_backend_t { device_backend_t base; - dc_status_t (*packet) (device_t *device, const unsigned char command[], unsigned int csize, unsigned char answer[], unsigned int asize, unsigned int size); + dc_status_t (*packet) (dc_device_t *device, const unsigned char command[], unsigned int csize, unsigned char answer[], unsigned int asize, unsigned int size); } suunto_common2_device_backend_t; void suunto_common2_device_init (suunto_common2_device_t *device, const suunto_common2_device_backend_t *backend); dc_status_t -suunto_common2_device_set_fingerprint (device_t *device, const unsigned char data[], unsigned int size); +suunto_common2_device_set_fingerprint (dc_device_t *device, const unsigned char data[], unsigned int size); dc_status_t -suunto_common2_device_version (device_t *device, unsigned char data[], unsigned int size); +suunto_common2_device_version (dc_device_t *device, unsigned char data[], unsigned int size); dc_status_t -suunto_common2_device_read (device_t *device, unsigned int address, unsigned char data[], unsigned int size); +suunto_common2_device_read (dc_device_t *device, unsigned int address, unsigned char data[], unsigned int size); dc_status_t -suunto_common2_device_write (device_t *device, unsigned int address, const unsigned char data[], unsigned int size); +suunto_common2_device_write (dc_device_t *device, unsigned int address, const unsigned char data[], unsigned int size); dc_status_t -suunto_common2_device_dump (device_t *device, dc_buffer_t *buffer); +suunto_common2_device_dump (dc_device_t *device, dc_buffer_t *buffer); dc_status_t -suunto_common2_device_foreach (device_t *device, dive_callback_t callback, void *userdata); +suunto_common2_device_foreach (dc_device_t *device, dc_dive_callback_t callback, void *userdata); dc_status_t -suunto_common2_device_reset_maxdepth (device_t *device); +suunto_common2_device_reset_maxdepth (dc_device_t *device); #ifdef __cplusplus } diff --git a/src/suunto_d9.c b/src/suunto_d9.c index 0020c76..d0cc3d8 100644 --- a/src/suunto_d9.c +++ b/src/suunto_d9.c @@ -48,8 +48,8 @@ typedef struct suunto_d9_device_t { unsigned char version[4]; } suunto_d9_device_t; -static dc_status_t suunto_d9_device_packet (device_t *abstract, const unsigned char command[], unsigned int csize, unsigned char answer[], unsigned int asize, unsigned int size); -static dc_status_t suunto_d9_device_close (device_t *abstract); +static dc_status_t suunto_d9_device_packet (dc_device_t *abstract, const unsigned char command[], unsigned int csize, unsigned char answer[], unsigned int asize, unsigned int size); +static dc_status_t suunto_d9_device_close (dc_device_t *abstract); static const suunto_common2_device_backend_t suunto_d9_device_backend = { { @@ -80,7 +80,7 @@ static const suunto_common2_layout_t suunto_d9tx_layout = { }; static int -device_is_suunto_d9 (device_t *abstract) +device_is_suunto_d9 (dc_device_t *abstract) { if (abstract == NULL) return 0; @@ -114,7 +114,7 @@ suunto_d9_device_autodetect (suunto_d9_device_t *device, unsigned int model) } // Try reading the version info. - status = suunto_common2_device_version ((device_t *) device, device->version, sizeof (device->version)); + status = suunto_common2_device_version ((dc_device_t *) device, device->version, sizeof (device->version)); if (status == DC_STATUS_SUCCESS) break; } @@ -124,7 +124,7 @@ suunto_d9_device_autodetect (suunto_d9_device_t *device, unsigned int model) dc_status_t -suunto_d9_device_open (device_t **out, const char* name, unsigned int model) +suunto_d9_device_open (dc_device_t **out, const char *name, unsigned int model) { if (out == NULL) return DC_STATUS_INVALIDARGS; @@ -198,14 +198,14 @@ suunto_d9_device_open (device_t **out, const char* name, unsigned int model) else device->base.layout = &suunto_d9_layout; - *out = (device_t*) device; + *out = (dc_device_t*) device; return DC_STATUS_SUCCESS; } static dc_status_t -suunto_d9_device_close (device_t *abstract) +suunto_d9_device_close (dc_device_t *abstract) { suunto_d9_device_t *device = (suunto_d9_device_t*) abstract; @@ -226,7 +226,7 @@ suunto_d9_device_close (device_t *abstract) static dc_status_t -suunto_d9_device_packet (device_t *abstract, const unsigned char command[], unsigned int csize, unsigned char answer[], unsigned int asize, unsigned int size) +suunto_d9_device_packet (dc_device_t *abstract, const unsigned char command[], unsigned int csize, unsigned char answer[], unsigned int asize, unsigned int size) { suunto_d9_device_t *device = (suunto_d9_device_t *) abstract; @@ -299,7 +299,7 @@ suunto_d9_device_packet (device_t *abstract, const unsigned char command[], unsi dc_status_t -suunto_d9_device_reset_maxdepth (device_t *abstract) +suunto_d9_device_reset_maxdepth (dc_device_t *abstract) { if (! device_is_suunto_d9 (abstract)) return DC_STATUS_INVALIDARGS; diff --git a/src/suunto_d9_parser.c b/src/suunto_d9_parser.c index eb4295d..3328a93 100644 --- a/src/suunto_d9_parser.c +++ b/src/suunto_d9_parser.c @@ -46,7 +46,7 @@ typedef struct suunto_d9_parser_t suunto_d9_parser_t; struct suunto_d9_parser_t { - parser_t base; + dc_parser_t base; unsigned int model; }; @@ -57,11 +57,11 @@ typedef struct sample_info_t { unsigned int divisor; } sample_info_t; -static dc_status_t suunto_d9_parser_set_data (parser_t *abstract, const unsigned char *data, unsigned int size); -static dc_status_t suunto_d9_parser_get_datetime (parser_t *abstract, dc_datetime_t *datetime); -static dc_status_t suunto_d9_parser_get_field (parser_t *abstract, parser_field_type_t type, unsigned int flags, void *value); -static dc_status_t suunto_d9_parser_samples_foreach (parser_t *abstract, sample_callback_t callback, void *userdata); -static dc_status_t suunto_d9_parser_destroy (parser_t *abstract); +static dc_status_t suunto_d9_parser_set_data (dc_parser_t *abstract, const unsigned char *data, unsigned int size); +static dc_status_t suunto_d9_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *datetime); +static dc_status_t suunto_d9_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsigned int flags, void *value); +static dc_status_t suunto_d9_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t callback, void *userdata); +static dc_status_t suunto_d9_parser_destroy (dc_parser_t *abstract); static const parser_backend_t suunto_d9_parser_backend = { DC_FAMILY_SUUNTO_D9, @@ -74,7 +74,7 @@ static const parser_backend_t suunto_d9_parser_backend = { static int -parser_is_suunto_d9 (parser_t *abstract) +parser_is_suunto_d9 (dc_parser_t *abstract) { if (abstract == NULL) return 0; @@ -84,7 +84,7 @@ parser_is_suunto_d9 (parser_t *abstract) dc_status_t -suunto_d9_parser_create (parser_t **out, unsigned int model) +suunto_d9_parser_create (dc_parser_t **out, unsigned int model) { if (out == NULL) return DC_STATUS_INVALIDARGS; @@ -102,14 +102,14 @@ suunto_d9_parser_create (parser_t **out, unsigned int model) // Set the default values. parser->model = model; - *out = (parser_t*) parser; + *out = (dc_parser_t*) parser; return DC_STATUS_SUCCESS; } static dc_status_t -suunto_d9_parser_destroy (parser_t *abstract) +suunto_d9_parser_destroy (dc_parser_t *abstract) { if (! parser_is_suunto_d9 (abstract)) return DC_STATUS_INVALIDARGS; @@ -122,7 +122,7 @@ suunto_d9_parser_destroy (parser_t *abstract) static dc_status_t -suunto_d9_parser_set_data (parser_t *abstract, const unsigned char *data, unsigned int size) +suunto_d9_parser_set_data (dc_parser_t *abstract, const unsigned char *data, unsigned int size) { if (! parser_is_suunto_d9 (abstract)) return DC_STATUS_INVALIDARGS; @@ -132,7 +132,7 @@ suunto_d9_parser_set_data (parser_t *abstract, const unsigned char *data, unsign static dc_status_t -suunto_d9_parser_get_datetime (parser_t *abstract, dc_datetime_t *datetime) +suunto_d9_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *datetime) { suunto_d9_parser_t *parser = (suunto_d9_parser_t*) abstract; @@ -170,7 +170,7 @@ suunto_d9_parser_get_datetime (parser_t *abstract, dc_datetime_t *datetime) static dc_status_t -suunto_d9_parser_get_field (parser_t *abstract, parser_field_type_t type, unsigned int flags, void *value) +suunto_d9_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsigned int flags, void *value) { suunto_d9_parser_t *parser = (suunto_d9_parser_t*) abstract; @@ -186,11 +186,11 @@ suunto_d9_parser_get_field (parser_t *abstract, parser_field_type_t type, unsign if (size < config) return DC_STATUS_DATAFORMAT; - gasmix_t *gasmix = (gasmix_t *) value; + dc_gasmix_t *gasmix = (dc_gasmix_t *) value; if (value) { switch (type) { - case FIELD_TYPE_DIVETIME: + case DC_FIELD_DIVETIME: if (parser->model == D4) *((unsigned int *) value) = array_uint16_le (data + 0x0F - SKIP); else if (parser->model == D4i || parser->model == D6i || parser->model == D9tx) @@ -200,10 +200,10 @@ suunto_d9_parser_get_field (parser_t *abstract, parser_field_type_t type, unsign else *((unsigned int *) value) = array_uint16_le (data + 0x0F - SKIP) * 60; break; - case FIELD_TYPE_MAXDEPTH: + case DC_FIELD_MAXDEPTH: *((double *) value) = array_uint16_le (data + 0x0D - SKIP) / 100.0; break; - case FIELD_TYPE_GASMIX_COUNT: + case DC_FIELD_GASMIX_COUNT: if (parser->model == HELO2) { *((unsigned int *) value) = 8; } else if (parser->model == D9tx) { @@ -216,7 +216,7 @@ suunto_d9_parser_get_field (parser_t *abstract, parser_field_type_t type, unsign *((unsigned int *) value) = 3; } break; - case FIELD_TYPE_GASMIX: + case DC_FIELD_GASMIX: if (parser->model == HELO2) { gasmix->helium = data[0x58 - SKIP + 6 * flags + 2] / 100.0; gasmix->oxygen = data[0x58 - SKIP + 6 * flags + 1] / 100.0; @@ -239,7 +239,7 @@ suunto_d9_parser_get_field (parser_t *abstract, parser_field_type_t type, unsign static dc_status_t -suunto_d9_parser_samples_foreach (parser_t *abstract, sample_callback_t callback, void *userdata) +suunto_d9_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t callback, void *userdata) { suunto_d9_parser_t *parser = (suunto_d9_parser_t*) abstract; @@ -321,11 +321,11 @@ suunto_d9_parser_samples_foreach (parser_t *abstract, sample_callback_t callback unsigned int nsamples = 0; unsigned int offset = profile + 5; while (offset < size) { - parser_sample_value_t sample = {0}; + dc_sample_value_t sample = {0}; // Time (seconds). sample.time = time; - if (callback) callback (SAMPLE_TYPE_TIME, sample, userdata); + if (callback) callback (DC_SAMPLE_TIME, sample, userdata); // Sample data. for (unsigned int i = 0; i < nparams; ++i) { @@ -338,19 +338,19 @@ suunto_d9_parser_samples_foreach (parser_t *abstract, sample_callback_t callback case 0x64: // Depth value = array_uint16_le (data + offset); sample.depth = value / (double) info[i].divisor; - if (callback) callback (SAMPLE_TYPE_DEPTH, sample, userdata); + if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); break; case 0x68: // Pressure value = array_uint16_le (data + offset); if (value != 0xFFFF) { sample.pressure.tank = 0; sample.pressure.value = value / (double) info[i].divisor; - if (callback) callback (SAMPLE_TYPE_PRESSURE, sample, userdata); + if (callback) callback (DC_SAMPLE_PRESSURE, sample, userdata); } break; case 0x74: // Temperature sample.temperature = (signed char) data[offset] / (double) info[i].divisor; - if (callback) callback (SAMPLE_TYPE_TEMPERATURE, sample, userdata); + if (callback) callback (DC_SAMPLE_TEMPERATURE, sample, userdata); break; default: // Unknown sample type return DC_STATUS_DATAFORMAT; @@ -388,7 +388,7 @@ suunto_d9_parser_samples_foreach (parser_t *abstract, sample_callback_t callback seconds = data[offset + 1]; sample.event.type = SAMPLE_EVENT_SURFACE; sample.event.time = seconds; - if (callback) callback (SAMPLE_TYPE_EVENT, sample, userdata); + if (callback) callback (DC_SAMPLE_EVENT, sample, userdata); offset += 2; break; case 0x03: // Event @@ -467,7 +467,7 @@ suunto_d9_parser_samples_foreach (parser_t *abstract, sample_callback_t callback else sample.event.flags = SAMPLE_FLAGS_BEGIN; sample.event.time = seconds; - if (callback) callback (SAMPLE_TYPE_EVENT, sample, userdata); + if (callback) callback (DC_SAMPLE_EVENT, sample, userdata); offset += 2; break; case 0x04: // Bookmark/Heading @@ -484,7 +484,7 @@ suunto_d9_parser_samples_foreach (parser_t *abstract, sample_callback_t callback sample.event.value = heading / 2; } sample.event.time = seconds; - if (callback) callback (SAMPLE_TYPE_EVENT, sample, userdata); + if (callback) callback (DC_SAMPLE_EVENT, sample, userdata); offset += 4; break; case 0x05: // Gas Change @@ -495,7 +495,7 @@ suunto_d9_parser_samples_foreach (parser_t *abstract, sample_callback_t callback sample.event.type = SAMPLE_EVENT_GASCHANGE; sample.event.time = seconds; sample.event.value = percentage; - if (callback) callback (SAMPLE_TYPE_EVENT, sample, userdata); + if (callback) callback (DC_SAMPLE_EVENT, sample, userdata); offset += 2; break; case 0x06: // Gas Change @@ -508,7 +508,7 @@ suunto_d9_parser_samples_foreach (parser_t *abstract, sample_callback_t callback sample.event.type = SAMPLE_EVENT_GASCHANGE; sample.event.time = seconds; sample.event.value = percentage; - if (callback) callback (SAMPLE_TYPE_EVENT, sample, userdata); + if (callback) callback (DC_SAMPLE_EVENT, sample, userdata); offset += 4; break; default: diff --git a/src/suunto_eon.c b/src/suunto_eon.c index c3d96b7..3d71369 100644 --- a/src/suunto_eon.c +++ b/src/suunto_eon.c @@ -41,9 +41,9 @@ typedef struct suunto_eon_device_t { serial_t *port; } suunto_eon_device_t; -static dc_status_t suunto_eon_device_dump (device_t *abstract, dc_buffer_t *buffer); -static dc_status_t suunto_eon_device_foreach (device_t *abstract, dive_callback_t callback, void *userdata); -static dc_status_t suunto_eon_device_close (device_t *abstract); +static dc_status_t suunto_eon_device_dump (dc_device_t *abstract, dc_buffer_t *buffer); +static dc_status_t suunto_eon_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, void *userdata); +static dc_status_t suunto_eon_device_close (dc_device_t *abstract); static const device_backend_t suunto_eon_device_backend = { DC_FAMILY_SUUNTO_EON, @@ -66,7 +66,7 @@ static const suunto_common_layout_t suunto_eon_layout = { static int -device_is_suunto_eon (device_t *abstract) +device_is_suunto_eon (dc_device_t *abstract) { if (abstract == NULL) return 0; @@ -76,7 +76,7 @@ device_is_suunto_eon (device_t *abstract) dc_status_t -suunto_eon_device_open (device_t **out, const char* name) +suunto_eon_device_open (dc_device_t **out, const char *name) { if (out == NULL) return DC_STATUS_INVALIDARGS; @@ -127,14 +127,14 @@ suunto_eon_device_open (device_t **out, const char* name) return DC_STATUS_IO; } - *out = (device_t*) device; + *out = (dc_device_t*) device; return DC_STATUS_SUCCESS; } static dc_status_t -suunto_eon_device_close (device_t *abstract) +suunto_eon_device_close (dc_device_t *abstract) { suunto_eon_device_t *device = (suunto_eon_device_t*) abstract; @@ -155,7 +155,7 @@ suunto_eon_device_close (device_t *abstract) static dc_status_t -suunto_eon_device_dump (device_t *abstract, dc_buffer_t *buffer) +suunto_eon_device_dump (dc_device_t *abstract, dc_buffer_t *buffer) { suunto_eon_device_t *device = (suunto_eon_device_t*) abstract; @@ -170,9 +170,9 @@ suunto_eon_device_dump (device_t *abstract, dc_buffer_t *buffer) } // Enable progress notifications. - device_progress_t progress = DEVICE_PROGRESS_INITIALIZER; + dc_event_progress_t progress = EVENT_PROGRESS_INITIALIZER; progress.maximum = SUUNTO_EON_MEMORY_SIZE + 1; - device_event_emit (abstract, DEVICE_EVENT_PROGRESS, &progress); + device_event_emit (abstract, DC_EVENT_PROGRESS, &progress); // Send the command. unsigned char command[1] = {'P'}; @@ -192,7 +192,7 @@ suunto_eon_device_dump (device_t *abstract, dc_buffer_t *buffer) // Update and emit a progress event. progress.current += sizeof (answer); - device_event_emit (abstract, DEVICE_EVENT_PROGRESS, &progress); + device_event_emit (abstract, DC_EVENT_PROGRESS, &progress); // Verify the checksum of the package. unsigned char crc = answer[sizeof (answer) - 1]; @@ -209,7 +209,7 @@ suunto_eon_device_dump (device_t *abstract, dc_buffer_t *buffer) static dc_status_t -suunto_eon_device_foreach (device_t *abstract, dive_callback_t callback, void *userdata) +suunto_eon_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, void *userdata) { dc_buffer_t *buffer = dc_buffer_new (SUUNTO_EON_MEMORY_SIZE); if (buffer == NULL) @@ -223,11 +223,11 @@ suunto_eon_device_foreach (device_t *abstract, dive_callback_t callback, void *u // Emit a device info event. unsigned char *data = dc_buffer_get_data (buffer); - device_devinfo_t devinfo; + dc_event_devinfo_t devinfo; devinfo.model = 0; devinfo.firmware = 0; devinfo.serial = array_uint24_be (data + 244); - device_event_emit (abstract, DEVICE_EVENT_DEVINFO, &devinfo); + device_event_emit (abstract, DC_EVENT_DEVINFO, &devinfo); rc = suunto_eon_extract_dives (abstract, dc_buffer_get_data (buffer), dc_buffer_get_size (buffer), callback, userdata); @@ -239,7 +239,7 @@ suunto_eon_device_foreach (device_t *abstract, dive_callback_t callback, void *u dc_status_t -suunto_eon_device_write_name (device_t *abstract, unsigned char data[], unsigned int size) +suunto_eon_device_write_name (dc_device_t *abstract, unsigned char data[], unsigned int size) { suunto_eon_device_t *device = (suunto_eon_device_t*) abstract; @@ -263,7 +263,7 @@ suunto_eon_device_write_name (device_t *abstract, unsigned char data[], unsigned dc_status_t -suunto_eon_device_write_interval (device_t *abstract, unsigned char interval) +suunto_eon_device_write_interval (dc_device_t *abstract, unsigned char interval) { suunto_eon_device_t *device = (suunto_eon_device_t*) abstract; @@ -283,7 +283,7 @@ suunto_eon_device_write_interval (device_t *abstract, unsigned char interval) dc_status_t -suunto_eon_extract_dives (device_t *abstract, const unsigned char data[], unsigned int size, dive_callback_t callback, void *userdata) +suunto_eon_extract_dives (dc_device_t *abstract, const unsigned char data[], unsigned int size, dc_dive_callback_t callback, void *userdata) { suunto_common_device_t *device = (suunto_common_device_t*) abstract; diff --git a/src/suunto_eon_parser.c b/src/suunto_eon_parser.c index 092d1b3..b178967 100644 --- a/src/suunto_eon_parser.c +++ b/src/suunto_eon_parser.c @@ -31,7 +31,7 @@ typedef struct suunto_eon_parser_t suunto_eon_parser_t; struct suunto_eon_parser_t { - parser_t base; + dc_parser_t base; int spyder; // Cached fields. unsigned int cached; @@ -39,11 +39,11 @@ struct suunto_eon_parser_t { unsigned int maxdepth; }; -static dc_status_t suunto_eon_parser_set_data (parser_t *abstract, const unsigned char *data, unsigned int size); -static dc_status_t suunto_eon_parser_get_datetime (parser_t *abstract, dc_datetime_t *datetime); -static dc_status_t suunto_eon_parser_get_field (parser_t *abstract, parser_field_type_t type, unsigned int flags, void *value); -static dc_status_t suunto_eon_parser_samples_foreach (parser_t *abstract, sample_callback_t callback, void *userdata); -static dc_status_t suunto_eon_parser_destroy (parser_t *abstract); +static dc_status_t suunto_eon_parser_set_data (dc_parser_t *abstract, const unsigned char *data, unsigned int size); +static dc_status_t suunto_eon_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *datetime); +static dc_status_t suunto_eon_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsigned int flags, void *value); +static dc_status_t suunto_eon_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t callback, void *userdata); +static dc_status_t suunto_eon_parser_destroy (dc_parser_t *abstract); static const parser_backend_t suunto_eon_parser_backend = { DC_FAMILY_SUUNTO_EON, @@ -56,7 +56,7 @@ static const parser_backend_t suunto_eon_parser_backend = { static int -parser_is_suunto_eon (parser_t *abstract) +parser_is_suunto_eon (dc_parser_t *abstract) { if (abstract == NULL) return 0; @@ -66,7 +66,7 @@ parser_is_suunto_eon (parser_t *abstract) dc_status_t -suunto_eon_parser_create (parser_t **out, int spyder) +suunto_eon_parser_create (dc_parser_t **out, int spyder) { if (out == NULL) return DC_STATUS_INVALIDARGS; @@ -87,14 +87,14 @@ suunto_eon_parser_create (parser_t **out, int spyder) parser->divetime = 0; parser->maxdepth = 0; - *out = (parser_t*) parser; + *out = (dc_parser_t*) parser; return DC_STATUS_SUCCESS; } static dc_status_t -suunto_eon_parser_destroy (parser_t *abstract) +suunto_eon_parser_destroy (dc_parser_t *abstract) { if (! parser_is_suunto_eon (abstract)) return DC_STATUS_INVALIDARGS; @@ -107,7 +107,7 @@ suunto_eon_parser_destroy (parser_t *abstract) static dc_status_t -suunto_eon_parser_set_data (parser_t *abstract, const unsigned char *data, unsigned int size) +suunto_eon_parser_set_data (dc_parser_t *abstract, const unsigned char *data, unsigned int size) { suunto_eon_parser_t *parser = (suunto_eon_parser_t *) abstract; @@ -124,7 +124,7 @@ suunto_eon_parser_set_data (parser_t *abstract, const unsigned char *data, unsig static dc_status_t -suunto_eon_parser_get_datetime (parser_t *abstract, dc_datetime_t *datetime) +suunto_eon_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *datetime) { suunto_eon_parser_t *parser = (suunto_eon_parser_t *) abstract; @@ -155,7 +155,7 @@ suunto_eon_parser_get_datetime (parser_t *abstract, dc_datetime_t *datetime) static dc_status_t -suunto_eon_parser_get_field (parser_t *abstract, parser_field_type_t type, unsigned int flags, void *value) +suunto_eon_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsigned int flags, void *value) { suunto_eon_parser_t *parser = (suunto_eon_parser_t *) abstract; @@ -190,20 +190,20 @@ suunto_eon_parser_get_field (parser_t *abstract, parser_field_type_t type, unsig parser->maxdepth = maxdepth; } - gasmix_t *gasmix = (gasmix_t *) value; + dc_gasmix_t *gasmix = (dc_gasmix_t *) value; if (value) { switch (type) { - case FIELD_TYPE_DIVETIME: + case DC_FIELD_DIVETIME: *((unsigned int *) value) = parser->divetime; break; - case FIELD_TYPE_MAXDEPTH: + case DC_FIELD_MAXDEPTH: *((double *) value) = parser->maxdepth * FEET; break; - case FIELD_TYPE_GASMIX_COUNT: + case DC_FIELD_GASMIX_COUNT: *((unsigned int *) value) = 1; break; - case FIELD_TYPE_GASMIX: + case DC_FIELD_GASMIX: gasmix->helium = 0.0; if ((data[4] & 0x80) && !parser->spyder) gasmix->oxygen = data[0x05] / 100.0; @@ -221,7 +221,7 @@ suunto_eon_parser_get_field (parser_t *abstract, parser_field_type_t type, unsig static dc_status_t -suunto_eon_parser_samples_foreach (parser_t *abstract, sample_callback_t callback, void *userdata) +suunto_eon_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t callback, void *userdata) { suunto_eon_parser_t *parser = (suunto_eon_parser_t *) abstract; @@ -258,34 +258,34 @@ suunto_eon_parser_samples_foreach (parser_t *abstract, sample_callback_t callbac unsigned int interval = data[3]; unsigned int complete = 1; - parser_sample_value_t sample = {0}; + dc_sample_value_t sample = {0}; // Time sample.time = time; - if (callback) callback (SAMPLE_TYPE_TIME, sample, userdata); + if (callback) callback (DC_SAMPLE_TIME, sample, userdata); // Tank Pressure (2 bar) if (!nitrox) { sample.pressure.tank = 0; sample.pressure.value = data[5] * 2; - if (callback) callback (SAMPLE_TYPE_PRESSURE, sample, userdata); + if (callback) callback (DC_SAMPLE_PRESSURE, sample, userdata); } // Depth (0 ft) sample.depth = 0; - if (callback) callback (SAMPLE_TYPE_DEPTH, sample, userdata); + if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); depth = 0; offset = 11; while (offset < size && data[offset] != 0x80) { - parser_sample_value_t sample = {0}; + dc_sample_value_t sample = {0}; unsigned char value = data[offset++]; if (complete) { // Time (seconds). time += interval; sample.time = time; - if (callback) callback (SAMPLE_TYPE_TIME, sample, userdata); + if (callback) callback (DC_SAMPLE_TIME, sample, userdata); complete = 0; } @@ -299,12 +299,12 @@ suunto_eon_parser_samples_foreach (parser_t *abstract, sample_callback_t callbac sample.temperature = (signed char) data[marker + 1]; else sample.temperature = data[marker + 1] - 40; - if (callback) callback (SAMPLE_TYPE_TEMPERATURE, sample, userdata); + if (callback) callback (DC_SAMPLE_TEMPERATURE, sample, userdata); } // Depth (ft). sample.depth = depth * FEET; - if (callback) callback (SAMPLE_TYPE_DEPTH, sample, userdata); + if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); complete = 1; } else { @@ -330,7 +330,7 @@ suunto_eon_parser_samples_foreach (parser_t *abstract, sample_callback_t callbac break; } - if (callback) callback (SAMPLE_TYPE_EVENT, sample, userdata); + if (callback) callback (DC_SAMPLE_EVENT, sample, userdata); } } @@ -338,19 +338,19 @@ suunto_eon_parser_samples_foreach (parser_t *abstract, sample_callback_t callbac if (complete) { time += interval; sample.time = time; - if (callback) callback (SAMPLE_TYPE_TIME, sample, userdata); + if (callback) callback (DC_SAMPLE_TIME, sample, userdata); } // Tank Pressure (2 bar) if (!nitrox) { sample.pressure.tank = 0; sample.pressure.value = data[offset + 2] * 2; - if (callback) callback (SAMPLE_TYPE_PRESSURE, sample, userdata); + if (callback) callback (DC_SAMPLE_PRESSURE, sample, userdata); } // Depth (0 ft) sample.depth = 0; - if (callback) callback (SAMPLE_TYPE_DEPTH, sample, userdata); + if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); return DC_STATUS_SUCCESS; } diff --git a/src/suunto_solution.c b/src/suunto_solution.c index 36ef0e9..ebb62be 100644 --- a/src/suunto_solution.c +++ b/src/suunto_solution.c @@ -39,13 +39,13 @@ #define RB_PROFILE_END 0x100 typedef struct suunto_solution_device_t { - device_t base; + dc_device_t base; serial_t *port; } suunto_solution_device_t; -static dc_status_t suunto_solution_device_dump (device_t *abstract, dc_buffer_t *buffer); -static dc_status_t suunto_solution_device_foreach (device_t *abstract, dive_callback_t callback, void *userdata); -static dc_status_t suunto_solution_device_close (device_t *abstract); +static dc_status_t suunto_solution_device_dump (dc_device_t *abstract, dc_buffer_t *buffer); +static dc_status_t suunto_solution_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, void *userdata); +static dc_status_t suunto_solution_device_close (dc_device_t *abstract); static const device_backend_t suunto_solution_device_backend = { DC_FAMILY_SUUNTO_SOLUTION, @@ -59,7 +59,7 @@ static const device_backend_t suunto_solution_device_backend = { }; static int -device_is_suunto_solution (device_t *abstract) +device_is_suunto_solution (dc_device_t *abstract) { if (abstract == NULL) return 0; @@ -69,7 +69,7 @@ device_is_suunto_solution (device_t *abstract) dc_status_t -suunto_solution_device_open (device_t **out, const char* name) +suunto_solution_device_open (dc_device_t **out, const char *name) { if (out == NULL) return DC_STATUS_INVALIDARGS; @@ -120,14 +120,14 @@ suunto_solution_device_open (device_t **out, const char* name) return DC_STATUS_IO; } - *out = (device_t*) device; + *out = (dc_device_t*) device; return DC_STATUS_SUCCESS; } static dc_status_t -suunto_solution_device_close (device_t *abstract) +suunto_solution_device_close (dc_device_t *abstract) { suunto_solution_device_t *device = (suunto_solution_device_t*) abstract; @@ -148,7 +148,7 @@ suunto_solution_device_close (device_t *abstract) static dc_status_t -suunto_solution_device_dump (device_t *abstract, dc_buffer_t *buffer) +suunto_solution_device_dump (dc_device_t *abstract, dc_buffer_t *buffer) { suunto_solution_device_t *device = (suunto_solution_device_t*) abstract; @@ -165,9 +165,9 @@ suunto_solution_device_dump (device_t *abstract, dc_buffer_t *buffer) unsigned char *data = dc_buffer_get_data (buffer); // Enable progress notifications. - device_progress_t progress = DEVICE_PROGRESS_INITIALIZER; + dc_event_progress_t progress = EVENT_PROGRESS_INITIALIZER; progress.maximum = SUUNTO_SOLUTION_MEMORY_SIZE - 1 + 2; - device_event_emit (abstract, DEVICE_EVENT_PROGRESS, &progress); + device_event_emit (abstract, DC_EVENT_PROGRESS, &progress); int n = 0; unsigned char command[3] = {0}; @@ -193,7 +193,7 @@ suunto_solution_device_dump (device_t *abstract, dc_buffer_t *buffer) // Update and emit a progress event. progress.current += 1; - device_event_emit (abstract, DEVICE_EVENT_PROGRESS, &progress); + device_event_emit (abstract, DC_EVENT_PROGRESS, &progress); data[0] = 0x00; for (unsigned int i = 1; i < SUUNTO_SOLUTION_MEMORY_SIZE; ++i) { @@ -217,7 +217,7 @@ suunto_solution_device_dump (device_t *abstract, dc_buffer_t *buffer) // Update and emit a progress event. progress.current += 1; - device_event_emit (abstract, DEVICE_EVENT_PROGRESS, &progress); + device_event_emit (abstract, DC_EVENT_PROGRESS, &progress); } // Receive: 0x02, 0x00, 0x80 @@ -245,14 +245,14 @@ suunto_solution_device_dump (device_t *abstract, dc_buffer_t *buffer) // Update and emit a progress event. progress.current += 1; - device_event_emit (abstract, DEVICE_EVENT_PROGRESS, &progress); + device_event_emit (abstract, DC_EVENT_PROGRESS, &progress); return DC_STATUS_SUCCESS; } static dc_status_t -suunto_solution_device_foreach (device_t *abstract, dive_callback_t callback, void *userdata) +suunto_solution_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, void *userdata) { if (! device_is_suunto_solution (abstract)) return DC_STATUS_INVALIDARGS; @@ -269,11 +269,11 @@ suunto_solution_device_foreach (device_t *abstract, dive_callback_t callback, vo // Emit a device info event. unsigned char *data = dc_buffer_get_data (buffer); - device_devinfo_t devinfo; + dc_event_devinfo_t devinfo; devinfo.model = 0; devinfo.firmware = 0; devinfo.serial = array_uint24_be (data + 0x1D); - device_event_emit (abstract, DEVICE_EVENT_DEVINFO, &devinfo); + device_event_emit (abstract, DC_EVENT_DEVINFO, &devinfo); rc = suunto_solution_extract_dives (abstract, dc_buffer_get_data (buffer), dc_buffer_get_size (buffer), callback, userdata); @@ -285,7 +285,7 @@ suunto_solution_device_foreach (device_t *abstract, dive_callback_t callback, vo dc_status_t -suunto_solution_extract_dives (device_t *abstract, const unsigned char data[], unsigned int size, dive_callback_t callback, void *userdata) +suunto_solution_extract_dives (dc_device_t *abstract, const unsigned char data[], unsigned int size, dc_dive_callback_t callback, void *userdata) { if (abstract && !device_is_suunto_solution (abstract)) return DC_STATUS_INVALIDARGS; diff --git a/src/suunto_solution_parser.c b/src/suunto_solution_parser.c index 523b77a..e73d62a 100644 --- a/src/suunto_solution_parser.c +++ b/src/suunto_solution_parser.c @@ -30,17 +30,17 @@ typedef struct suunto_solution_parser_t suunto_solution_parser_t; struct suunto_solution_parser_t { - parser_t base; + dc_parser_t base; // Cached fields. unsigned int cached; unsigned int divetime; unsigned int maxdepth; }; -static dc_status_t suunto_solution_parser_set_data (parser_t *abstract, const unsigned char *data, unsigned int size); -static dc_status_t suunto_solution_parser_get_field (parser_t *abstract, parser_field_type_t type, unsigned int flags, void *value); -static dc_status_t suunto_solution_parser_samples_foreach (parser_t *abstract, sample_callback_t callback, void *userdata); -static dc_status_t suunto_solution_parser_destroy (parser_t *abstract); +static dc_status_t suunto_solution_parser_set_data (dc_parser_t *abstract, const unsigned char *data, unsigned int size); +static dc_status_t suunto_solution_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsigned int flags, void *value); +static dc_status_t suunto_solution_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t callback, void *userdata); +static dc_status_t suunto_solution_parser_destroy (dc_parser_t *abstract); static const parser_backend_t suunto_solution_parser_backend = { DC_FAMILY_SUUNTO_SOLUTION, @@ -53,7 +53,7 @@ static const parser_backend_t suunto_solution_parser_backend = { static int -parser_is_suunto_solution (parser_t *abstract) +parser_is_suunto_solution (dc_parser_t *abstract) { if (abstract == NULL) return 0; @@ -63,7 +63,7 @@ parser_is_suunto_solution (parser_t *abstract) dc_status_t -suunto_solution_parser_create (parser_t **out) +suunto_solution_parser_create (dc_parser_t **out) { if (out == NULL) return DC_STATUS_INVALIDARGS; @@ -83,14 +83,14 @@ suunto_solution_parser_create (parser_t **out) parser->divetime = 0; parser->maxdepth = 0; - *out = (parser_t*) parser; + *out = (dc_parser_t*) parser; return DC_STATUS_SUCCESS; } static dc_status_t -suunto_solution_parser_destroy (parser_t *abstract) +suunto_solution_parser_destroy (dc_parser_t *abstract) { if (! parser_is_suunto_solution (abstract)) return DC_STATUS_INVALIDARGS; @@ -103,7 +103,7 @@ suunto_solution_parser_destroy (parser_t *abstract) static dc_status_t -suunto_solution_parser_set_data (parser_t *abstract, const unsigned char *data, unsigned int size) +suunto_solution_parser_set_data (dc_parser_t *abstract, const unsigned char *data, unsigned int size) { suunto_solution_parser_t *parser = (suunto_solution_parser_t *) abstract; @@ -120,7 +120,7 @@ suunto_solution_parser_set_data (parser_t *abstract, const unsigned char *data, static dc_status_t -suunto_solution_parser_get_field (parser_t *abstract, parser_field_type_t type, unsigned int flags, void *value) +suunto_solution_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsigned int flags, void *value) { suunto_solution_parser_t *parser = (suunto_solution_parser_t *) abstract; @@ -159,20 +159,20 @@ suunto_solution_parser_get_field (parser_t *abstract, parser_field_type_t type, parser->maxdepth = maxdepth; } - gasmix_t *gasmix = (gasmix_t *) value; + dc_gasmix_t *gasmix = (dc_gasmix_t *) value; if (value) { switch (type) { - case FIELD_TYPE_DIVETIME: + case DC_FIELD_DIVETIME: *((unsigned int *) value) = parser->divetime; break; - case FIELD_TYPE_MAXDEPTH: + case DC_FIELD_MAXDEPTH: *((double *) value) = parser->maxdepth * FEET; break; - case FIELD_TYPE_GASMIX_COUNT: + case DC_FIELD_GASMIX_COUNT: *((unsigned int *) value) = 1; break; - case FIELD_TYPE_GASMIX: + case DC_FIELD_GASMIX: gasmix->helium = 0.0; gasmix->oxygen = 0.21; gasmix->nitrogen = 1.0 - gasmix->oxygen - gasmix->helium; @@ -186,7 +186,7 @@ suunto_solution_parser_get_field (parser_t *abstract, parser_field_type_t type, } static dc_status_t -suunto_solution_parser_samples_foreach (parser_t *abstract, sample_callback_t callback, void *userdata) +suunto_solution_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t callback, void *userdata) { if (! parser_is_suunto_solution (abstract)) return DC_STATUS_INVALIDARGS; @@ -201,13 +201,13 @@ suunto_solution_parser_samples_foreach (parser_t *abstract, sample_callback_t ca unsigned int offset = 3; while (offset < size && data[offset] != 0x80) { - parser_sample_value_t sample = {0}; + dc_sample_value_t sample = {0}; unsigned char value = data[offset++]; if (value < 0x7e || value > 0x82) { // Time (minutes). time += 3 * 60; sample.time = time; - if (callback) callback (SAMPLE_TYPE_TIME, sample, userdata); + if (callback) callback (DC_SAMPLE_TIME, sample, userdata); // Depth (ft). depth += (signed char) value; @@ -220,7 +220,7 @@ suunto_solution_parser_samples_foreach (parser_t *abstract, sample_callback_t ca depth += (signed char) data[offset++]; } sample.depth = depth * FEET; - if (callback) callback (SAMPLE_TYPE_DEPTH, sample, userdata); + if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); } else { // Event. sample.event.time = 0; @@ -241,7 +241,7 @@ suunto_solution_parser_samples_foreach (parser_t *abstract, sample_callback_t ca break; } - if (callback) callback (SAMPLE_TYPE_EVENT, sample, userdata); + if (callback) callback (DC_SAMPLE_EVENT, sample, userdata); } } diff --git a/src/suunto_vyper.c b/src/suunto_vyper.c index 3727f86..ef40abe 100644 --- a/src/suunto_vyper.c +++ b/src/suunto_vyper.c @@ -51,11 +51,11 @@ typedef struct suunto_vyper_device_t { unsigned int delay; } suunto_vyper_device_t; -static dc_status_t suunto_vyper_device_read (device_t *abstract, unsigned int address, unsigned char data[], unsigned int size); -static dc_status_t suunto_vyper_device_write (device_t *abstract, unsigned int address, const unsigned char data[], unsigned int size); -static dc_status_t suunto_vyper_device_dump (device_t *abstract, dc_buffer_t *buffer); -static dc_status_t suunto_vyper_device_foreach (device_t *abstract, dive_callback_t callback, void *userdata); -static dc_status_t suunto_vyper_device_close (device_t *abstract); +static dc_status_t suunto_vyper_device_read (dc_device_t *abstract, unsigned int address, unsigned char data[], unsigned int size); +static dc_status_t suunto_vyper_device_write (dc_device_t *abstract, unsigned int address, const unsigned char data[], unsigned int size); +static dc_status_t suunto_vyper_device_dump (dc_device_t *abstract, dc_buffer_t *buffer); +static dc_status_t suunto_vyper_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, void *userdata); +static dc_status_t suunto_vyper_device_close (dc_device_t *abstract); static const device_backend_t suunto_vyper_device_backend = { DC_FAMILY_SUUNTO_VYPER, @@ -86,7 +86,7 @@ static const suunto_common_layout_t suunto_spyder_layout = { static int -device_is_suunto_vyper (device_t *abstract) +device_is_suunto_vyper (dc_device_t *abstract) { if (abstract == NULL) return 0; @@ -96,7 +96,7 @@ device_is_suunto_vyper (device_t *abstract) dc_status_t -suunto_vyper_device_open (device_t **out, const char* name) +suunto_vyper_device_open (dc_device_t **out, const char *name) { if (out == NULL) return DC_STATUS_INVALIDARGS; @@ -154,14 +154,14 @@ suunto_vyper_device_open (device_t **out, const char* name) // Make sure everything is in a sane state. serial_flush (device->port, SERIAL_QUEUE_BOTH); - *out = (device_t*) device; + *out = (dc_device_t*) device; return DC_STATUS_SUCCESS; } static dc_status_t -suunto_vyper_device_close (device_t *abstract) +suunto_vyper_device_close (dc_device_t *abstract) { suunto_vyper_device_t *device = (suunto_vyper_device_t*) abstract; @@ -182,7 +182,7 @@ suunto_vyper_device_close (device_t *abstract) dc_status_t -suunto_vyper_device_set_delay (device_t *abstract, unsigned int delay) +suunto_vyper_device_set_delay (dc_device_t *abstract, unsigned int delay) { suunto_vyper_device_t *device = (suunto_vyper_device_t*) abstract; @@ -236,7 +236,7 @@ suunto_vyper_transfer (suunto_vyper_device_t *device, const unsigned char comman { assert (asize >= size + 2); - device_t *abstract = (device_t *) device; + dc_device_t *abstract = (dc_device_t *) device; if (device_is_cancelled (abstract)) return DC_STATUS_CANCELLED; @@ -274,7 +274,7 @@ suunto_vyper_transfer (suunto_vyper_device_t *device, const unsigned char comman static dc_status_t -suunto_vyper_device_read (device_t *abstract, unsigned int address, unsigned char data[], unsigned int size) +suunto_vyper_device_read (dc_device_t *abstract, unsigned int address, unsigned char data[], unsigned int size) { suunto_vyper_device_t *device = (suunto_vyper_device_t*) abstract; @@ -313,7 +313,7 @@ suunto_vyper_device_read (device_t *abstract, unsigned int address, unsigned cha static dc_status_t -suunto_vyper_device_write (device_t *abstract, unsigned int address, const unsigned char data[], unsigned int size) +suunto_vyper_device_write (dc_device_t *abstract, unsigned int address, const unsigned char data[], unsigned int size) { suunto_vyper_device_t *device = (suunto_vyper_device_t*) abstract; @@ -358,7 +358,7 @@ suunto_vyper_device_write (device_t *abstract, unsigned int address, const unsig static dc_status_t -suunto_vyper_read_dive (device_t *abstract, dc_buffer_t *buffer, int init, device_progress_t *progress) +suunto_vyper_read_dive (dc_device_t *abstract, dc_buffer_t *buffer, int init, dc_event_progress_t *progress) { suunto_vyper_device_t *device = (suunto_vyper_device_t*) abstract; @@ -438,7 +438,7 @@ suunto_vyper_read_dive (device_t *abstract, dc_buffer_t *buffer, int init, devic // Update and emit a progress event. if (progress) { progress->current += len; - device_event_emit (abstract, DEVICE_EVENT_PROGRESS, progress); + device_event_emit (abstract, DC_EVENT_PROGRESS, progress); } // Append the package to the output buffer. @@ -477,7 +477,7 @@ suunto_vyper_read_dive (device_t *abstract, dc_buffer_t *buffer, int init, devic dc_status_t -suunto_vyper_device_read_dive (device_t *abstract, dc_buffer_t *buffer, int init) +suunto_vyper_device_read_dive (dc_device_t *abstract, dc_buffer_t *buffer, int init) { if (! device_is_suunto_vyper (abstract)) return DC_STATUS_INVALIDARGS; @@ -487,7 +487,7 @@ suunto_vyper_device_read_dive (device_t *abstract, dc_buffer_t *buffer, int init static dc_status_t -suunto_vyper_device_dump (device_t *abstract, dc_buffer_t *buffer) +suunto_vyper_device_dump (dc_device_t *abstract, dc_buffer_t *buffer) { if (! device_is_suunto_vyper (abstract)) return DC_STATUS_INVALIDARGS; @@ -505,7 +505,7 @@ suunto_vyper_device_dump (device_t *abstract, dc_buffer_t *buffer) static dc_status_t -suunto_vyper_device_foreach (device_t *abstract, dive_callback_t callback, void *userdata) +suunto_vyper_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, void *userdata) { suunto_common_device_t *device = (suunto_common_device_t*) abstract; @@ -513,9 +513,9 @@ suunto_vyper_device_foreach (device_t *abstract, dive_callback_t callback, void return DC_STATUS_INVALIDARGS; // Enable progress notifications. - device_progress_t progress = DEVICE_PROGRESS_INITIALIZER; + dc_event_progress_t progress = EVENT_PROGRESS_INITIALIZER; progress.maximum = SUUNTO_VYPER_MEMORY_SIZE; - device_event_emit (abstract, DEVICE_EVENT_PROGRESS, &progress); + device_event_emit (abstract, DC_EVENT_PROGRESS, &progress); // Read the device info. The Vyper and the Spyder store this data // in a different location. To minimize the number of (slow) reads, @@ -540,14 +540,14 @@ suunto_vyper_device_foreach (device_t *abstract, dive_callback_t callback, void progress.maximum = sizeof (header) + (layout->rb_profile_end - layout->rb_profile_begin); progress.current += sizeof (header); - device_event_emit (abstract, DEVICE_EVENT_PROGRESS, &progress); + device_event_emit (abstract, DC_EVENT_PROGRESS, &progress); // Emit a device info event. - device_devinfo_t devinfo; + dc_event_devinfo_t devinfo; devinfo.model = header[hoffset + 0]; devinfo.firmware = header[hoffset + 1]; devinfo.serial = array_uint32_be (header + hoffset + 2); - device_event_emit (abstract, DEVICE_EVENT_DEVINFO, &devinfo); + device_event_emit (abstract, DC_EVENT_DEVINFO, &devinfo); // Allocate a memory buffer. dc_buffer_t *buffer = dc_buffer_new (layout->rb_profile_end - layout->rb_profile_begin); @@ -584,7 +584,7 @@ suunto_vyper_device_foreach (device_t *abstract, dive_callback_t callback, void dc_status_t -suunto_vyper_extract_dives (device_t *abstract, const unsigned char data[], unsigned int size, dive_callback_t callback, void *userdata) +suunto_vyper_extract_dives (dc_device_t *abstract, const unsigned char data[], unsigned int size, dc_dive_callback_t callback, void *userdata) { suunto_common_device_t *device = (suunto_common_device_t*) abstract; diff --git a/src/suunto_vyper2.c b/src/suunto_vyper2.c index 3d40bcf..0c02dbb 100644 --- a/src/suunto_vyper2.c +++ b/src/suunto_vyper2.c @@ -40,8 +40,8 @@ typedef struct suunto_vyper2_device_t { serial_t *port; } suunto_vyper2_device_t; -static dc_status_t suunto_vyper2_device_packet (device_t *abstract, const unsigned char command[], unsigned int csize, unsigned char answer[], unsigned int asize, unsigned int size); -static dc_status_t suunto_vyper2_device_close (device_t *abstract); +static dc_status_t suunto_vyper2_device_packet (dc_device_t *abstract, const unsigned char command[], unsigned int csize, unsigned char answer[], unsigned int asize, unsigned int size); +static dc_status_t suunto_vyper2_device_close (dc_device_t *abstract); static const suunto_common2_device_backend_t suunto_vyper2_device_backend = { { @@ -65,7 +65,7 @@ static const suunto_common2_layout_t suunto_vyper2_layout = { }; static int -device_is_suunto_vyper2 (device_t *abstract) +device_is_suunto_vyper2 (dc_device_t *abstract) { if (abstract == NULL) return 0; @@ -75,7 +75,7 @@ device_is_suunto_vyper2 (device_t *abstract) dc_status_t -suunto_vyper2_device_open (device_t **out, const char* name) +suunto_vyper2_device_open (dc_device_t **out, const char *name) { if (out == NULL) return DC_STATUS_INVALIDARGS; @@ -138,14 +138,14 @@ suunto_vyper2_device_open (device_t **out, const char* name) // Override the base class values. device->base.layout = &suunto_vyper2_layout; - *out = (device_t*) device; + *out = (dc_device_t*) device; return DC_STATUS_SUCCESS; } static dc_status_t -suunto_vyper2_device_close (device_t *abstract) +suunto_vyper2_device_close (dc_device_t *abstract) { suunto_vyper2_device_t *device = (suunto_vyper2_device_t*) abstract; @@ -166,7 +166,7 @@ suunto_vyper2_device_close (device_t *abstract) static dc_status_t -suunto_vyper2_device_packet (device_t *abstract, const unsigned char command[], unsigned int csize, unsigned char answer[], unsigned int asize, unsigned int size) +suunto_vyper2_device_packet (dc_device_t *abstract, const unsigned char command[], unsigned int csize, unsigned char answer[], unsigned int asize, unsigned int size) { suunto_vyper2_device_t *device = (suunto_vyper2_device_t *) abstract; @@ -226,7 +226,7 @@ suunto_vyper2_device_packet (device_t *abstract, const unsigned char command[], dc_status_t -suunto_vyper2_device_reset_maxdepth (device_t *abstract) +suunto_vyper2_device_reset_maxdepth (dc_device_t *abstract) { if (! device_is_suunto_vyper2 (abstract)) return DC_STATUS_INVALIDARGS; diff --git a/src/suunto_vyper_parser.c b/src/suunto_vyper_parser.c index 1dda5b6..d36db95 100644 --- a/src/suunto_vyper_parser.c +++ b/src/suunto_vyper_parser.c @@ -30,18 +30,18 @@ typedef struct suunto_vyper_parser_t suunto_vyper_parser_t; struct suunto_vyper_parser_t { - parser_t base; + dc_parser_t base; // Cached fields. unsigned int cached; unsigned int divetime; unsigned int maxdepth; }; -static dc_status_t suunto_vyper_parser_set_data (parser_t *abstract, const unsigned char *data, unsigned int size); -static dc_status_t suunto_vyper_parser_get_datetime (parser_t *abstract, dc_datetime_t *datetime); -static dc_status_t suunto_vyper_parser_get_field (parser_t *abstract, parser_field_type_t type, unsigned int flags, void *value); -static dc_status_t suunto_vyper_parser_samples_foreach (parser_t *abstract, sample_callback_t callback, void *userdata); -static dc_status_t suunto_vyper_parser_destroy (parser_t *abstract); +static dc_status_t suunto_vyper_parser_set_data (dc_parser_t *abstract, const unsigned char *data, unsigned int size); +static dc_status_t suunto_vyper_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *datetime); +static dc_status_t suunto_vyper_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsigned int flags, void *value); +static dc_status_t suunto_vyper_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t callback, void *userdata); +static dc_status_t suunto_vyper_parser_destroy (dc_parser_t *abstract); static const parser_backend_t suunto_vyper_parser_backend = { DC_FAMILY_SUUNTO_VYPER, @@ -54,7 +54,7 @@ static const parser_backend_t suunto_vyper_parser_backend = { static int -parser_is_suunto_vyper (parser_t *abstract) +parser_is_suunto_vyper (dc_parser_t *abstract) { if (abstract == NULL) return 0; @@ -64,7 +64,7 @@ parser_is_suunto_vyper (parser_t *abstract) dc_status_t -suunto_vyper_parser_create (parser_t **out) +suunto_vyper_parser_create (dc_parser_t **out) { if (out == NULL) return DC_STATUS_INVALIDARGS; @@ -84,14 +84,14 @@ suunto_vyper_parser_create (parser_t **out) parser->divetime = 0; parser->maxdepth = 0; - *out = (parser_t*) parser; + *out = (dc_parser_t*) parser; return DC_STATUS_SUCCESS; } static dc_status_t -suunto_vyper_parser_destroy (parser_t *abstract) +suunto_vyper_parser_destroy (dc_parser_t *abstract) { if (! parser_is_suunto_vyper (abstract)) return DC_STATUS_INVALIDARGS; @@ -104,7 +104,7 @@ suunto_vyper_parser_destroy (parser_t *abstract) static dc_status_t -suunto_vyper_parser_set_data (parser_t *abstract, const unsigned char *data, unsigned int size) +suunto_vyper_parser_set_data (dc_parser_t *abstract, const unsigned char *data, unsigned int size) { suunto_vyper_parser_t *parser = (suunto_vyper_parser_t *) abstract; @@ -121,7 +121,7 @@ suunto_vyper_parser_set_data (parser_t *abstract, const unsigned char *data, uns static dc_status_t -suunto_vyper_parser_get_datetime (parser_t *abstract, dc_datetime_t *datetime) +suunto_vyper_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *datetime) { if (abstract->size < 9 + 5) return DC_STATUS_DATAFORMAT; @@ -142,7 +142,7 @@ suunto_vyper_parser_get_datetime (parser_t *abstract, dc_datetime_t *datetime) static dc_status_t -suunto_vyper_parser_get_field (parser_t *abstract, parser_field_type_t type, unsigned int flags, void *value) +suunto_vyper_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsigned int flags, void *value) { suunto_vyper_parser_t *parser = (suunto_vyper_parser_t *) abstract; @@ -177,20 +177,20 @@ suunto_vyper_parser_get_field (parser_t *abstract, parser_field_type_t type, uns parser->maxdepth = maxdepth; } - gasmix_t *gas = (gasmix_t *) value; + dc_gasmix_t *gas = (dc_gasmix_t *) value; if (value) { switch (type) { - case FIELD_TYPE_DIVETIME: + case DC_FIELD_DIVETIME: *((unsigned int *) value) = parser->divetime; break; - case FIELD_TYPE_MAXDEPTH: + case DC_FIELD_MAXDEPTH: *((double *) value) = parser->maxdepth * FEET; break; - case FIELD_TYPE_GASMIX_COUNT: + case DC_FIELD_GASMIX_COUNT: *((unsigned int *) value) = 1; break; - case FIELD_TYPE_GASMIX: + case DC_FIELD_GASMIX: gas->helium = 0.0; if (data[6]) gas->oxygen = data[6] / 100.0; @@ -207,7 +207,7 @@ suunto_vyper_parser_get_field (parser_t *abstract, parser_field_type_t type, uns } static dc_status_t -suunto_vyper_parser_samples_foreach (parser_t *abstract, sample_callback_t callback, void *userdata) +suunto_vyper_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t callback, void *userdata) { if (! parser_is_suunto_vyper (abstract)) return DC_STATUS_INVALIDARGS; @@ -239,24 +239,24 @@ suunto_vyper_parser_samples_foreach (parser_t *abstract, sample_callback_t callb unsigned int interval = data[3]; unsigned int complete = 1; - parser_sample_value_t sample = {0}; + dc_sample_value_t sample = {0}; // Time sample.time = time; - if (callback) callback (SAMPLE_TYPE_TIME, sample, userdata); + if (callback) callback (DC_SAMPLE_TIME, sample, userdata); // Temperature (°C) sample.temperature = (signed char) data[8]; - if (callback) callback (SAMPLE_TYPE_TEMPERATURE, sample, userdata); + if (callback) callback (DC_SAMPLE_TEMPERATURE, sample, userdata); // Tank Pressure (2 bar) sample.pressure.tank = 0; sample.pressure.value = data[5] * 2; - if (callback) callback (SAMPLE_TYPE_PRESSURE, sample, userdata); + if (callback) callback (DC_SAMPLE_PRESSURE, sample, userdata); // Depth (0 ft) sample.depth = 0; - if (callback) callback (SAMPLE_TYPE_DEPTH, sample, userdata); + if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); depth = 0; offset = 14; @@ -267,7 +267,7 @@ suunto_vyper_parser_samples_foreach (parser_t *abstract, sample_callback_t callb // Time (seconds). time += interval; sample.time = time; - if (callback) callback (SAMPLE_TYPE_TIME, sample, userdata); + if (callback) callback (DC_SAMPLE_TIME, sample, userdata); complete = 0; } @@ -278,12 +278,12 @@ suunto_vyper_parser_samples_foreach (parser_t *abstract, sample_callback_t callb // Temperature at maximum depth (°C) if (depth == maxdepth) { sample.temperature = (signed char) data[marker + 1]; - if (callback) callback (SAMPLE_TYPE_TEMPERATURE, sample, userdata); + if (callback) callback (DC_SAMPLE_TEMPERATURE, sample, userdata); } // Depth (ft). sample.depth = depth * FEET; - if (callback) callback (SAMPLE_TYPE_DEPTH, sample, userdata); + if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); complete = 1; } else { @@ -324,7 +324,7 @@ suunto_vyper_parser_samples_foreach (parser_t *abstract, sample_callback_t callb break; } - if (callback) callback (SAMPLE_TYPE_EVENT, sample, userdata); + if (callback) callback (DC_SAMPLE_EVENT, sample, userdata); } } @@ -332,21 +332,21 @@ suunto_vyper_parser_samples_foreach (parser_t *abstract, sample_callback_t callb if (complete) { time += interval; sample.time = time; - if (callback) callback (SAMPLE_TYPE_TIME, sample, userdata); + if (callback) callback (DC_SAMPLE_TIME, sample, userdata); } // Temperature (°C) sample.temperature = (signed char) data[offset + 2]; - if (callback) callback (SAMPLE_TYPE_TEMPERATURE, sample, userdata); + if (callback) callback (DC_SAMPLE_TEMPERATURE, sample, userdata); // Tank Pressure (2 bar) sample.pressure.tank = 0; sample.pressure.value = data[offset + 3] * 2; - if (callback) callback (SAMPLE_TYPE_PRESSURE, sample, userdata); + if (callback) callback (DC_SAMPLE_PRESSURE, sample, userdata); // Depth (0 ft) sample.depth = 0; - if (callback) callback (SAMPLE_TYPE_DEPTH, sample, userdata); + if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); return DC_STATUS_SUCCESS; } diff --git a/src/uwatec_aladin.c b/src/uwatec_aladin.c index 46e381d..0e9bb81 100644 --- a/src/uwatec_aladin.c +++ b/src/uwatec_aladin.c @@ -44,17 +44,17 @@ #define HEADER 4 typedef struct uwatec_aladin_device_t { - device_t base; + dc_device_t base; serial_t *port; unsigned int timestamp; unsigned int devtime; dc_ticks_t systime; } uwatec_aladin_device_t ; -static dc_status_t uwatec_aladin_device_set_fingerprint (device_t *abstract, const unsigned char data[], unsigned int size); -static dc_status_t uwatec_aladin_device_dump (device_t *abstract, dc_buffer_t *buffer); -static dc_status_t uwatec_aladin_device_foreach (device_t *abstract, dive_callback_t callback, void *userdata); -static dc_status_t uwatec_aladin_device_close (device_t *abstract); +static dc_status_t uwatec_aladin_device_set_fingerprint (dc_device_t *abstract, const unsigned char data[], unsigned int size); +static dc_status_t uwatec_aladin_device_dump (dc_device_t *abstract, dc_buffer_t *buffer); +static dc_status_t uwatec_aladin_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, void *userdata); +static dc_status_t uwatec_aladin_device_close (dc_device_t *abstract); static const device_backend_t uwatec_aladin_device_backend = { DC_FAMILY_UWATEC_ALADIN, @@ -68,7 +68,7 @@ static const device_backend_t uwatec_aladin_device_backend = { }; static int -device_is_uwatec_aladin (device_t *abstract) +device_is_uwatec_aladin (dc_device_t *abstract) { if (abstract == NULL) return 0; @@ -78,7 +78,7 @@ device_is_uwatec_aladin (device_t *abstract) dc_status_t -uwatec_aladin_device_open (device_t **out, const char* name) +uwatec_aladin_device_open (dc_device_t **out, const char *name) { if (out == NULL) return DC_STATUS_INVALIDARGS; @@ -133,14 +133,14 @@ uwatec_aladin_device_open (device_t **out, const char* name) return DC_STATUS_IO; } - *out = (device_t*) device; + *out = (dc_device_t*) device; return DC_STATUS_SUCCESS; } static dc_status_t -uwatec_aladin_device_close (device_t *abstract) +uwatec_aladin_device_close (dc_device_t *abstract) { uwatec_aladin_device_t *device = (uwatec_aladin_device_t*) abstract; @@ -161,7 +161,7 @@ uwatec_aladin_device_close (device_t *abstract) dc_status_t -uwatec_aladin_device_set_timestamp (device_t *abstract, unsigned int timestamp) +uwatec_aladin_device_set_timestamp (dc_device_t *abstract, unsigned int timestamp) { uwatec_aladin_device_t *device = (uwatec_aladin_device_t*) abstract; @@ -175,7 +175,7 @@ uwatec_aladin_device_set_timestamp (device_t *abstract, unsigned int timestamp) static dc_status_t -uwatec_aladin_device_set_fingerprint (device_t *abstract, const unsigned char data[], unsigned int size) +uwatec_aladin_device_set_fingerprint (dc_device_t *abstract, const unsigned char data[], unsigned int size) { uwatec_aladin_device_t *device = (uwatec_aladin_device_t*) abstract; @@ -195,7 +195,7 @@ uwatec_aladin_device_set_fingerprint (device_t *abstract, const unsigned char da static dc_status_t -uwatec_aladin_device_dump (device_t *abstract, dc_buffer_t *buffer) +uwatec_aladin_device_dump (dc_device_t *abstract, dc_buffer_t *buffer) { uwatec_aladin_device_t *device = (uwatec_aladin_device_t*) abstract; @@ -210,9 +210,9 @@ uwatec_aladin_device_dump (device_t *abstract, dc_buffer_t *buffer) } // Enable progress notifications. - device_progress_t progress = DEVICE_PROGRESS_INITIALIZER; + dc_event_progress_t progress = EVENT_PROGRESS_INITIALIZER; progress.maximum = UWATEC_ALADIN_MEMORY_SIZE + 2; - device_event_emit (abstract, DEVICE_EVENT_PROGRESS, &progress); + device_event_emit (abstract, DC_EVENT_PROGRESS, &progress); unsigned char answer[UWATEC_ALADIN_MEMORY_SIZE + 2] = {0}; @@ -230,7 +230,7 @@ uwatec_aladin_device_dump (device_t *abstract, dc_buffer_t *buffer) i++; // Continue. } else { i = 0; // Reset. - device_event_emit (abstract, DEVICE_EVENT_WAITING, NULL); + device_event_emit (abstract, DC_EVENT_WAITING, NULL); } } @@ -239,7 +239,7 @@ uwatec_aladin_device_dump (device_t *abstract, dc_buffer_t *buffer) // Update and emit a progress event. progress.current += 4; - device_event_emit (abstract, DEVICE_EVENT_PROGRESS, &progress); + device_event_emit (abstract, DC_EVENT_PROGRESS, &progress); // Receive the remaining part of the package. int rc = serial_read (device->port, answer + 4, sizeof (answer) - 4); @@ -250,7 +250,7 @@ uwatec_aladin_device_dump (device_t *abstract, dc_buffer_t *buffer) // Update and emit a progress event. progress.current += sizeof (answer) - 4; - device_event_emit (abstract, DEVICE_EVENT_PROGRESS, &progress); + device_event_emit (abstract, DC_EVENT_PROGRESS, &progress); // Reverse the bit order. array_reverse_bits (answer, sizeof (answer)); @@ -268,10 +268,10 @@ uwatec_aladin_device_dump (device_t *abstract, dc_buffer_t *buffer) device->devtime = array_uint32_be (answer + HEADER + 0x7f8); // Emit a clock event. - device_clock_t clock; + dc_event_clock_t clock; clock.systime = device->systime; clock.devtime = device->devtime; - device_event_emit (abstract, DEVICE_EVENT_CLOCK, &clock); + device_event_emit (abstract, DC_EVENT_CLOCK, &clock); dc_buffer_append (buffer, answer, UWATEC_ALADIN_MEMORY_SIZE); @@ -280,7 +280,7 @@ uwatec_aladin_device_dump (device_t *abstract, dc_buffer_t *buffer) static dc_status_t -uwatec_aladin_device_foreach (device_t *abstract, dive_callback_t callback, void *userdata) +uwatec_aladin_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, void *userdata) { if (! device_is_uwatec_aladin (abstract)) return DC_STATUS_INVALIDARGS; @@ -297,11 +297,11 @@ uwatec_aladin_device_foreach (device_t *abstract, dive_callback_t callback, void // Emit a device info event. unsigned char *data = dc_buffer_get_data (buffer); - device_devinfo_t devinfo; + dc_event_devinfo_t devinfo; devinfo.model = data[HEADER + 0x7bc]; devinfo.firmware = 0; devinfo.serial = array_uint24_be (data + HEADER + 0x7ed); - device_event_emit (abstract, DEVICE_EVENT_DEVINFO, &devinfo); + device_event_emit (abstract, DC_EVENT_DEVINFO, &devinfo); rc = uwatec_aladin_extract_dives (abstract, dc_buffer_get_data (buffer), dc_buffer_get_size (buffer), callback, userdata); @@ -313,7 +313,7 @@ uwatec_aladin_device_foreach (device_t *abstract, dive_callback_t callback, void dc_status_t -uwatec_aladin_extract_dives (device_t *abstract, const unsigned char* data, unsigned int size, dive_callback_t callback, void *userdata) +uwatec_aladin_extract_dives (dc_device_t *abstract, const unsigned char* data, unsigned int size, dc_dive_callback_t callback, void *userdata) { uwatec_aladin_device_t *device = (uwatec_aladin_device_t*) abstract; diff --git a/src/uwatec_memomouse.c b/src/uwatec_memomouse.c index c6f05cf..f46f7bb 100644 --- a/src/uwatec_memomouse.c +++ b/src/uwatec_memomouse.c @@ -42,17 +42,17 @@ #define NAK 0xA8 typedef struct uwatec_memomouse_device_t { - device_t base; + dc_device_t base; serial_t *port; unsigned int timestamp; unsigned int devtime; dc_ticks_t systime; } uwatec_memomouse_device_t; -static dc_status_t uwatec_memomouse_device_set_fingerprint (device_t *device, const unsigned char data[], unsigned int size); -static dc_status_t uwatec_memomouse_device_dump (device_t *abstract, dc_buffer_t *buffer); -static dc_status_t uwatec_memomouse_device_foreach (device_t *abstract, dive_callback_t callback, void *userdata); -static dc_status_t uwatec_memomouse_device_close (device_t *abstract); +static dc_status_t uwatec_memomouse_device_set_fingerprint (dc_device_t *device, const unsigned char data[], unsigned int size); +static dc_status_t uwatec_memomouse_device_dump (dc_device_t *abstract, dc_buffer_t *buffer); +static dc_status_t uwatec_memomouse_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, void *userdata); +static dc_status_t uwatec_memomouse_device_close (dc_device_t *abstract); static const device_backend_t uwatec_memomouse_device_backend = { DC_FAMILY_UWATEC_MEMOMOUSE, @@ -66,7 +66,7 @@ static const device_backend_t uwatec_memomouse_device_backend = { }; static int -device_is_uwatec_memomouse (device_t *abstract) +device_is_uwatec_memomouse (dc_device_t *abstract) { if (abstract == NULL) return 0; @@ -76,7 +76,7 @@ device_is_uwatec_memomouse (device_t *abstract) dc_status_t -uwatec_memomouse_device_open (device_t **out, const char* name) +uwatec_memomouse_device_open (dc_device_t **out, const char *name) { if (out == NULL) return DC_STATUS_INVALIDARGS; @@ -134,14 +134,14 @@ uwatec_memomouse_device_open (device_t **out, const char* name) // Make sure everything is in a sane state. serial_flush (device->port, SERIAL_QUEUE_BOTH); - *out = (device_t*) device; + *out = (dc_device_t*) device; return DC_STATUS_SUCCESS; } static dc_status_t -uwatec_memomouse_device_close (device_t *abstract) +uwatec_memomouse_device_close (dc_device_t *abstract) { uwatec_memomouse_device_t *device = (uwatec_memomouse_device_t*) abstract; @@ -162,7 +162,7 @@ uwatec_memomouse_device_close (device_t *abstract) dc_status_t -uwatec_memomouse_device_set_timestamp (device_t *abstract, unsigned int timestamp) +uwatec_memomouse_device_set_timestamp (dc_device_t *abstract, unsigned int timestamp) { uwatec_memomouse_device_t *device = (uwatec_memomouse_device_t*) abstract; @@ -176,7 +176,7 @@ uwatec_memomouse_device_set_timestamp (device_t *abstract, unsigned int timestam static dc_status_t -uwatec_memomouse_device_set_fingerprint (device_t *abstract, const unsigned char data[], unsigned int size) +uwatec_memomouse_device_set_fingerprint (dc_device_t *abstract, const unsigned char data[], unsigned int size) { uwatec_memomouse_device_t *device = (uwatec_memomouse_device_t*) abstract; @@ -268,7 +268,7 @@ uwatec_memomouse_read_packet_outer (uwatec_memomouse_device_t *device, unsigned static dc_status_t -uwatec_memomouse_read_packet_inner (uwatec_memomouse_device_t *device, dc_buffer_t *buffer, device_progress_t *progress) +uwatec_memomouse_read_packet_inner (uwatec_memomouse_device_t *device, dc_buffer_t *buffer, dc_event_progress_t *progress) { // Erase the current contents of the buffer. if (!dc_buffer_clear (buffer)) { @@ -320,7 +320,7 @@ uwatec_memomouse_read_packet_inner (uwatec_memomouse_device_t *device, dc_buffer if (progress) { progress->maximum = total; progress->current += length; - device_event_emit (&device->base, DEVICE_EVENT_PROGRESS, progress); + device_event_emit (&device->base, DC_EVENT_PROGRESS, progress); } // Append the packet to the buffer. @@ -350,11 +350,11 @@ uwatec_memomouse_read_packet_inner (uwatec_memomouse_device_t *device, dc_buffer static dc_status_t uwatec_memomouse_dump_internal (uwatec_memomouse_device_t *device, dc_buffer_t *buffer) { - device_t *abstract = (device_t *) device; + dc_device_t *abstract = (dc_device_t *) device; // Enable progress notifications. - device_progress_t progress = DEVICE_PROGRESS_INITIALIZER; - device_event_emit (&device->base, DEVICE_EVENT_PROGRESS, &progress); + dc_event_progress_t progress = EVENT_PROGRESS_INITIALIZER; + device_event_emit (&device->base, DC_EVENT_PROGRESS, &progress); // Waiting for greeting message. while (serial_get_received (device->port) == 0) { @@ -430,7 +430,7 @@ uwatec_memomouse_dump_internal (uwatec_memomouse_device_t *device, dc_buffer_t * if (device_is_cancelled (abstract)) return DC_STATUS_CANCELLED; - device_event_emit (&device->base, DEVICE_EVENT_WAITING, NULL); + device_event_emit (&device->base, DC_EVENT_WAITING, NULL); serial_sleep (100); } @@ -447,17 +447,17 @@ uwatec_memomouse_dump_internal (uwatec_memomouse_device_t *device, dc_buffer_t * device->devtime = array_uint32_le (dc_buffer_get_data (buffer) + 1); // Emit a clock event. - device_clock_t clock; + dc_event_clock_t clock; clock.systime = device->systime; clock.devtime = device->devtime; - device_event_emit ((device_t *) device, DEVICE_EVENT_CLOCK, &clock); + device_event_emit ((dc_device_t *) device, DC_EVENT_CLOCK, &clock); return DC_STATUS_SUCCESS; } static dc_status_t -uwatec_memomouse_device_dump (device_t *abstract, dc_buffer_t *buffer) +uwatec_memomouse_device_dump (dc_device_t *abstract, dc_buffer_t *buffer) { uwatec_memomouse_device_t *device = (uwatec_memomouse_device_t*) abstract; @@ -494,7 +494,7 @@ uwatec_memomouse_device_dump (device_t *abstract, dc_buffer_t *buffer) static dc_status_t -uwatec_memomouse_device_foreach (device_t *abstract, dive_callback_t callback, void *userdata) +uwatec_memomouse_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, void *userdata) { if (! device_is_uwatec_memomouse (abstract)) return DC_STATUS_INVALIDARGS; @@ -519,7 +519,7 @@ uwatec_memomouse_device_foreach (device_t *abstract, dive_callback_t callback, v dc_status_t -uwatec_memomouse_extract_dives (device_t *abstract, const unsigned char data[], unsigned int size, dive_callback_t callback, void *userdata) +uwatec_memomouse_extract_dives (dc_device_t *abstract, const unsigned char data[], unsigned int size, dc_dive_callback_t callback, void *userdata) { if (abstract && !device_is_uwatec_memomouse (abstract)) return DC_STATUS_INVALIDARGS; @@ -552,11 +552,11 @@ uwatec_memomouse_extract_dives (device_t *abstract, const unsigned char data[], // only needs to be reported once. if (abstract && ndives == 0) { // Emit a device info event. - device_devinfo_t devinfo; + dc_event_devinfo_t devinfo; devinfo.model = data[current + 3]; devinfo.firmware = 0; devinfo.serial = array_uint24_be (data + current); - device_event_emit (abstract, DEVICE_EVENT_DEVINFO, &devinfo); + device_event_emit (abstract, DC_EVENT_DEVINFO, &devinfo); } // Move to the next dive. diff --git a/src/uwatec_memomouse_parser.c b/src/uwatec_memomouse_parser.c index e3ad8d9..57557cb 100644 --- a/src/uwatec_memomouse_parser.c +++ b/src/uwatec_memomouse_parser.c @@ -30,16 +30,16 @@ typedef struct uwatec_memomouse_parser_t uwatec_memomouse_parser_t; struct uwatec_memomouse_parser_t { - parser_t base; + dc_parser_t base; unsigned int devtime; dc_ticks_t systime; }; -static dc_status_t uwatec_memomouse_parser_set_data (parser_t *abstract, const unsigned char *data, unsigned int size); -static dc_status_t uwatec_memomouse_parser_get_datetime (parser_t *abstract, dc_datetime_t *datetime); -static dc_status_t uwatec_memomouse_parser_get_field (parser_t *abstract, parser_field_type_t type, unsigned int flags, void *value); -static dc_status_t uwatec_memomouse_parser_samples_foreach (parser_t *abstract, sample_callback_t callback, void *userdata); -static dc_status_t uwatec_memomouse_parser_destroy (parser_t *abstract); +static dc_status_t uwatec_memomouse_parser_set_data (dc_parser_t *abstract, const unsigned char *data, unsigned int size); +static dc_status_t uwatec_memomouse_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *datetime); +static dc_status_t uwatec_memomouse_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsigned int flags, void *value); +static dc_status_t uwatec_memomouse_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t callback, void *userdata); +static dc_status_t uwatec_memomouse_parser_destroy (dc_parser_t *abstract); static const parser_backend_t uwatec_memomouse_parser_backend = { DC_FAMILY_UWATEC_MEMOMOUSE, @@ -52,7 +52,7 @@ static const parser_backend_t uwatec_memomouse_parser_backend = { static int -parser_is_uwatec_memomouse (parser_t *abstract) +parser_is_uwatec_memomouse (dc_parser_t *abstract) { if (abstract == NULL) return 0; @@ -62,7 +62,7 @@ parser_is_uwatec_memomouse (parser_t *abstract) dc_status_t -uwatec_memomouse_parser_create (parser_t **out, unsigned int devtime, dc_ticks_t systime) +uwatec_memomouse_parser_create (dc_parser_t **out, unsigned int devtime, dc_ticks_t systime) { if (out == NULL) return DC_STATUS_INVALIDARGS; @@ -81,14 +81,14 @@ uwatec_memomouse_parser_create (parser_t **out, unsigned int devtime, dc_ticks_t parser->devtime = devtime; parser->systime = systime; - *out = (parser_t*) parser; + *out = (dc_parser_t*) parser; return DC_STATUS_SUCCESS; } static dc_status_t -uwatec_memomouse_parser_destroy (parser_t *abstract) +uwatec_memomouse_parser_destroy (dc_parser_t *abstract) { if (! parser_is_uwatec_memomouse (abstract)) return DC_STATUS_INVALIDARGS; @@ -101,7 +101,7 @@ uwatec_memomouse_parser_destroy (parser_t *abstract) static dc_status_t -uwatec_memomouse_parser_set_data (parser_t *abstract, const unsigned char *data, unsigned int size) +uwatec_memomouse_parser_set_data (dc_parser_t *abstract, const unsigned char *data, unsigned int size) { if (! parser_is_uwatec_memomouse (abstract)) return DC_STATUS_INVALIDARGS; @@ -111,7 +111,7 @@ uwatec_memomouse_parser_set_data (parser_t *abstract, const unsigned char *data, static dc_status_t -uwatec_memomouse_parser_get_datetime (parser_t *abstract, dc_datetime_t *datetime) +uwatec_memomouse_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *datetime) { uwatec_memomouse_parser_t *parser = (uwatec_memomouse_parser_t *) abstract; @@ -130,7 +130,7 @@ uwatec_memomouse_parser_get_datetime (parser_t *abstract, dc_datetime_t *datetim static dc_status_t -uwatec_memomouse_parser_get_field (parser_t *abstract, parser_field_type_t type, unsigned int flags, void *value) +uwatec_memomouse_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsigned int flags, void *value) { const unsigned char *data = abstract->data; unsigned int size = abstract->size; @@ -154,20 +154,20 @@ uwatec_memomouse_parser_get_field (parser_t *abstract, parser_field_type_t type, if (is_oxygen) header += 3; - gasmix_t *gasmix = (gasmix_t *) value; + dc_gasmix_t *gasmix = (dc_gasmix_t *) value; if (value) { switch (type) { - case FIELD_TYPE_DIVETIME: + case DC_FIELD_DIVETIME: *((unsigned int *) value) = ((data[4] & 0x04 ? 100 : 0) + bcd2dec (data[5])) * 60; break; - case FIELD_TYPE_MAXDEPTH: + case DC_FIELD_MAXDEPTH: *((double *) value) = ((array_uint16_be (data + 6) & 0xFFC0) >> 6) * 10.0 / 64.0; break; - case FIELD_TYPE_GASMIX_COUNT: + case DC_FIELD_GASMIX_COUNT: *((unsigned int *) value) = 1; break; - case FIELD_TYPE_GASMIX: + case DC_FIELD_GASMIX: gasmix->helium = 0.0; if (size >= header + 18) { if (is_oxygen) @@ -191,7 +191,7 @@ uwatec_memomouse_parser_get_field (parser_t *abstract, parser_field_type_t type, static dc_status_t -uwatec_memomouse_parser_samples_foreach (parser_t *abstract, sample_callback_t callback, void *userdata) +uwatec_memomouse_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t callback, void *userdata) { if (! parser_is_uwatec_memomouse (abstract)) return DC_STATUS_INVALIDARGS; @@ -222,7 +222,7 @@ uwatec_memomouse_parser_samples_foreach (parser_t *abstract, sample_callback_t c unsigned int offset = header + 18; while (offset + 2 <= size) { - parser_sample_value_t sample = {0}; + dc_sample_value_t sample = {0}; unsigned int value = array_uint16_be (data + offset); unsigned int depth = (value & 0xFFC0) >> 6; @@ -231,11 +231,11 @@ uwatec_memomouse_parser_samples_foreach (parser_t *abstract, sample_callback_t c // Time (seconds) sample.time = time; - if (callback) callback (SAMPLE_TYPE_TIME, sample, userdata); + if (callback) callback (DC_SAMPLE_TIME, sample, userdata); // Depth (meters) sample.depth = depth * 10.0 / 64.0; - if (callback) callback (SAMPLE_TYPE_DEPTH, sample, userdata); + if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); // Warnings for (unsigned int i = 0; i < 6; ++i) { @@ -263,7 +263,7 @@ uwatec_memomouse_parser_samples_foreach (parser_t *abstract, sample_callback_t c sample.event.type = SAMPLE_EVENT_TRANSMITTER; break; } - if (callback) callback (SAMPLE_TYPE_EVENT, sample, userdata); + if (callback) callback (DC_SAMPLE_EVENT, sample, userdata); } } @@ -286,7 +286,7 @@ uwatec_memomouse_parser_samples_foreach (parser_t *abstract, sample_callback_t c offset++; } - if (callback) callback (SAMPLE_TYPE_VENDOR, sample, userdata); + if (callback) callback (DC_SAMPLE_VENDOR, sample, userdata); } time += 20; diff --git a/src/uwatec_smart.c b/src/uwatec_smart.c index 39b067a..1ca24c6 100644 --- a/src/uwatec_smart.c +++ b/src/uwatec_smart.c @@ -35,7 +35,7 @@ ) typedef struct uwatec_smart_device_t { - device_t base; + dc_device_t base; irda_t *socket; unsigned int address; unsigned int timestamp; @@ -43,11 +43,11 @@ typedef struct uwatec_smart_device_t { dc_ticks_t systime; } uwatec_smart_device_t; -static dc_status_t uwatec_smart_device_set_fingerprint (device_t *device, const unsigned char data[], unsigned int size); -static dc_status_t uwatec_smart_device_version (device_t *abstract, unsigned char data[], unsigned int size); -static dc_status_t uwatec_smart_device_dump (device_t *abstract, dc_buffer_t *buffer); -static dc_status_t uwatec_smart_device_foreach (device_t *abstract, dive_callback_t callback, void *userdata); -static dc_status_t uwatec_smart_device_close (device_t *abstract); +static dc_status_t uwatec_smart_device_set_fingerprint (dc_device_t *device, const unsigned char data[], unsigned int size); +static dc_status_t uwatec_smart_device_version (dc_device_t *abstract, unsigned char data[], unsigned int size); +static dc_status_t uwatec_smart_device_dump (dc_device_t *abstract, dc_buffer_t *buffer); +static dc_status_t uwatec_smart_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, void *userdata); +static dc_status_t uwatec_smart_device_close (dc_device_t *abstract); static const device_backend_t uwatec_smart_device_backend = { DC_FAMILY_UWATEC_SMART, @@ -61,7 +61,7 @@ static const device_backend_t uwatec_smart_device_backend = { }; static int -device_is_uwatec_smart (device_t *abstract) +device_is_uwatec_smart (dc_device_t *abstract) { if (abstract == NULL) return 0; @@ -148,7 +148,7 @@ uwatec_smart_handshake (uwatec_smart_device_t *device) dc_status_t -uwatec_smart_device_open (device_t **out) +uwatec_smart_device_open (dc_device_t **out) { if (out == NULL) return DC_STATUS_INVALIDARGS; @@ -212,14 +212,14 @@ uwatec_smart_device_open (device_t **out) // Perform the handshaking. uwatec_smart_handshake (device); - *out = (device_t*) device; + *out = (dc_device_t*) device; return DC_STATUS_SUCCESS; } static dc_status_t -uwatec_smart_device_close (device_t *abstract) +uwatec_smart_device_close (dc_device_t *abstract) { uwatec_smart_device_t *device = (uwatec_smart_device_t*) abstract; @@ -243,7 +243,7 @@ uwatec_smart_device_close (device_t *abstract) dc_status_t -uwatec_smart_device_set_timestamp (device_t *abstract, unsigned int timestamp) +uwatec_smart_device_set_timestamp (dc_device_t *abstract, unsigned int timestamp) { uwatec_smart_device_t *device = (uwatec_smart_device_t*) abstract; @@ -257,7 +257,7 @@ uwatec_smart_device_set_timestamp (device_t *abstract, unsigned int timestamp) static dc_status_t -uwatec_smart_device_set_fingerprint (device_t *abstract, const unsigned char data[], unsigned int size) +uwatec_smart_device_set_fingerprint (dc_device_t *abstract, const unsigned char data[], unsigned int size) { uwatec_smart_device_t *device = (uwatec_smart_device_t*) abstract; @@ -277,7 +277,7 @@ uwatec_smart_device_set_fingerprint (device_t *abstract, const unsigned char dat static dc_status_t -uwatec_smart_device_version (device_t *abstract, unsigned char data[], unsigned int size) +uwatec_smart_device_version (dc_device_t *abstract, unsigned char data[], unsigned int size) { uwatec_smart_device_t *device = (uwatec_smart_device_t *) abstract; @@ -311,7 +311,7 @@ uwatec_smart_device_version (device_t *abstract, unsigned char data[], unsigned static dc_status_t -uwatec_smart_device_dump (device_t *abstract, dc_buffer_t *buffer) +uwatec_smart_device_dump (dc_device_t *abstract, dc_buffer_t *buffer) { uwatec_smart_device_t *device = (uwatec_smart_device_t*) abstract; @@ -325,8 +325,8 @@ uwatec_smart_device_dump (device_t *abstract, dc_buffer_t *buffer) } // Enable progress notifications. - device_progress_t progress = DEVICE_PROGRESS_INITIALIZER; - device_event_emit (&device->base, DEVICE_EVENT_PROGRESS, &progress); + dc_event_progress_t progress = EVENT_PROGRESS_INITIALIZER; + device_event_emit (&device->base, DC_EVENT_PROGRESS, &progress); // Read the version and clock data. unsigned char version[UWATEC_SMART_VERSION_SIZE] = {0}; @@ -340,20 +340,20 @@ uwatec_smart_device_dump (device_t *abstract, dc_buffer_t *buffer) // Update and emit a progress event. progress.current += 9; - device_event_emit (&device->base, DEVICE_EVENT_PROGRESS, &progress); + device_event_emit (&device->base, DC_EVENT_PROGRESS, &progress); // Emit a clock event. - device_clock_t clock; + dc_event_clock_t clock; clock.systime = device->systime; clock.devtime = device->devtime; - device_event_emit (&device->base, DEVICE_EVENT_CLOCK, &clock); + device_event_emit (&device->base, DC_EVENT_CLOCK, &clock); // Emit a device info event. - device_devinfo_t devinfo; + dc_event_devinfo_t devinfo; devinfo.model = version[0]; devinfo.firmware = 0; devinfo.serial = array_uint32_le (version + 1); - device_event_emit (&device->base, DEVICE_EVENT_DEVINFO, &devinfo); + device_event_emit (&device->base, DC_EVENT_DEVINFO, &devinfo); // Command template. unsigned char answer[4] = {0}; @@ -378,7 +378,7 @@ uwatec_smart_device_dump (device_t *abstract, dc_buffer_t *buffer) // Update and emit a progress event. progress.maximum = 4 + 9 + (length ? length + 4 : 0); progress.current += 4; - device_event_emit (&device->base, DEVICE_EVENT_PROGRESS, &progress); + device_event_emit (&device->base, DC_EVENT_PROGRESS, &progress); if (length == 0) return DC_STATUS_SUCCESS; @@ -401,7 +401,7 @@ uwatec_smart_device_dump (device_t *abstract, dc_buffer_t *buffer) // Update and emit a progress event. progress.current += 4; - device_event_emit (&device->base, DEVICE_EVENT_PROGRESS, &progress); + device_event_emit (&device->base, DC_EVENT_PROGRESS, &progress); if (total != length + 4) { WARNING ("Received an unexpected size."); @@ -430,7 +430,7 @@ uwatec_smart_device_dump (device_t *abstract, dc_buffer_t *buffer) // Update and emit a progress event. progress.current += n; - device_event_emit (&device->base, DEVICE_EVENT_PROGRESS, &progress); + device_event_emit (&device->base, DC_EVENT_PROGRESS, &progress); nbytes += n; } @@ -440,7 +440,7 @@ uwatec_smart_device_dump (device_t *abstract, dc_buffer_t *buffer) static dc_status_t -uwatec_smart_device_foreach (device_t *abstract, dive_callback_t callback, void *userdata) +uwatec_smart_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, void *userdata) { if (! device_is_uwatec_smart (abstract)) return DC_STATUS_INVALIDARGS; @@ -465,7 +465,7 @@ uwatec_smart_device_foreach (device_t *abstract, dive_callback_t callback, void dc_status_t -uwatec_smart_extract_dives (device_t *abstract, const unsigned char data[], unsigned int size, dive_callback_t callback, void *userdata) +uwatec_smart_extract_dives (dc_device_t *abstract, const unsigned char data[], unsigned int size, dc_dive_callback_t callback, void *userdata) { if (abstract && !device_is_uwatec_smart (abstract)) return DC_STATUS_INVALIDARGS; diff --git a/src/uwatec_smart_parser.c b/src/uwatec_smart_parser.c index 8c5a770..93e1b73 100644 --- a/src/uwatec_smart_parser.c +++ b/src/uwatec_smart_parser.c @@ -43,17 +43,17 @@ typedef struct uwatec_smart_parser_t uwatec_smart_parser_t; struct uwatec_smart_parser_t { - parser_t base; + dc_parser_t base; unsigned int model; unsigned int devtime; dc_ticks_t systime; }; -static dc_status_t uwatec_smart_parser_set_data (parser_t *abstract, const unsigned char *data, unsigned int size); -static dc_status_t uwatec_smart_parser_get_datetime (parser_t *abstract, dc_datetime_t *datetime); -static dc_status_t uwatec_smart_parser_get_field (parser_t *abstract, parser_field_type_t type, unsigned int flags, void *value); -static dc_status_t uwatec_smart_parser_samples_foreach (parser_t *abstract, sample_callback_t callback, void *userdata); -static dc_status_t uwatec_smart_parser_destroy (parser_t *abstract); +static dc_status_t uwatec_smart_parser_set_data (dc_parser_t *abstract, const unsigned char *data, unsigned int size); +static dc_status_t uwatec_smart_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *datetime); +static dc_status_t uwatec_smart_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsigned int flags, void *value); +static dc_status_t uwatec_smart_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t callback, void *userdata); +static dc_status_t uwatec_smart_parser_destroy (dc_parser_t *abstract); static const parser_backend_t uwatec_smart_parser_backend = { DC_FAMILY_UWATEC_SMART, @@ -66,7 +66,7 @@ static const parser_backend_t uwatec_smart_parser_backend = { static int -parser_is_uwatec_smart (parser_t *abstract) +parser_is_uwatec_smart (dc_parser_t *abstract) { if (abstract == NULL) return 0; @@ -76,7 +76,7 @@ parser_is_uwatec_smart (parser_t *abstract) dc_status_t -uwatec_smart_parser_create (parser_t **out, unsigned int model, unsigned int devtime, dc_ticks_t systime) +uwatec_smart_parser_create (dc_parser_t **out, unsigned int model, unsigned int devtime, dc_ticks_t systime) { if (out == NULL) return DC_STATUS_INVALIDARGS; @@ -96,14 +96,14 @@ uwatec_smart_parser_create (parser_t **out, unsigned int model, unsigned int dev parser->devtime = devtime; parser->systime = systime; - *out = (parser_t*) parser; + *out = (dc_parser_t*) parser; return DC_STATUS_SUCCESS; } static dc_status_t -uwatec_smart_parser_destroy (parser_t *abstract) +uwatec_smart_parser_destroy (dc_parser_t *abstract) { if (! parser_is_uwatec_smart (abstract)) return DC_STATUS_INVALIDARGS; @@ -116,7 +116,7 @@ uwatec_smart_parser_destroy (parser_t *abstract) static dc_status_t -uwatec_smart_parser_set_data (parser_t *abstract, const unsigned char *data, unsigned int size) +uwatec_smart_parser_set_data (dc_parser_t *abstract, const unsigned char *data, unsigned int size) { if (! parser_is_uwatec_smart (abstract)) return DC_STATUS_INVALIDARGS; @@ -126,7 +126,7 @@ uwatec_smart_parser_set_data (parser_t *abstract, const unsigned char *data, uns static dc_status_t -uwatec_smart_parser_get_datetime (parser_t *abstract, dc_datetime_t *datetime) +uwatec_smart_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *datetime) { uwatec_smart_parser_t *parser = (uwatec_smart_parser_t *) abstract; @@ -200,7 +200,7 @@ uwatec_smart_header_info_t uwatec_galileo_sol_header = { }; static dc_status_t -uwatec_smart_parser_get_field (parser_t *abstract, parser_field_type_t type, unsigned int flags, void *value) +uwatec_smart_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsigned int flags, void *value) { uwatec_smart_parser_t *parser = (uwatec_smart_parser_t *) abstract; @@ -247,20 +247,20 @@ uwatec_smart_parser_get_field (parser_t *abstract, parser_field_type_t type, uns if (size < header) return DC_STATUS_DATAFORMAT; - gasmix_t *gasmix = (gasmix_t *) value; + dc_gasmix_t *gasmix = (dc_gasmix_t *) value; if (value) { switch (type) { - case FIELD_TYPE_DIVETIME: + case DC_FIELD_DIVETIME: *((unsigned int *) value) = array_uint16_le (data + table->divetime) * 60; break; - case FIELD_TYPE_MAXDEPTH: + case DC_FIELD_MAXDEPTH: *((double *) value) = array_uint16_le (data + table->maxdepth) / 100.0; break; - case FIELD_TYPE_GASMIX_COUNT: + case DC_FIELD_GASMIX_COUNT: *((unsigned int *) value) = table->ngases; break; - case FIELD_TYPE_GASMIX: + case DC_FIELD_GASMIX: gasmix->helium = 0.0; gasmix->oxygen = array_uint16_le (data + table->gasmix + flags * 2) / 100.0; gasmix->nitrogen = 1.0 - gasmix->oxygen - gasmix->helium; @@ -433,7 +433,7 @@ uwatec_smart_sample_info_t uwatec_galileo_sol_table [] = { }; static dc_status_t -uwatec_smart_parser_samples_foreach (parser_t *abstract, sample_callback_t callback, void *userdata) +uwatec_smart_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t callback, void *userdata) { uwatec_smart_parser_t *parser = (uwatec_smart_parser_t*) abstract; @@ -512,7 +512,7 @@ uwatec_smart_parser_samples_foreach (parser_t *abstract, sample_callback_t callb unsigned int offset = header; while (offset < size) { - parser_sample_value_t sample = {0}; + dc_sample_value_t sample = {0}; // Process the type bits in the bitstream. unsigned int id = 0; @@ -635,47 +635,47 @@ uwatec_smart_parser_samples_foreach (parser_t *abstract, sample_callback_t callb while (complete) { sample.time = time; - if (callback) callback (SAMPLE_TYPE_TIME, sample, userdata); + if (callback) callback (DC_SAMPLE_TIME, sample, userdata); if (have_temperature) { sample.temperature = temperature; - if (callback) callback (SAMPLE_TYPE_TEMPERATURE, sample, userdata); + if (callback) callback (DC_SAMPLE_TEMPERATURE, sample, userdata); } if (have_alarms) { sample.vendor.type = SAMPLE_VENDOR_UWATEC_SMART; sample.vendor.size = nalarms; sample.vendor.data = alarms; - if (callback) callback (SAMPLE_TYPE_VENDOR, sample, userdata); + if (callback) callback (DC_SAMPLE_VENDOR, sample, userdata); memset (alarms, 0, sizeof (alarms)); have_alarms = 0; } if (have_rbt || have_pressure) { sample.rbt = rbt; - if (callback) callback (SAMPLE_TYPE_RBT, sample, userdata); + if (callback) callback (DC_SAMPLE_RBT, sample, userdata); } if (have_pressure) { sample.pressure.tank = tank; sample.pressure.value = pressure; - if (callback) callback (SAMPLE_TYPE_PRESSURE, sample, userdata); + if (callback) callback (DC_SAMPLE_PRESSURE, sample, userdata); } if (have_heartrate) { sample.heartbeat = heartrate; - if (callback) callback (SAMPLE_TYPE_HEARTBEAT, sample, userdata); + if (callback) callback (DC_SAMPLE_HEARTBEAT, sample, userdata); } if (have_bearing) { sample.bearing = bearing; - if (callback) callback (SAMPLE_TYPE_BEARING, sample, userdata); + if (callback) callback (DC_SAMPLE_BEARING, sample, userdata); have_bearing = 0; } if (have_depth) { sample.depth = depth - depth_calibration; - if (callback) callback (SAMPLE_TYPE_DEPTH, sample, userdata); + if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); } time += 4; diff --git a/src/zeagle_n2ition3.c b/src/zeagle_n2ition3.c index d3d3bf7..a889f92 100644 --- a/src/zeagle_n2ition3.c +++ b/src/zeagle_n2ition3.c @@ -45,16 +45,16 @@ #define RB_LOGBOOK_END 60 typedef struct zeagle_n2ition3_device_t { - device_t base; + dc_device_t base; serial_t *port; unsigned char fingerprint[16]; } zeagle_n2ition3_device_t; -static dc_status_t zeagle_n2ition3_device_set_fingerprint (device_t *abstract, const unsigned char data[], unsigned int size); -static dc_status_t zeagle_n2ition3_device_read (device_t *abstract, unsigned int address, unsigned char data[], unsigned int size); -static dc_status_t zeagle_n2ition3_device_dump (device_t *abstract, dc_buffer_t *buffer); -static dc_status_t zeagle_n2ition3_device_foreach (device_t *abstract, dive_callback_t callback, void *userdata); -static dc_status_t zeagle_n2ition3_device_close (device_t *abstract); +static dc_status_t zeagle_n2ition3_device_set_fingerprint (dc_device_t *abstract, const unsigned char data[], unsigned int size); +static dc_status_t zeagle_n2ition3_device_read (dc_device_t *abstract, unsigned int address, unsigned char data[], unsigned int size); +static dc_status_t zeagle_n2ition3_device_dump (dc_device_t *abstract, dc_buffer_t *buffer); +static dc_status_t zeagle_n2ition3_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, void *userdata); +static dc_status_t zeagle_n2ition3_device_close (dc_device_t *abstract); static const device_backend_t zeagle_n2ition3_device_backend = { DC_FAMILY_ZEAGLE_N2ITION3, @@ -68,7 +68,7 @@ static const device_backend_t zeagle_n2ition3_device_backend = { }; static int -device_is_zeagle_n2ition3 (device_t *abstract) +device_is_zeagle_n2ition3 (dc_device_t *abstract) { if (abstract == NULL) return 0; @@ -135,7 +135,7 @@ zeagle_n2ition3_init (zeagle_n2ition3_device_t *device) } dc_status_t -zeagle_n2ition3_device_open (device_t **out, const char* name) +zeagle_n2ition3_device_open (dc_device_t **out, const char *name) { if (out == NULL) return DC_STATUS_INVALIDARGS; @@ -184,14 +184,14 @@ zeagle_n2ition3_device_open (device_t **out, const char* name) // Send the init commands. zeagle_n2ition3_init (device); - *out = (device_t *) device; + *out = (dc_device_t *) device; return DC_STATUS_SUCCESS; } static dc_status_t -zeagle_n2ition3_device_close (device_t *abstract) +zeagle_n2ition3_device_close (dc_device_t *abstract) { zeagle_n2ition3_device_t *device = (zeagle_n2ition3_device_t*) abstract; @@ -212,7 +212,7 @@ zeagle_n2ition3_device_close (device_t *abstract) static dc_status_t -zeagle_n2ition3_device_set_fingerprint (device_t *abstract, const unsigned char data[], unsigned int size) +zeagle_n2ition3_device_set_fingerprint (dc_device_t *abstract, const unsigned char data[], unsigned int size) { zeagle_n2ition3_device_t *device = (zeagle_n2ition3_device_t *) abstract; @@ -229,7 +229,7 @@ zeagle_n2ition3_device_set_fingerprint (device_t *abstract, const unsigned char static dc_status_t -zeagle_n2ition3_device_read (device_t *abstract, unsigned int address, unsigned char data[], unsigned int size) +zeagle_n2ition3_device_read (dc_device_t *abstract, unsigned int address, unsigned char data[], unsigned int size) { zeagle_n2ition3_device_t *device = (zeagle_n2ition3_device_t*) abstract; @@ -270,7 +270,7 @@ zeagle_n2ition3_device_read (device_t *abstract, unsigned int address, unsigned static dc_status_t -zeagle_n2ition3_device_dump (device_t *abstract, dc_buffer_t *buffer) +zeagle_n2ition3_device_dump (dc_device_t *abstract, dc_buffer_t *buffer) { if (! device_is_zeagle_n2ition3 (abstract)) return DC_STATUS_INVALIDARGS; @@ -288,15 +288,15 @@ zeagle_n2ition3_device_dump (device_t *abstract, dc_buffer_t *buffer) static dc_status_t -zeagle_n2ition3_device_foreach (device_t *abstract, dive_callback_t callback, void *userdata) +zeagle_n2ition3_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, void *userdata) { zeagle_n2ition3_device_t *device = (zeagle_n2ition3_device_t *) abstract; // Enable progress notifications. - device_progress_t progress = DEVICE_PROGRESS_INITIALIZER; + dc_event_progress_t progress = EVENT_PROGRESS_INITIALIZER; progress.maximum = (RB_LOGBOOK_END - RB_LOGBOOK_BEGIN) * 2 + 8 + (RB_PROFILE_END - RB_PROFILE_BEGIN); - device_event_emit (abstract, DEVICE_EVENT_PROGRESS, &progress); + device_event_emit (abstract, DC_EVENT_PROGRESS, &progress); // Read the configuration data. unsigned char config[(RB_LOGBOOK_END - RB_LOGBOOK_BEGIN) * 2 + 8] = {0}; @@ -363,7 +363,7 @@ zeagle_n2ition3_device_foreach (device_t *abstract, dive_callback_t callback, vo // Update and emit a progress event. progress.current += sizeof (config); progress.maximum = (RB_LOGBOOK_END - RB_LOGBOOK_BEGIN) * 2 + 8 + total; - device_event_emit (abstract, DEVICE_EVENT_PROGRESS, &progress); + device_event_emit (abstract, DC_EVENT_PROGRESS, &progress); // Memory buffer for the profile data. unsigned char buffer[RB_PROFILE_END - RB_PROFILE_BEGIN] = {0}; @@ -405,7 +405,7 @@ zeagle_n2ition3_device_foreach (device_t *abstract, dive_callback_t callback, vo // Update and emit a progress event. progress.current += len; - device_event_emit (abstract, DEVICE_EVENT_PROGRESS, &progress); + device_event_emit (abstract, DC_EVENT_PROGRESS, &progress); nbytes += len; }