Introduce a namespace prefix for the high-level public api.

Adding the "dc_" namespace prefix (which is of course an abbreviation
for libdivecomputer) should avoid conflicts with other libraries. For
the time being, only the high-level device and parser layers are
changed.
This commit is contained in:
Jef Driesen 2012-01-21 22:28:04 +01:00
parent 163d383332
commit c821d40144
102 changed files with 1433 additions and 1423 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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, "</sample>\n");
fprintf (sampledata->fp, "<sample>\n");
fprintf (sampledata->fp, " <time>%02u:%02u</time>\n", value.time / 60, value.time % 60);
break;
case SAMPLE_TYPE_DEPTH:
case DC_SAMPLE_DEPTH:
fprintf (sampledata->fp, " <depth>%.2f</depth>\n", value.depth);
break;
case SAMPLE_TYPE_PRESSURE:
case DC_SAMPLE_PRESSURE:
fprintf (sampledata->fp, " <pressure tank=\"%u\">%.2f</pressure>\n", value.pressure.tank, value.pressure.value);
break;
case SAMPLE_TYPE_TEMPERATURE:
case DC_SAMPLE_TEMPERATURE:
fprintf (sampledata->fp, " <temperature>%.2f</temperature>\n", value.temperature);
break;
case SAMPLE_TYPE_EVENT:
case DC_SAMPLE_EVENT:
fprintf (sampledata->fp, " <event type=\"%u\" time=\"%u\" flags=\"%u\" value=\"%u\">%s</event>\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, " <rbt>%u</rbt>\n", value.rbt);
break;
case SAMPLE_TYPE_HEARTBEAT:
case DC_SAMPLE_HEARTBEAT:
fprintf (sampledata->fp, " <heartbeat>%u</heartbeat>\n", value.heartbeat);
break;
case SAMPLE_TYPE_BEARING:
case DC_SAMPLE_BEARING:
fprintf (sampledata->fp, " <bearing>%u</bearing>\n", value.bearing);
break;
case SAMPLE_TYPE_VENDOR:
case DC_SAMPLE_VENDOR:
fprintf (sampledata->fp, " <vendor type=\"%u\" size=\"%u\">", 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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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
}

View File

@ -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
}

View File

@ -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 */

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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 */

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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);

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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
}

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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);

View File

@ -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
}

View File

@ -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;

View File

@ -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);
}
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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;

View File

@ -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);
}
}
}

View File

@ -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;

View File

@ -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;

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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
}

View File

@ -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;

View File

@ -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;

View File

@ -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.

View File

@ -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;

View File

@ -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;
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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);

View File

@ -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
}

View File

@ -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;

View File

@ -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
}

View File

@ -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;

View File

@ -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:

View File

@ -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;

View File

@ -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;
}

View File

@ -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;

View File

@ -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);
}
}

View File

@ -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;

View File

@ -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;

View File

@ -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;
}

View File

@ -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;

View File

@ -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.

View File

@ -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;

View File

@ -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;

Some files were not shown because too many files have changed in this diff Show More