Merge git://github.com/libdivecomputer/libdivecomputer into Subsurface-NG
Merge with upstream from Jef. Small trivial fixlets. * 'master' of git://github.com/libdivecomputer/libdivecomputer: Fix the Cobalt 2 memory size Use the travis homebrew plugin to install packages Increase the internal log buffer Fix undefined behaviour in left shifts
This commit is contained in:
commit
e4c96e93ca
@ -37,11 +37,10 @@ addons:
|
||||
packages:
|
||||
- libbluetooth-dev
|
||||
- libusb-1.0-0-dev
|
||||
|
||||
install:
|
||||
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then
|
||||
brew install hidapi libusb;
|
||||
fi
|
||||
homebrew:
|
||||
packages:
|
||||
- hidapi
|
||||
- libusb
|
||||
|
||||
script:
|
||||
- case $CC in
|
||||
|
||||
33
src/array.c
33
src/array.c
@ -167,7 +167,7 @@ array_uint_be (const unsigned char data[], unsigned int n)
|
||||
unsigned int value = 0;
|
||||
for (unsigned int i = 0; i < n; ++i) {
|
||||
shift -= 8;
|
||||
value |= data[i] << shift;
|
||||
value |= (unsigned int) data[i] << shift;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
@ -178,7 +178,7 @@ array_uint_le (const unsigned char data[], unsigned int n)
|
||||
unsigned int shift = 0;
|
||||
unsigned int value = 0;
|
||||
for (unsigned int i = 0; i < n; ++i) {
|
||||
value |= data[i] << shift;
|
||||
value |= (unsigned int) data[i] << shift;
|
||||
shift += 8;
|
||||
}
|
||||
return value;
|
||||
@ -187,21 +187,30 @@ array_uint_le (const unsigned char data[], unsigned int n)
|
||||
unsigned int
|
||||
array_uint32_be (const unsigned char data[])
|
||||
{
|
||||
return (data[0] << 24) + (data[1] << 16) + (data[2] << 8) + data[3];
|
||||
return ((unsigned int) data[0] << 24) |
|
||||
((unsigned int) data[1] << 16) |
|
||||
((unsigned int) data[2] << 8) |
|
||||
((unsigned int) data[3] << 0);
|
||||
}
|
||||
|
||||
|
||||
unsigned int
|
||||
array_uint32_le (const unsigned char data[])
|
||||
{
|
||||
return data[0] + (data[1] << 8) + (data[2] << 16) + (data[3] << 24);
|
||||
return ((unsigned int) data[0] << 0) |
|
||||
((unsigned int) data[1] << 8) |
|
||||
((unsigned int) data[2] << 16) |
|
||||
((unsigned int) data[3] << 24);
|
||||
}
|
||||
|
||||
|
||||
unsigned int
|
||||
array_uint32_word_be (const unsigned char data[])
|
||||
{
|
||||
return data[1] + (data[0] << 8) + (data[3] << 16) + (data[2] << 24);
|
||||
return ((unsigned int) data[0] << 8) |
|
||||
((unsigned int) data[1] << 0) |
|
||||
((unsigned int) data[2] << 24) |
|
||||
((unsigned int) data[3] << 16);
|
||||
}
|
||||
|
||||
|
||||
@ -218,7 +227,9 @@ array_uint32_le_set (unsigned char data[], const unsigned int input)
|
||||
unsigned int
|
||||
array_uint24_be (const unsigned char data[])
|
||||
{
|
||||
return (data[0] << 16) + (data[1] << 8) + data[2];
|
||||
return ((unsigned int) data[0] << 16) |
|
||||
((unsigned int) data[1] << 8) |
|
||||
((unsigned int) data[2] << 0);
|
||||
}
|
||||
|
||||
|
||||
@ -234,20 +245,24 @@ array_uint24_be_set (unsigned char data[], const unsigned int input)
|
||||
unsigned int
|
||||
array_uint24_le (const unsigned char data[])
|
||||
{
|
||||
return data[0] + (data[1] << 8) + (data[2] << 16);
|
||||
return ((unsigned int) data[0] << 0) |
|
||||
((unsigned int) data[1] << 8) |
|
||||
((unsigned int) data[2] << 16);
|
||||
}
|
||||
|
||||
unsigned short
|
||||
array_uint16_be (const unsigned char data[])
|
||||
{
|
||||
return (data[0] << 8) + data[1];
|
||||
return ((unsigned int) data[0] << 8) |
|
||||
((unsigned int) data[1] << 0);
|
||||
}
|
||||
|
||||
|
||||
unsigned short
|
||||
array_uint16_le (const unsigned char data[])
|
||||
{
|
||||
return data[0] + (data[1] << 8);
|
||||
return ((unsigned int) data[0] << 0) |
|
||||
((unsigned int) data[1] << 8);
|
||||
}
|
||||
|
||||
unsigned char
|
||||
|
||||
@ -43,13 +43,17 @@
|
||||
|
||||
#define EXITCODE(rc) (rc == LIBUSB_ERROR_TIMEOUT ? DC_STATUS_TIMEOUT : DC_STATUS_IO)
|
||||
|
||||
#define COBALT1 0
|
||||
#define COBALT2 2
|
||||
|
||||
#define VID 0x0471
|
||||
#define PID 0x0888
|
||||
#define TIMEOUT 2000
|
||||
|
||||
#define FP_OFFSET 20
|
||||
|
||||
#define SZ_MEMORY (29 * 64 * 1024)
|
||||
#define SZ_MEMORY1 (29 * 64 * 1024) // Cobalt 1
|
||||
#define SZ_MEMORY2 (41 * 64 * 1024) // Cobalt 2
|
||||
#define SZ_VERSION 14
|
||||
|
||||
typedef struct atomics_cobalt_device_t {
|
||||
@ -350,9 +354,12 @@ atomics_cobalt_device_foreach (dc_device_t *abstract, dc_dive_callback_t callbac
|
||||
{
|
||||
atomics_cobalt_device_t *device = (atomics_cobalt_device_t *) abstract;
|
||||
|
||||
// Get the model number.
|
||||
unsigned int model = array_uint16_le (device->version + 12);
|
||||
|
||||
// Enable progress notifications.
|
||||
dc_event_progress_t progress = EVENT_PROGRESS_INITIALIZER;
|
||||
progress.maximum = SZ_MEMORY + 2;
|
||||
progress.maximum = (model == COBALT2 ? SZ_MEMORY2 : SZ_MEMORY1) + 2;
|
||||
device_event_emit (abstract, DC_EVENT_PROGRESS, &progress);
|
||||
|
||||
// Emit a vendor event.
|
||||
|
||||
@ -41,7 +41,7 @@ struct dc_context_t {
|
||||
dc_logfunc_t logfunc;
|
||||
void *userdata;
|
||||
#ifdef ENABLE_LOGGING
|
||||
char msg[8192 + 32];
|
||||
char msg[16384 + 32];
|
||||
dc_timer_t *timer;
|
||||
#endif
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user