Added a public API function to set the oldest timestamp.
This commit is contained in:
parent
a540260f61
commit
1d50bcf732
@ -21,6 +21,7 @@
|
||||
|
||||
struct memomouse {
|
||||
struct serial *port;
|
||||
unsigned int timestamp;
|
||||
};
|
||||
|
||||
|
||||
@ -39,6 +40,7 @@ uwatec_memomouse_open (memomouse **out, const char* name)
|
||||
|
||||
// Set the default values.
|
||||
device->port = NULL;
|
||||
device->timestamp = 0;
|
||||
|
||||
// Open the device.
|
||||
int rc = serial_open (&device->port, name);
|
||||
@ -102,6 +104,18 @@ uwatec_memomouse_close (memomouse *device)
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
uwatec_memomouse_set_timestamp (memomouse *device, unsigned int timestamp)
|
||||
{
|
||||
if (device == NULL)
|
||||
return UWATEC_ERROR;
|
||||
|
||||
device->timestamp = timestamp;
|
||||
|
||||
return UWATEC_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
uwatec_memomouse_reverse (unsigned char data[], unsigned int size)
|
||||
{
|
||||
@ -332,7 +346,10 @@ uwatec_memomouse_read (memomouse *device, unsigned char data[], unsigned int siz
|
||||
0x07, // Outer packet size.
|
||||
0x05, 0x00, // Inner packet size.
|
||||
0x55, // Command byte.
|
||||
0x00, 0x00, 0x00, 0x00, // Timestamp.
|
||||
(device->timestamp ) & 0xFF,
|
||||
(device->timestamp >> 8) & 0xFF,
|
||||
(device->timestamp >> 16) & 0xFF,
|
||||
(device->timestamp >> 24) & 0xFF,
|
||||
0x00}; // Outer packet checksum.
|
||||
command[8] = uwatec_memomouse_checksum (command, 8, 0x00);
|
||||
uwatec_memomouse_reverse (command, sizeof (command));
|
||||
|
||||
@ -11,6 +11,8 @@ int uwatec_memomouse_open (memomouse **device, const char* name);
|
||||
|
||||
int uwatec_memomouse_close (memomouse *device);
|
||||
|
||||
int uwatec_memomouse_set_timestamp (memomouse *device, unsigned int timestamp);
|
||||
|
||||
int uwatec_memomouse_read (memomouse *device, unsigned char data[], unsigned int size);
|
||||
|
||||
int uwatec_memomouse_extract_dives (const unsigned char data[], unsigned int size, dive_callback_t callback, void *userdata);
|
||||
|
||||
@ -20,6 +20,7 @@
|
||||
struct smart {
|
||||
struct irda *socket;
|
||||
unsigned int address;
|
||||
unsigned int timestamp;
|
||||
};
|
||||
|
||||
|
||||
@ -63,6 +64,7 @@ uwatec_smart_open (smart **out)
|
||||
// Set the default values.
|
||||
device->socket = NULL;
|
||||
device->address = 0;
|
||||
device->timestamp = 0;
|
||||
|
||||
irda_init ();
|
||||
|
||||
@ -131,6 +133,18 @@ uwatec_smart_close (smart *device)
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
uwatec_smart_set_timestamp (smart *device, unsigned int timestamp)
|
||||
{
|
||||
if (device == NULL)
|
||||
return UWATEC_ERROR;
|
||||
|
||||
device->timestamp = timestamp;
|
||||
|
||||
return UWATEC_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
uwatec_smart_transfer (smart *device, const unsigned char command[], unsigned int csize, unsigned char answer[], unsigned int asize)
|
||||
{
|
||||
@ -238,10 +252,10 @@ uwatec_smart_read (smart *device, unsigned char data[], unsigned int msize)
|
||||
// Data Length.
|
||||
|
||||
command[0] = 0xC6;
|
||||
command[1] = (timestamp ) & 0xFF;
|
||||
command[2] = (timestamp >> 8 ) & 0xFF;
|
||||
command[3] = (timestamp >> 16) & 0xFF;
|
||||
command[4] = (timestamp >> 24) & 0xFF;
|
||||
command[1] = (device->timestamp ) & 0xFF;
|
||||
command[2] = (device->timestamp >> 8 ) & 0xFF;
|
||||
command[3] = (device->timestamp >> 16) & 0xFF;
|
||||
command[4] = (device->timestamp >> 24) & 0xFF;
|
||||
command[5] = 0x10;
|
||||
command[6] = 0x27;
|
||||
command[7] = 0;
|
||||
@ -267,10 +281,10 @@ uwatec_smart_read (smart *device, unsigned char data[], unsigned int msize)
|
||||
// Data.
|
||||
|
||||
command[0] = 0xC4;
|
||||
command[1] = (timestamp ) & 0xFF;
|
||||
command[2] = (timestamp >> 8 ) & 0xFF;
|
||||
command[3] = (timestamp >> 16) & 0xFF;
|
||||
command[4] = (timestamp >> 24) & 0xFF;
|
||||
command[1] = (device->timestamp ) & 0xFF;
|
||||
command[2] = (device->timestamp >> 8 ) & 0xFF;
|
||||
command[3] = (device->timestamp >> 16) & 0xFF;
|
||||
command[4] = (device->timestamp >> 24) & 0xFF;
|
||||
command[5] = 0x10;
|
||||
command[6] = 0x27;
|
||||
command[7] = 0;
|
||||
|
||||
@ -11,6 +11,8 @@ int uwatec_smart_open (smart **device);
|
||||
|
||||
int uwatec_smart_close (smart *device);
|
||||
|
||||
int uwatec_smart_set_timestamp (smart *device, unsigned int timestamp);
|
||||
|
||||
int uwatec_smart_read (smart *device, unsigned char data[], unsigned int size);
|
||||
|
||||
int uwatec_smart_extract_dives (const unsigned char data[], unsigned int size, dive_callback_t callback, void *userdata);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user