From 3b61ef6f6306adda4e4485ad2a6696fcd43ac8f2 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Fri, 21 Nov 2008 08:40:30 +0000 Subject: [PATCH] Use the address of the last read page in the keepalive command. --- src/oceanic_veo250.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/oceanic_veo250.c b/src/oceanic_veo250.c index 5f85ba4..6c89249 100644 --- a/src/oceanic_veo250.c +++ b/src/oceanic_veo250.c @@ -51,6 +51,7 @@ typedef struct oceanic_veo250_device_t oceanic_veo250_device_t; struct oceanic_veo250_device_t { device_t base; struct serial *port; + unsigned int last; }; static device_status_t oceanic_veo250_device_version (device_t *abstract, unsigned char data[], unsigned int size); @@ -228,6 +229,7 @@ oceanic_veo250_device_open (device_t **out, const char* name) // Set the default values. device->port = NULL; + device->last = 0; // Open the device. int rc = serial_open (&device->port, name); @@ -312,7 +314,10 @@ oceanic_veo250_device_keepalive (device_t *abstract) return DEVICE_STATUS_TYPE_MISMATCH; // Send the command to the dive computer. - unsigned char command[4] = {0x91, 0x00, 0x00, 0x00}; + unsigned char command[4] = {0x91, + (device->last ) & 0xFF, // low + (device->last >> 8) & 0xFF, // high + 0x00}; device_status_t rc = oceanic_veo250_send (device, command, sizeof (command)); if (rc != DEVICE_STATUS_SUCCESS) { WARNING ("Failed to send the command."); @@ -396,6 +401,8 @@ oceanic_veo250_device_read (device_t *abstract, unsigned int address, unsigned c memcpy (data, answer, OCEANIC_VEO250_PACKET_SIZE); + device->last = number; + #ifndef NDEBUG message ("VEO250Read(0x%04x,%d)=\"", address, OCEANIC_VEO250_PACKET_SIZE); for (unsigned int i = 0; i < OCEANIC_VEO250_PACKET_SIZE; ++i) {