>From 6944fd9509c38315267f861b28627e9de59e7545 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Wed, 24 Sep 2014 21:39:28 -0700 Subject: [PATCH 2/3] The Aeris A300CS does not talk to USB unless DTR/RTS is toggled twice This is a problem - we don't know for sure that it is an A300CS until after the device was opened and the model data was read. To make this work I added a new oceanic_atom2_device_open_with_model() function that is now called from device.c (just in case someone used the existing oceanic_atom2_device_open() call I kept that around and have it just call into the new one with a model of -1). This allows us to do the right thing for the A300CS. I had to move the #defines for the various Oceanic Atom2 based dive computers into oceanic_common.h so I would have access to the A300CS define from the new open function. Signed-off-by: Dirk Hohndel --- src/device-private.h | 3 +++ src/device.c | 2 +- src/oceanic_atom2.c | 18 ++++++++++++++++-- src/oceanic_common.h | 40 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 60 insertions(+), 3 deletions(-) diff --git a/src/device-private.h b/src/device-private.h index 8e183fb6b03e..53fa3bca99db 100644 --- a/src/device-private.h +++ b/src/device-private.h @@ -85,6 +85,9 @@ device_is_cancelled (dc_device_t *device); dc_status_t device_dump_read (dc_device_t *device, unsigned char data[], unsigned int size, unsigned int blocksize); +dc_status_t +oceanic_atom2_device_open_with_model (dc_device_t **out, dc_context_t *context, const char *name, int model); + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/src/device.c b/src/device.c index 9fad7a238bc4..200d883d3e0e 100644 --- a/src/device.c +++ b/src/device.c @@ -110,7 +110,7 @@ dc_device_open (dc_device_t **out, dc_context_t *context, dc_descriptor_t *descr rc = oceanic_veo250_device_open (&device, context, name); break; case DC_FAMILY_OCEANIC_ATOM2: - rc = oceanic_atom2_device_open (&device, context, name); + rc = oceanic_atom2_device_open_with_model (&device, context, name, dc_descriptor_get_model (descriptor)); break; case DC_FAMILY_MARES_NEMO: rc = mares_nemo_device_open (&device, context, name); diff --git a/src/oceanic_atom2.c b/src/oceanic_atom2.c index cf164ac0b1eb..7ff267c15a65 100644 --- a/src/oceanic_atom2.c +++ b/src/oceanic_atom2.c @@ -456,9 +456,8 @@ oceanic_atom2_quit (oceanic_atom2_device_t *device) return DC_STATUS_SUCCESS; } - dc_status_t -oceanic_atom2_device_open (dc_device_t **out, dc_context_t *context, const char *name) +oceanic_atom2_device_open_with_model (dc_device_t **out, dc_context_t *context, const char *name, int model) { if (out == NULL) return DC_STATUS_INVALIDARGS; @@ -487,6 +486,16 @@ oceanic_atom2_device_open (dc_device_t **out, dc_context_t *context, const char // Set the serial communication protocol (38400 8N1). rc = serial_configure (device->port, 38400, 8, SERIAL_PARITY_NONE, 1, SERIAL_FLOWCONTROL_NONE); + + if (model == A300CS) { + // the Aeris A300CS needs these four commands to respond to the serial interface + // and I need to issue those before I can read the model an KNOW that it's an A300CS + serial_set_dtr(device->port, 1); + serial_set_rts(device->port, 1); + serial_set_dtr(device->port, 1); + serial_set_rts(device->port, 1); + } + if (rc == -1) { ERROR (context, "Failed to set the terminal attributes."); serial_close (device->port); @@ -560,6 +569,11 @@ oceanic_atom2_device_open (dc_device_t **out, dc_context_t *context, const char return DC_STATUS_SUCCESS; } +dc_status_t +oceanic_atom2_device_open (dc_device_t **out, dc_context_t *context, const char *name) +{ + return oceanic_atom2_device_open_with_model(out, context, name, -1); +} static dc_status_t oceanic_atom2_device_close (dc_device_t *abstract) diff --git a/src/oceanic_common.h b/src/oceanic_common.h index a276f1f56b5f..73f6559783db 100644 --- a/src/oceanic_common.h +++ b/src/oceanic_common.h @@ -32,6 +32,46 @@ extern "C" { #define FPMAXSIZE 0x20 #define BIGPAGESIZE (PAGESIZE * 16) +#define ATOM1 0x4250 +#define EPICA 0x4257 +#define VT3 0x4258 +#define T3A 0x4259 +#define ATOM2 0x4342 +#define GEO 0x4344 +#define MANTA 0x4345 +#define DATAMASK 0x4347 +#define COMPUMASK 0x4348 +#define OC1A 0x434E +#define F10 0x434D +#define WISDOM2 0x4350 +#define INSIGHT2 0x4353 +#define ELEMENT2 0x4357 +#define VEO20 0x4359 +#define VEO30 0x435A +#define ZEN 0x4441 +#define ZENAIR 0x4442 +#define ATMOSAI2 0x4443 +#define PROPLUS21 0x4444 +#define GEO20 0x4446 +#define VT4 0x4447 +#define OC1B 0x4449 +#define VOYAGER2G 0x444B +#define ATOM3 0x444C +#define DG03 0x444D +#define OCS 0x4450 +#define OC1C 0x4451 +#define VT41 0x4452 +#define EPICB 0x4453 +#define T3B 0x4455 +#define ATOM31 0x4456 +#define A300AI 0x4457 +#define A300 0x445A +#define TX1 0x4542 +#define AMPHOS 0x4545 +#define PROPLUS3 0x4548 +#define OCI 0x454B +#define A300CS 0x454C + #define OCEANIC_COMMON_MATCH(version,patterns) \ oceanic_common_match ((version), (patterns), \ sizeof (patterns) / sizeof *(patterns)) -- 1.8.0.rc0.18.gf84667d