Add an option to switch between real and simulated dives.
This commit is contained in:
parent
5614aff3ee
commit
c15b964b26
@ -48,6 +48,7 @@ typedef struct atomics_cobalt_device_t {
|
|||||||
libusb_context *context;
|
libusb_context *context;
|
||||||
libusb_device_handle *handle;
|
libusb_device_handle *handle;
|
||||||
#endif
|
#endif
|
||||||
|
unsigned int simulation;
|
||||||
unsigned char fingerprint[6];
|
unsigned char fingerprint[6];
|
||||||
} atomics_cobalt_device_t;
|
} atomics_cobalt_device_t;
|
||||||
|
|
||||||
@ -96,6 +97,7 @@ atomics_cobalt_device_open (device_t **out)
|
|||||||
// Set the default values.
|
// Set the default values.
|
||||||
device->context = NULL;
|
device->context = NULL;
|
||||||
device->handle = NULL;
|
device->handle = NULL;
|
||||||
|
device->simulation = 0;
|
||||||
memset (device->fingerprint, 0, sizeof (device->fingerprint));
|
memset (device->fingerprint, 0, sizeof (device->fingerprint));
|
||||||
|
|
||||||
int rc = libusb_init (&device->context);
|
int rc = libusb_init (&device->context);
|
||||||
@ -169,6 +171,20 @@ atomics_cobalt_device_set_fingerprint (device_t *abstract, const unsigned char d
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
device_status_t
|
||||||
|
atomics_cobalt_device_set_simulation (device_t *abstract, unsigned int simulation)
|
||||||
|
{
|
||||||
|
atomics_cobalt_device_t *device = (atomics_cobalt_device_t *) abstract;
|
||||||
|
|
||||||
|
if (! device_is_atomics_cobalt (abstract))
|
||||||
|
return DEVICE_STATUS_TYPE_MISMATCH;
|
||||||
|
|
||||||
|
device->simulation = simulation;
|
||||||
|
|
||||||
|
return DEVICE_STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static device_status_t
|
static device_status_t
|
||||||
atomics_cobalt_read_dive (device_t *abstract, dc_buffer_t *buffer, int init)
|
atomics_cobalt_read_dive (device_t *abstract, dc_buffer_t *buffer, int init)
|
||||||
{
|
{
|
||||||
@ -185,7 +201,11 @@ atomics_cobalt_read_dive (device_t *abstract, dc_buffer_t *buffer, int init)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Send the command to the dive computer.
|
// Send the command to the dive computer.
|
||||||
uint8_t bRequest = init ? 0x09 : 0x0A;
|
uint8_t bRequest = 0;
|
||||||
|
if (device->simulation)
|
||||||
|
bRequest = init ? 0x02 : 0x03;
|
||||||
|
else
|
||||||
|
bRequest = init ? 0x09 : 0x0A;
|
||||||
int rc = libusb_control_transfer (device->handle,
|
int rc = libusb_control_transfer (device->handle,
|
||||||
LIBUSB_RECIPIENT_DEVICE | LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_ENDPOINT_OUT,
|
LIBUSB_RECIPIENT_DEVICE | LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_ENDPOINT_OUT,
|
||||||
bRequest, 0, 0, NULL, 0, TIMEOUT);
|
bRequest, 0, 0, NULL, 0, TIMEOUT);
|
||||||
|
|||||||
@ -32,6 +32,9 @@ extern "C" {
|
|||||||
device_status_t
|
device_status_t
|
||||||
atomics_cobalt_device_open (device_t **device);
|
atomics_cobalt_device_open (device_t **device);
|
||||||
|
|
||||||
|
device_status_t
|
||||||
|
atomics_cobalt_device_set_simulation (device_t *abstract, unsigned int simulation);
|
||||||
|
|
||||||
parser_status_t
|
parser_status_t
|
||||||
atomics_cobalt_parser_create (parser_t **parser);
|
atomics_cobalt_parser_create (parser_t **parser);
|
||||||
|
|
||||||
|
|||||||
@ -116,3 +116,4 @@ hw_ostc_device_open
|
|||||||
hw_ostc_extract_dives
|
hw_ostc_extract_dives
|
||||||
zeagle_n2ition3_device_open
|
zeagle_n2ition3_device_open
|
||||||
atomics_cobalt_device_open
|
atomics_cobalt_device_open
|
||||||
|
atomics_cobalt_device_set_simulation
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user