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.
This commit is contained in:
Jef Driesen 2013-01-05 10:12:04 +01:00
parent af1ca93fe8
commit 380eaadf83
4 changed files with 7 additions and 36 deletions

View File

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

View File

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

View File

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

View File

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