Remove the old custom serial code
Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
f9db4ca97c
commit
7e086f697d
@ -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);
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
28
src/device.c
28
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)
|
||||
{
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user