Report the firmware version in the devinfo event
This commit is contained in:
parent
50f3ba3189
commit
b7850e9cbf
@ -910,7 +910,7 @@ oceanic_atom2_device_open (dc_device_t **out, dc_context_t *context, dc_iostream
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Detect the memory layout.
|
// Detect the memory layout.
|
||||||
device->base.layout = OCEANIC_COMMON_MATCH(device->base.version, versions);
|
device->base.layout = OCEANIC_COMMON_MATCH(device->base.version, versions, &device->base.firmware);
|
||||||
if (device->base.layout == NULL) {
|
if (device->base.layout == NULL) {
|
||||||
WARNING (context, "Unsupported device detected!");
|
WARNING (context, "Unsupported device detected!");
|
||||||
if (memcmp(device->base.version + 12, "256K", 4) == 0) {
|
if (memcmp(device->base.version + 12, "256K", 4) == 0) {
|
||||||
|
|||||||
@ -130,13 +130,16 @@ oceanic_common_match_pattern (const unsigned char *string, const unsigned char *
|
|||||||
}
|
}
|
||||||
|
|
||||||
const oceanic_common_layout_t *
|
const oceanic_common_layout_t *
|
||||||
oceanic_common_match (const unsigned char *version, const oceanic_common_version_t patterns[], size_t n)
|
oceanic_common_match (const unsigned char *version, const oceanic_common_version_t patterns[], size_t n, unsigned int *firmware)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < n; ++i) {
|
for (size_t i = 0; i < n; ++i) {
|
||||||
unsigned int fw = 0;
|
unsigned int fw = 0;
|
||||||
if (oceanic_common_match_pattern (version, patterns[i].pattern, &fw) &&
|
if (oceanic_common_match_pattern (version, patterns[i].pattern, &fw) &&
|
||||||
fw >= patterns[i].firmware)
|
fw >= patterns[i].firmware)
|
||||||
{
|
{
|
||||||
|
if (firmware) {
|
||||||
|
*firmware = fw;
|
||||||
|
}
|
||||||
return patterns[i].layout;
|
return patterns[i].layout;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -151,6 +154,7 @@ oceanic_common_device_init (oceanic_common_device_t *device)
|
|||||||
assert (device != NULL);
|
assert (device != NULL);
|
||||||
|
|
||||||
// Set the default values.
|
// Set the default values.
|
||||||
|
device->firmware = 0;
|
||||||
memset (device->version, 0, sizeof (device->version));
|
memset (device->version, 0, sizeof (device->version));
|
||||||
memset (device->fingerprint, 0, sizeof (device->fingerprint));
|
memset (device->fingerprint, 0, sizeof (device->fingerprint));
|
||||||
device->layout = NULL;
|
device->layout = NULL;
|
||||||
@ -608,7 +612,7 @@ oceanic_common_device_foreach (dc_device_t *abstract, dc_dive_callback_t callbac
|
|||||||
// Emit a device info event.
|
// Emit a device info event.
|
||||||
dc_event_devinfo_t devinfo;
|
dc_event_devinfo_t devinfo;
|
||||||
devinfo.model = array_uint16_be (id + 8);
|
devinfo.model = array_uint16_be (id + 8);
|
||||||
devinfo.firmware = 0;
|
devinfo.firmware = device->firmware;
|
||||||
if (layout->pt_mode_serial == 0)
|
if (layout->pt_mode_serial == 0)
|
||||||
devinfo.serial = bcd2dec (id[10]) * 10000 + bcd2dec (id[11]) * 100 + bcd2dec (id[12]);
|
devinfo.serial = bcd2dec (id[10]) * 10000 + bcd2dec (id[11]) * 100 + bcd2dec (id[12]);
|
||||||
else if (layout->pt_mode_serial == 1)
|
else if (layout->pt_mode_serial == 1)
|
||||||
|
|||||||
@ -31,9 +31,9 @@ extern "C" {
|
|||||||
#define PAGESIZE 0x10
|
#define PAGESIZE 0x10
|
||||||
#define FPMAXSIZE 0x20
|
#define FPMAXSIZE 0x20
|
||||||
|
|
||||||
#define OCEANIC_COMMON_MATCH(version,patterns) \
|
#define OCEANIC_COMMON_MATCH(version,patterns,firmware) \
|
||||||
oceanic_common_match ((version), (patterns), \
|
oceanic_common_match ((version), (patterns), \
|
||||||
sizeof (patterns) / sizeof *(patterns))
|
sizeof (patterns) / sizeof *(patterns), (firmware))
|
||||||
|
|
||||||
typedef struct oceanic_common_layout_t {
|
typedef struct oceanic_common_layout_t {
|
||||||
// Memory size.
|
// Memory size.
|
||||||
@ -61,6 +61,7 @@ typedef struct oceanic_common_layout_t {
|
|||||||
|
|
||||||
typedef struct oceanic_common_device_t {
|
typedef struct oceanic_common_device_t {
|
||||||
dc_device_t base;
|
dc_device_t base;
|
||||||
|
unsigned int firmware;
|
||||||
unsigned char version[PAGESIZE];
|
unsigned char version[PAGESIZE];
|
||||||
unsigned char fingerprint[FPMAXSIZE];
|
unsigned char fingerprint[FPMAXSIZE];
|
||||||
const oceanic_common_layout_t *layout;
|
const oceanic_common_layout_t *layout;
|
||||||
@ -80,7 +81,7 @@ typedef struct oceanic_common_version_t {
|
|||||||
} oceanic_common_version_t;
|
} oceanic_common_version_t;
|
||||||
|
|
||||||
const oceanic_common_layout_t *
|
const oceanic_common_layout_t *
|
||||||
oceanic_common_match (const unsigned char *version, const oceanic_common_version_t patterns[], size_t n);
|
oceanic_common_match (const unsigned char *version, const oceanic_common_version_t patterns[], size_t n, unsigned int *firmware);
|
||||||
|
|
||||||
void
|
void
|
||||||
oceanic_common_device_init (oceanic_common_device_t *device);
|
oceanic_common_device_init (oceanic_common_device_t *device);
|
||||||
|
|||||||
@ -316,7 +316,7 @@ oceanic_veo250_device_open (dc_device_t **out, dc_context_t *context, dc_iostrea
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Detect the memory layout.
|
// Detect the memory layout.
|
||||||
device->base.layout = OCEANIC_COMMON_MATCH(device->base.version, versions);
|
device->base.layout = OCEANIC_COMMON_MATCH(device->base.version, versions, &device->base.firmware);
|
||||||
if (device->base.layout == NULL) {
|
if (device->base.layout == NULL) {
|
||||||
WARNING (context, "Unsupported device detected!");
|
WARNING (context, "Unsupported device detected!");
|
||||||
device->base.layout = &oceanic_veo250_layout;
|
device->base.layout = &oceanic_veo250_layout;
|
||||||
|
|||||||
@ -493,7 +493,7 @@ oceanic_vtpro_device_open (dc_device_t **out, dc_context_t *context, dc_iostream
|
|||||||
if (model == AERIS500AI) {
|
if (model == AERIS500AI) {
|
||||||
device->base.layout = &aeris_500ai_layout;
|
device->base.layout = &aeris_500ai_layout;
|
||||||
} else {
|
} else {
|
||||||
device->base.layout = OCEANIC_COMMON_MATCH(device->base.version, versions);
|
device->base.layout = OCEANIC_COMMON_MATCH(device->base.version, versions, &device->base.firmware);
|
||||||
if (device->base.layout == NULL) {
|
if (device->base.layout == NULL) {
|
||||||
WARNING (context, "Unsupported device detected!");
|
WARNING (context, "Unsupported device detected!");
|
||||||
device->base.layout = &oceanic_vtpro_layout;
|
device->base.layout = &oceanic_vtpro_layout;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user