From 380eaadf833532949de4784155855ac095de604e Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Sat, 5 Jan 2013 10:12:04 +0100 Subject: [PATCH] Hardcode the delay between packets. The application shouldn't have to deal with the delay between packets. If the default value isn't good enough, that should be fixed internally and not on the application side. --- examples/suunto_vyper_test.c | 21 ++++++--------------- include/libdivecomputer/suunto_vyper.h | 3 --- src/libdivecomputer.symbols | 1 - src/suunto_vyper.c | 18 +----------------- 4 files changed, 7 insertions(+), 36 deletions(-) diff --git a/examples/suunto_vyper_test.c b/examples/suunto_vyper_test.c index 3e074c1..85b2295 100644 --- a/examples/suunto_vyper_test.c +++ b/examples/suunto_vyper_test.c @@ -28,7 +28,7 @@ #include "common.h" dc_status_t -test_dump_sdm (const char* name, unsigned int delay) +test_dump_sdm (const char* name) { dc_context_t *context = NULL; dc_device_t *device = NULL; @@ -45,8 +45,6 @@ test_dump_sdm (const char* name, unsigned int delay) return rc; } - suunto_vyper_device_set_delay (device, delay); - message ("dc_device_foreach\n"); rc = dc_device_foreach (device, NULL, NULL); if (rc != DC_STATUS_SUCCESS) { @@ -71,7 +69,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) +test_dump_memory (const char* name, const char* filename) { dc_context_t *context = NULL; dc_device_t *device = NULL; @@ -88,8 +86,6 @@ test_dump_memory (const char* name, unsigned int delay, const char* filename) return rc; } - suunto_vyper_device_set_delay (device, delay); - dc_buffer_t *buffer = dc_buffer_new (0); message ("dc_device_dump\n"); @@ -134,20 +130,15 @@ int main(int argc, char *argv[]) #else const char* name = "/dev/ttyS0"; #endif - - unsigned int delay = 500; - if (argc > 2) { - name = argv[1]; - delay = atoi (argv[2]); - } else if (argc > 1) { + if (argc > 1) { name = argv[1]; } - message ("DEVICE=%s, DELAY=%i\n", name, delay); + message ("DEVICE=%s\n", name); - dc_status_t a = test_dump_sdm (name, delay); - dc_status_t b = test_dump_memory (name, delay, "VYPER.DMP"); + dc_status_t a = test_dump_sdm (name); + dc_status_t b = test_dump_memory (name, "VYPER.DMP"); message ("\nSUMMARY\n"); message ("-------\n"); diff --git a/include/libdivecomputer/suunto_vyper.h b/include/libdivecomputer/suunto_vyper.h index 727a125..651d5ec 100644 --- a/include/libdivecomputer/suunto_vyper.h +++ b/include/libdivecomputer/suunto_vyper.h @@ -33,9 +33,6 @@ extern "C" { dc_status_t suunto_vyper_device_open (dc_device_t **device, dc_context_t *context, const char *name); -dc_status_t -suunto_vyper_device_set_delay (dc_device_t *device, unsigned int delay); - dc_status_t suunto_vyper_device_read_dive (dc_device_t *device, dc_buffer_t *buffer, int init); diff --git a/src/libdivecomputer.symbols b/src/libdivecomputer.symbols index 6f4c6b8..c470901 100644 --- a/src/libdivecomputer.symbols +++ b/src/libdivecomputer.symbols @@ -121,7 +121,6 @@ suunto_vyper2_device_version suunto_vyper2_device_reset_maxdepth suunto_vyper_device_open suunto_vyper_device_read_dive -suunto_vyper_device_set_delay suunto_vyper_extract_dives uwatec_aladin_device_open uwatec_aladin_extract_dives diff --git a/src/suunto_vyper.c b/src/suunto_vyper.c index bfd17b1..f644883 100644 --- a/src/suunto_vyper.c +++ b/src/suunto_vyper.c @@ -51,7 +51,6 @@ typedef struct suunto_vyper_device_t { suunto_common_device_t base; serial_t *port; - unsigned int delay; } suunto_vyper_device_t; static dc_status_t suunto_vyper_device_read (dc_device_t *abstract, unsigned int address, unsigned char data[], unsigned int size); @@ -115,7 +114,6 @@ suunto_vyper_device_open (dc_device_t **out, dc_context_t *context, const char * // Set the default values. device->port = NULL; - device->delay = 500; // Open the device. int rc = serial_open (&device->port, context, name); @@ -183,26 +181,12 @@ suunto_vyper_device_close (dc_device_t *abstract) } -dc_status_t -suunto_vyper_device_set_delay (dc_device_t *abstract, unsigned int delay) -{ - suunto_vyper_device_t *device = (suunto_vyper_device_t*) abstract; - - if (! device_is_suunto_vyper (abstract)) - return DC_STATUS_INVALIDARGS; - - device->delay = delay; - - return DC_STATUS_SUCCESS; -} - - static dc_status_t suunto_vyper_send (suunto_vyper_device_t *device, const unsigned char command[], unsigned int csize) { dc_device_t *abstract = (dc_device_t *) device; - serial_sleep (device->port, device->delay); + serial_sleep (device->port, 500); // Set RTS to send the command. serial_set_rts (device->port, 1);