From 24f0f66efd1279e3ca5b6efe4a046cd3fd4a56d6 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Wed, 27 May 2009 10:23:27 +0000 Subject: [PATCH] Automatically switch the device into download mode. --- examples/oceanic_atom2_test.c | 9 --------- examples/oceanic_veo250_test.c | 9 --------- examples/oceanic_vtpro_test.c | 9 --------- src/oceanic_atom2.c | 7 +++++++ src/oceanic_veo250.c | 9 ++++++++- src/oceanic_vtpro.c | 9 ++++++++- 6 files changed, 23 insertions(+), 29 deletions(-) diff --git a/examples/oceanic_atom2_test.c b/examples/oceanic_atom2_test.c index 9b368b2..64a8cc4 100644 --- a/examples/oceanic_atom2_test.c +++ b/examples/oceanic_atom2_test.c @@ -42,15 +42,6 @@ test_dump_memory (const char* name, const char* filename) return rc; } - message ("device_version\n"); - unsigned char version[OCEANIC_ATOM2_PACKET_SIZE] = {0}; - rc = device_version (device, version, sizeof (version)); - if (rc != DEVICE_STATUS_SUCCESS) { - WARNING ("Cannot identify computer."); - device_close (device); - return rc; - } - message ("device_read\n"); rc = device_read (device, 0x00, data, sizeof (data)); if (rc != DEVICE_STATUS_SUCCESS) { diff --git a/examples/oceanic_veo250_test.c b/examples/oceanic_veo250_test.c index 9bc7d68..5dd2134 100644 --- a/examples/oceanic_veo250_test.c +++ b/examples/oceanic_veo250_test.c @@ -42,15 +42,6 @@ test_dump_memory (const char* name, const char* filename) return rc; } - message ("device_version\n"); - unsigned char version[OCEANIC_VEO250_PACKET_SIZE] = {0}; - rc = device_version (device, version, sizeof (version)); - if (rc != DEVICE_STATUS_SUCCESS) { - WARNING ("Cannot identify computer."); - device_close (device); - return rc; - } - message ("device_read\n"); rc = device_read (device, 0x00, data, sizeof (data)); if (rc != DEVICE_STATUS_SUCCESS) { diff --git a/examples/oceanic_vtpro_test.c b/examples/oceanic_vtpro_test.c index c1e8005..68789d0 100644 --- a/examples/oceanic_vtpro_test.c +++ b/examples/oceanic_vtpro_test.c @@ -42,15 +42,6 @@ test_dump_memory (const char* name, const char* filename) return rc; } - message ("device_version\n"); - unsigned char version[OCEANIC_VTPRO_PACKET_SIZE] = {0}; - rc = device_version (device, version, sizeof (version)); - if (rc != DEVICE_STATUS_SUCCESS) { - WARNING ("Cannot identify computer."); - device_close (device); - return rc; - } - message ("oceanic_vtpro_device_calibrate\n"); unsigned char calibration = 0; rc = oceanic_vtpro_device_calibrate (device, &calibration, 1); diff --git a/src/oceanic_atom2.c b/src/oceanic_atom2.c index 584b253..13df24b 100644 --- a/src/oceanic_atom2.c +++ b/src/oceanic_atom2.c @@ -49,6 +49,7 @@ typedef struct oceanic_atom2_device_t { oceanic_common_device_t base; struct serial *port; + unsigned char version[OCEANIC_ATOM2_PACKET_SIZE]; } oceanic_atom2_device_t; static device_status_t oceanic_atom2_device_set_fingerprint (device_t *abstract, const unsigned char data[], unsigned int size); @@ -244,6 +245,7 @@ oceanic_atom2_device_open (device_t **out, const char* name) // Set the default values. device->port = NULL; + memset (device->version, 0, sizeof (device->version)); // Open the device. int rc = serial_open (&device->port, name); @@ -279,6 +281,11 @@ oceanic_atom2_device_open (device_t **out, const char* name) // Send the init command. oceanic_atom2_init (device); + // Switch the device from surface mode into download mode. Before sending + // this command, the device needs to be in PC mode (automatically activated + // by connecting the device), or already in download mode. + oceanic_atom2_device_version ((device_t *) device, device->version, sizeof (device->version)); + *out = (device_t*) device; return DEVICE_STATUS_SUCCESS; diff --git a/src/oceanic_veo250.c b/src/oceanic_veo250.c index 4a5fdae..7cc420c 100644 --- a/src/oceanic_veo250.c +++ b/src/oceanic_veo250.c @@ -50,6 +50,7 @@ typedef struct oceanic_veo250_device_t { oceanic_common_device_t base; struct serial *port; unsigned int last; + unsigned char version[OCEANIC_VEO250_PACKET_SIZE]; } oceanic_veo250_device_t; static device_status_t oceanic_veo250_device_set_fingerprint (device_t *abstract, const unsigned char data[], unsigned int size); @@ -243,6 +244,7 @@ oceanic_veo250_device_open (device_t **out, const char* name) // Set the default values. device->port = NULL; device->last = 0; + memset (device->version, 0, sizeof (device->version)); // Open the device. int rc = serial_open (&device->port, name); @@ -287,6 +289,11 @@ oceanic_veo250_device_open (device_t **out, const char* name) // Initialize the data cable (PPS mode). oceanic_veo250_init (device); + // Switch the device from surface mode into download mode. Before sending + // this command, the device needs to be in PC mode (manually activated by + // the user), or already in download mode. + oceanic_veo250_device_version ((device_t *) device, device->version, sizeof (device->version)); + *out = (device_t*) device; return DEVICE_STATUS_SUCCESS; @@ -313,7 +320,7 @@ oceanic_veo250_device_close (device_t *abstract) if (! device_is_oceanic_veo250 (abstract)) return DEVICE_STATUS_TYPE_MISMATCH; - // Send the quit command. + // Switch the device back to surface mode. oceanic_veo250_quit (device); // Close the device. diff --git a/src/oceanic_vtpro.c b/src/oceanic_vtpro.c index 02f594f..7180628 100644 --- a/src/oceanic_vtpro.c +++ b/src/oceanic_vtpro.c @@ -49,6 +49,7 @@ typedef struct oceanic_vtpro_device_t { oceanic_common_device_t base; struct serial *port; + unsigned char version[OCEANIC_VTPRO_PACKET_SIZE]; } oceanic_vtpro_device_t; static device_status_t oceanic_vtpro_device_set_fingerprint (device_t *abstract, const unsigned char data[], unsigned int size); @@ -236,6 +237,7 @@ oceanic_vtpro_device_open (device_t **out, const char* name) // Set the default values. device->port = NULL; + memset (device->version, 0, sizeof (device->version)); // Open the device. int rc = serial_open (&device->port, name); @@ -280,6 +282,11 @@ oceanic_vtpro_device_open (device_t **out, const char* name) // Initialize the data cable (MOD mode). oceanic_vtpro_init (device); + // Switch the device from surface mode into download mode. Before sending + // this command, the device needs to be in PC mode (manually activated by + // the user), or already in download mode. + oceanic_vtpro_device_version ((device_t *) device, device->version, sizeof (device->version)); + *out = (device_t*) device; return DEVICE_STATUS_SUCCESS; @@ -294,7 +301,7 @@ oceanic_vtpro_device_close (device_t *abstract) if (! device_is_oceanic_vtpro (abstract)) return DEVICE_STATUS_TYPE_MISMATCH; - // Send the quit command. + // Switch the device back to surface mode. oceanic_vtpro_quit (device); // Close the device.