From 7e086f697d740c00ca747dc2195e2a61fcb67c9f Mon Sep 17 00:00:00 2001 From: Anton Lundin Date: Sat, 17 Sep 2016 15:19:47 +0200 Subject: [PATCH] Remove the old custom serial code Signed-off-by: Anton Lundin Signed-off-by: Linus Torvalds --- include/libdivecomputer/device.h | 3 - include/libdivecomputer/hw_ostc3.h | 3 - include/libdivecomputer/shearwater_petrel.h | 3 - include/libdivecomputer/shearwater_predator.h | 3 - src/device.c | 28 --------- src/hw_ostc3.c | 59 ------------------- src/libdivecomputer.symbols | 3 - src/shearwater_common.c | 37 ------------ src/shearwater_common.h | 3 - src/shearwater_petrel.c | 35 ----------- src/shearwater_predator.c | 35 ----------- 11 files changed, 212 deletions(-) diff --git a/include/libdivecomputer/device.h b/include/libdivecomputer/device.h index c0868a3..008d3c2 100644 --- a/include/libdivecomputer/device.h +++ b/include/libdivecomputer/device.h @@ -74,9 +74,6 @@ typedef int (*dc_dive_callback_t) (const unsigned char *data, unsigned int size, dc_status_t dc_device_open (dc_device_t **out, dc_context_t *context, dc_descriptor_t *descriptor, const char *name); -dc_status_t -dc_device_custom_open (dc_device_t **out, dc_context_t *context, dc_descriptor_t *descriptor, dc_serial_t *serial); - dc_family_t dc_device_get_type (dc_device_t *device); diff --git a/include/libdivecomputer/hw_ostc3.h b/include/libdivecomputer/hw_ostc3.h index e463d04..4c4a8e4 100644 --- a/include/libdivecomputer/hw_ostc3.h +++ b/include/libdivecomputer/hw_ostc3.h @@ -38,9 +38,6 @@ extern "C" { dc_status_t hw_ostc3_device_open (dc_device_t **device, dc_context_t *context, const char *name); -dc_status_t -hw_ostc3_device_custom_open (dc_device_t **device, dc_context_t *context, dc_serial_t *serial); - dc_status_t hw_ostc3_device_version (dc_device_t *device, unsigned char data[], unsigned int size); diff --git a/include/libdivecomputer/shearwater_petrel.h b/include/libdivecomputer/shearwater_petrel.h index 97a8dc2..f1fe8b0 100644 --- a/include/libdivecomputer/shearwater_petrel.h +++ b/include/libdivecomputer/shearwater_petrel.h @@ -34,9 +34,6 @@ extern "C" { dc_status_t shearwater_petrel_device_open (dc_device_t **device, dc_context_t *context, const char *name); -dc_status_t -shearwater_petrel_device_custom_open (dc_device_t **out, dc_context_t *context, dc_serial_t *serial); - dc_status_t shearwater_petrel_parser_create (dc_parser_t **parser, dc_context_t *context, unsigned int serial); diff --git a/include/libdivecomputer/shearwater_predator.h b/include/libdivecomputer/shearwater_predator.h index 9a37bcf..8939c6c 100644 --- a/include/libdivecomputer/shearwater_predator.h +++ b/include/libdivecomputer/shearwater_predator.h @@ -34,9 +34,6 @@ extern "C" { dc_status_t shearwater_predator_device_open (dc_device_t **device, dc_context_t *context, const char *name); -dc_status_t -shearwater_predator_device_custom_open (dc_device_t **device, dc_context_t *context, dc_serial_t *serial); - dc_status_t shearwater_predator_extract_dives (dc_device_t *device, const unsigned char data[], unsigned int size, dc_dive_callback_t callback, void *userdata); diff --git a/src/device.c b/src/device.c index 526ded1..56a2422 100644 --- a/src/device.c +++ b/src/device.c @@ -198,34 +198,6 @@ dc_device_open (dc_device_t **out, dc_context_t *context, dc_descriptor_t *descr return rc; } -dc_status_t -dc_device_custom_open (dc_device_t **out, dc_context_t *context, dc_descriptor_t *descriptor, dc_serial_t *serial) -{ - dc_status_t rc = DC_STATUS_SUCCESS; - dc_device_t *device = NULL; - - if (out == NULL || descriptor == NULL || serial == NULL) - return DC_STATUS_INVALIDARGS; - - switch (dc_descriptor_get_type (descriptor)) { - case DC_FAMILY_HW_OSTC3: - rc = hw_ostc3_device_custom_open (&device, context, serial); - break; - case DC_FAMILY_SHEARWATER_PREDATOR: - rc = shearwater_predator_device_custom_open (&device, context, serial); - break; - case DC_FAMILY_SHEARWATER_PETREL: - rc = shearwater_petrel_device_custom_open (&device, context, serial); - break; - default: - return DC_STATUS_INVALIDARGS; - } - - *out = device; - - return rc; -} - int dc_device_isinstance (dc_device_t *device, const dc_device_vtable_t *vtable) { diff --git a/src/hw_ostc3.c b/src/hw_ostc3.c index acf6012..f4f2c10 100644 --- a/src/hw_ostc3.c +++ b/src/hw_ostc3.c @@ -379,65 +379,6 @@ error_free: } -dc_status_t -hw_ostc3_device_custom_open (dc_device_t **out, dc_context_t *context, dc_serial_t *port) -{ - dc_status_t status = DC_STATUS_SUCCESS; - hw_ostc3_device_t *device = NULL; - - if (out == NULL || port == NULL) - return DC_STATUS_INVALIDARGS; - - // Allocate memory. - device = (hw_ostc3_device_t *) dc_device_allocate (context, &hw_ostc3_device_vtable); - if (device == NULL) { - ERROR (context, "Failed to allocate memory."); - return DC_STATUS_NOMEMORY; - } - - // Set the default values. - device->hardware = INVALID; - memset (device->fingerprint, 0, sizeof (device->fingerprint)); - - // Set the serial reference - device->port = port; - - if (1) { -// if (port->type == DC_TRANSPORT_SERIAL) { - // Set the serial communication protocol (115200 8N1). - status = dc_serial_configure (device->port, 115200, 8, DC_PARITY_NONE, 1, DC_FLOWCONTROL_NONE); - if (status == DC_STATUS_SUCCESS) { - ERROR (context, "Failed to set the terminal attributes."); - status = DC_STATUS_IO; - goto error_close; - } - } - - // Set the timeout for receiving data (3000ms). - status = dc_serial_set_timeout (device->port, 3000); - if (status != DC_STATUS_SUCCESS) { - ERROR (context, "Failed to set the timeout."); - goto error_close; - } - - // Make sure everything is in a sane state. - dc_serial_sleep (device->port, 300); - dc_serial_purge (device->port, DC_DIRECTION_ALL); - - device->state = OPEN; - - *out = (dc_device_t *) device; - - return DC_STATUS_SUCCESS; - -error_close: - dc_serial_close (device->port); -error_free: - dc_device_deallocate ((dc_device_t *) device); - return status; -} - - static dc_status_t hw_ostc3_device_id (hw_ostc3_device_t *device, unsigned char data[], unsigned int size) { diff --git a/src/libdivecomputer.symbols b/src/libdivecomputer.symbols index 5fe3442..347db27 100644 --- a/src/libdivecomputer.symbols +++ b/src/libdivecomputer.symbols @@ -87,9 +87,6 @@ dc_device_set_events dc_device_set_fingerprint dc_device_write -dc_serial_init -dc_device_custom_open - cressi_edy_device_open cressi_leonardo_device_open mares_nemo_device_open diff --git a/src/shearwater_common.c b/src/shearwater_common.c index e4313e4..7493161 100644 --- a/src/shearwater_common.c +++ b/src/shearwater_common.c @@ -75,43 +75,6 @@ error_close: } -dc_status_t -shearwater_common_custom_open (shearwater_common_device_t *device, dc_context_t *context, dc_serial_t *port) -{ - dc_status_t status = DC_STATUS_SUCCESS; - - // Set the serial reference - device->port = port; - -// if (port->type == DC_TRANSPORT_SERIAL) { - if (1) { - // Set the serial communication protocol (115200 8N1). - status = dc_serial_configure (device->port, 115200, 8, DC_PARITY_NONE, 1, DC_FLOWCONTROL_NONE); - if (status != DC_STATUS_SUCCESS) { - ERROR (context, "Failed to set the terminal attributes."); - goto error_close; - } - } - - // Set the timeout for receiving data (3000ms). - status = dc_serial_set_timeout (device->port, 3000); - if (status != DC_STATUS_SUCCESS) { - ERROR (context, "Failed to set the timeout."); - goto error_close; - } - - // Make sure everything is in a sane state. - dc_serial_sleep (device->port, 300); - dc_serial_purge (device->port, DC_DIRECTION_ALL); - - return DC_STATUS_SUCCESS; - -error_close: - dc_serial_close (device->port); - return status; -} - - dc_status_t shearwater_common_close (shearwater_common_device_t *device) { diff --git a/src/shearwater_common.h b/src/shearwater_common.h index b060f7c..0b49c59 100644 --- a/src/shearwater_common.h +++ b/src/shearwater_common.h @@ -41,9 +41,6 @@ typedef struct shearwater_common_device_t { dc_status_t shearwater_common_open (shearwater_common_device_t *device, dc_context_t *context, const char *name); -dc_status_t -shearwater_common_custom_open (shearwater_common_device_t *device, dc_context_t *context, dc_serial_t *serial); - dc_status_t shearwater_common_close (shearwater_common_device_t *device); diff --git a/src/shearwater_petrel.c b/src/shearwater_petrel.c index bb0c884..06fba30 100644 --- a/src/shearwater_petrel.c +++ b/src/shearwater_petrel.c @@ -113,41 +113,6 @@ error_free: } -dc_status_t -shearwater_petrel_device_custom_open (dc_device_t **out, dc_context_t *context, dc_serial_t *port) -{ - dc_status_t status = DC_STATUS_SUCCESS; - shearwater_petrel_device_t *device = NULL; - - if (out == NULL || port == NULL) - return DC_STATUS_INVALIDARGS; - - // Allocate memory. - device = (shearwater_petrel_device_t *) dc_device_allocate (context, &shearwater_petrel_device_vtable); - if (device == NULL) { - ERROR (context, "Failed to allocate memory."); - return DC_STATUS_NOMEMORY; - } - - // Set the default values. - memset (device->fingerprint, 0, sizeof (device->fingerprint)); - - // Open the device. - status = shearwater_common_custom_open (&device->base, context, port); - if (status != DC_STATUS_SUCCESS) { - goto error_free; - } - - *out = (dc_device_t *) device; - - return DC_STATUS_SUCCESS; - -error_free: - dc_device_deallocate ((dc_device_t *) device); - return status; -} - - static dc_status_t shearwater_petrel_device_close (dc_device_t *abstract) { diff --git a/src/shearwater_predator.c b/src/shearwater_predator.c index 068b318..f018885 100644 --- a/src/shearwater_predator.c +++ b/src/shearwater_predator.c @@ -99,41 +99,6 @@ error_free: } -dc_status_t -shearwater_predator_device_custom_open (dc_device_t **out, dc_context_t *context, dc_serial_t *port) -{ - dc_status_t status = DC_STATUS_SUCCESS; - shearwater_predator_device_t *device = NULL; - - if (out == NULL || port == NULL) - return DC_STATUS_INVALIDARGS; - - // Allocate memory. - device = (shearwater_predator_device_t *) dc_device_allocate (context, &shearwater_predator_device_vtable); - if (device == NULL) { - ERROR (context, "Failed to allocate memory."); - return DC_STATUS_NOMEMORY; - } - - // Set the default values. - memset (device->fingerprint, 0, sizeof (device->fingerprint)); - - // Open the device. - status = shearwater_common_custom_open (&device->base, context, port); - if (status != DC_STATUS_SUCCESS) { - goto error_free; - } - - *out = (dc_device_t *) device; - - return DC_STATUS_SUCCESS; - -error_free: - dc_device_deallocate ((dc_device_t *) device); - return status; -} - - static dc_status_t shearwater_predator_device_close (dc_device_t *abstract) {