Support reading the logbook in forward direction

To prepare the code to support reading the logbook ringbuffer in the
forward direction, a new field is added to the layout data structure to
indicate the direction of the ringbuffer, the workaround for handling an
invalid pointer is extended to support both directions, and finally the
correct parameters are passed to the rbstream reader.
This commit is contained in:
Jef Driesen 2024-03-04 21:38:07 +01:00
parent f49af5208c
commit 4cc0bc25ae
5 changed files with 40 additions and 2 deletions

View File

@ -100,6 +100,7 @@ static const oceanic_common_layout_t aeris_f10_layout = {
0x0100, /* rb_logbook_begin */ 0x0100, /* rb_logbook_begin */
0x0D80, /* rb_logbook_end */ 0x0D80, /* rb_logbook_end */
32, /* rb_logbook_entry_size */ 32, /* rb_logbook_entry_size */
1, /* rb_logbook_direction */
0x0D80, /* rb_profile_begin */ 0x0D80, /* rb_profile_begin */
0x10000, /* rb_profile_end */ 0x10000, /* rb_profile_end */
0, /* pt_mode_global */ 0, /* pt_mode_global */
@ -115,6 +116,7 @@ static const oceanic_common_layout_t aeris_f11_layout = {
0x0100, /* rb_logbook_begin */ 0x0100, /* rb_logbook_begin */
0x0D80, /* rb_logbook_end */ 0x0D80, /* rb_logbook_end */
32, /* rb_logbook_entry_size */ 32, /* rb_logbook_entry_size */
1, /* rb_logbook_direction */
0x0D80, /* rb_profile_begin */ 0x0D80, /* rb_profile_begin */
0x20000, /* rb_profile_end */ 0x20000, /* rb_profile_end */
0, /* pt_mode_global */ 0, /* pt_mode_global */
@ -130,6 +132,7 @@ static const oceanic_common_layout_t oceanic_default_layout = {
0x0240, /* rb_logbook_begin */ 0x0240, /* rb_logbook_begin */
0x0A40, /* rb_logbook_end */ 0x0A40, /* rb_logbook_end */
8, /* rb_logbook_entry_size */ 8, /* rb_logbook_entry_size */
1, /* rb_logbook_direction */
0x0A40, /* rb_profile_begin */ 0x0A40, /* rb_profile_begin */
0x10000, /* rb_profile_end */ 0x10000, /* rb_profile_end */
0, /* pt_mode_global */ 0, /* pt_mode_global */
@ -145,6 +148,7 @@ static const oceanic_common_layout_t oceanic_atom1_layout = {
0x0240, /* rb_logbook_begin */ 0x0240, /* rb_logbook_begin */
0x0440, /* rb_logbook_end */ 0x0440, /* rb_logbook_end */
8, /* rb_logbook_entry_size */ 8, /* rb_logbook_entry_size */
1, /* rb_logbook_direction */
0x0440, /* rb_profile_begin */ 0x0440, /* rb_profile_begin */
0x8000, /* rb_profile_end */ 0x8000, /* rb_profile_end */
0, /* pt_mode_global */ 0, /* pt_mode_global */
@ -160,6 +164,7 @@ static const oceanic_common_layout_t oceanic_atom2a_layout = {
0x0240, /* rb_logbook_begin */ 0x0240, /* rb_logbook_begin */
0x0A40, /* rb_logbook_end */ 0x0A40, /* rb_logbook_end */
8, /* rb_logbook_entry_size */ 8, /* rb_logbook_entry_size */
1, /* rb_logbook_direction */
0x0A40, /* rb_profile_begin */ 0x0A40, /* rb_profile_begin */
0xFE00, /* rb_profile_end */ 0xFE00, /* rb_profile_end */
0, /* pt_mode_global */ 0, /* pt_mode_global */
@ -175,6 +180,7 @@ static const oceanic_common_layout_t oceanic_atom2b_layout = {
0x0240, /* rb_logbook_begin */ 0x0240, /* rb_logbook_begin */
0x0A40, /* rb_logbook_end */ 0x0A40, /* rb_logbook_end */
8, /* rb_logbook_entry_size */ 8, /* rb_logbook_entry_size */
1, /* rb_logbook_direction */
0x0A40, /* rb_profile_begin */ 0x0A40, /* rb_profile_begin */
0xFE00, /* rb_profile_end */ 0xFE00, /* rb_profile_end */
0, /* pt_mode_global */ 0, /* pt_mode_global */
@ -190,6 +196,7 @@ static const oceanic_common_layout_t oceanic_atom2c_layout = {
0x0240, /* rb_logbook_begin */ 0x0240, /* rb_logbook_begin */
0x0A40, /* rb_logbook_end */ 0x0A40, /* rb_logbook_end */
8, /* rb_logbook_entry_size */ 8, /* rb_logbook_entry_size */
1, /* rb_logbook_direction */
0x0A40, /* rb_profile_begin */ 0x0A40, /* rb_profile_begin */
0xFFF0, /* rb_profile_end */ 0xFFF0, /* rb_profile_end */
0, /* pt_mode_global */ 0, /* pt_mode_global */
@ -205,6 +212,7 @@ static const oceanic_common_layout_t sherwood_wisdom_layout = {
0x03D0, /* rb_logbook_begin */ 0x03D0, /* rb_logbook_begin */
0x0A40, /* rb_logbook_end */ 0x0A40, /* rb_logbook_end */
8, /* rb_logbook_entry_size */ 8, /* rb_logbook_entry_size */
1, /* rb_logbook_direction */
0x0A40, /* rb_profile_begin */ 0x0A40, /* rb_profile_begin */
0xFE00, /* rb_profile_end */ 0xFE00, /* rb_profile_end */
0, /* pt_mode_global */ 0, /* pt_mode_global */
@ -220,6 +228,7 @@ static const oceanic_common_layout_t oceanic_proplus3_layout = {
0x03E0, /* rb_logbook_begin */ 0x03E0, /* rb_logbook_begin */
0x0A40, /* rb_logbook_end */ 0x0A40, /* rb_logbook_end */
8, /* rb_logbook_entry_size */ 8, /* rb_logbook_entry_size */
1, /* rb_logbook_direction */
0x0A40, /* rb_profile_begin */ 0x0A40, /* rb_profile_begin */
0xFE00, /* rb_profile_end */ 0xFE00, /* rb_profile_end */
0, /* pt_mode_global */ 0, /* pt_mode_global */
@ -235,6 +244,7 @@ static const oceanic_common_layout_t tusa_zenair_layout = {
0x0240, /* rb_logbook_begin */ 0x0240, /* rb_logbook_begin */
0x0A40, /* rb_logbook_end */ 0x0A40, /* rb_logbook_end */
8, /* rb_logbook_entry_size */ 8, /* rb_logbook_entry_size */
1, /* rb_logbook_direction */
0x0A40, /* rb_profile_begin */ 0x0A40, /* rb_profile_begin */
0xFE00, /* rb_profile_end */ 0xFE00, /* rb_profile_end */
0, /* pt_mode_global */ 0, /* pt_mode_global */
@ -250,6 +260,7 @@ static const oceanic_common_layout_t oceanic_oc1_layout = {
0x0240, /* rb_logbook_begin */ 0x0240, /* rb_logbook_begin */
0x0A40, /* rb_logbook_end */ 0x0A40, /* rb_logbook_end */
8, /* rb_logbook_entry_size */ 8, /* rb_logbook_entry_size */
1, /* rb_logbook_direction */
0x0A40, /* rb_profile_begin */ 0x0A40, /* rb_profile_begin */
0x1FE00, /* rb_profile_end */ 0x1FE00, /* rb_profile_end */
0, /* pt_mode_global */ 0, /* pt_mode_global */
@ -265,6 +276,7 @@ static const oceanic_common_layout_t oceanic_oci_layout = {
0x10C0, /* rb_logbook_begin */ 0x10C0, /* rb_logbook_begin */
0x1400, /* rb_logbook_end */ 0x1400, /* rb_logbook_end */
8, /* rb_logbook_entry_size */ 8, /* rb_logbook_entry_size */
1, /* rb_logbook_direction */
0x1400, /* rb_profile_begin */ 0x1400, /* rb_profile_begin */
0x1FE00, /* rb_profile_end */ 0x1FE00, /* rb_profile_end */
0, /* pt_mode_global */ 0, /* pt_mode_global */
@ -280,6 +292,7 @@ static const oceanic_common_layout_t oceanic_atom3_layout = {
0x0400, /* rb_logbook_begin */ 0x0400, /* rb_logbook_begin */
0x0A40, /* rb_logbook_end */ 0x0A40, /* rb_logbook_end */
8, /* rb_logbook_entry_size */ 8, /* rb_logbook_entry_size */
1, /* rb_logbook_direction */
0x0A40, /* rb_profile_begin */ 0x0A40, /* rb_profile_begin */
0x1FE00, /* rb_profile_end */ 0x1FE00, /* rb_profile_end */
0, /* pt_mode_global */ 0, /* pt_mode_global */
@ -295,6 +308,7 @@ static const oceanic_common_layout_t oceanic_vt4_layout = {
0x0420, /* rb_logbook_begin */ 0x0420, /* rb_logbook_begin */
0x0A40, /* rb_logbook_end */ 0x0A40, /* rb_logbook_end */
8, /* rb_logbook_entry_size */ 8, /* rb_logbook_entry_size */
1, /* rb_logbook_direction */
0x0A40, /* rb_profile_begin */ 0x0A40, /* rb_profile_begin */
0x1FE00, /* rb_profile_end */ 0x1FE00, /* rb_profile_end */
0, /* pt_mode_global */ 0, /* pt_mode_global */
@ -310,6 +324,7 @@ static const oceanic_common_layout_t hollis_tx1_layout = {
0x0780, /* rb_logbook_begin */ 0x0780, /* rb_logbook_begin */
0x1000, /* rb_logbook_end */ 0x1000, /* rb_logbook_end */
8, /* rb_logbook_entry_size */ 8, /* rb_logbook_entry_size */
1, /* rb_logbook_direction */
0x1000, /* rb_profile_begin */ 0x1000, /* rb_profile_begin */
0x40000, /* rb_profile_end */ 0x40000, /* rb_profile_end */
0, /* pt_mode_global */ 0, /* pt_mode_global */
@ -325,6 +340,7 @@ static const oceanic_common_layout_t oceanic_veo1_layout = {
0x0400, /* rb_logbook_begin */ 0x0400, /* rb_logbook_begin */
0x0400, /* rb_logbook_end */ 0x0400, /* rb_logbook_end */
8, /* rb_logbook_entry_size */ 8, /* rb_logbook_entry_size */
1, /* rb_logbook_direction */
0x0400, /* rb_profile_begin */ 0x0400, /* rb_profile_begin */
0x0400, /* rb_profile_end */ 0x0400, /* rb_profile_end */
0, /* pt_mode_global */ 0, /* pt_mode_global */
@ -340,6 +356,7 @@ static const oceanic_common_layout_t oceanic_reactpro_layout = {
0x0400, /* rb_logbook_begin */ 0x0400, /* rb_logbook_begin */
0x0600, /* rb_logbook_end */ 0x0600, /* rb_logbook_end */
8, /* rb_logbook_entry_size */ 8, /* rb_logbook_entry_size */
1, /* rb_logbook_direction */
0x0600, /* rb_profile_begin */ 0x0600, /* rb_profile_begin */
0xFE00, /* rb_profile_end */ 0xFE00, /* rb_profile_end */
1, /* pt_mode_global */ 1, /* pt_mode_global */
@ -355,6 +372,7 @@ static const oceanic_common_layout_t oceanic_proplusx_layout = {
0x1000, /* rb_logbook_begin */ 0x1000, /* rb_logbook_begin */
0x10000, /* rb_logbook_end */ 0x10000, /* rb_logbook_end */
16, /* rb_logbook_entry_size */ 16, /* rb_logbook_entry_size */
1, /* rb_logbook_direction */
0x40000, /* rb_profile_begin */ 0x40000, /* rb_profile_begin */
0x440000, /* rb_profile_end */ 0x440000, /* rb_profile_end */
0, /* pt_mode_global */ 0, /* pt_mode_global */
@ -370,6 +388,7 @@ static const oceanic_common_layout_t aqualung_i770r_layout = {
0x2000, /* rb_logbook_begin */ 0x2000, /* rb_logbook_begin */
0x10000, /* rb_logbook_end */ 0x10000, /* rb_logbook_end */
16, /* rb_logbook_entry_size */ 16, /* rb_logbook_entry_size */
1, /* rb_logbook_direction */
0x40000, /* rb_profile_begin */ 0x40000, /* rb_profile_begin */
0x640000, /* rb_profile_end */ 0x640000, /* rb_profile_end */
0, /* pt_mode_global */ 0, /* pt_mode_global */
@ -385,6 +404,7 @@ static const oceanic_common_layout_t aeris_a300cs_layout = {
0x0900, /* rb_logbook_begin */ 0x0900, /* rb_logbook_begin */
0x1000, /* rb_logbook_end */ 0x1000, /* rb_logbook_end */
16, /* rb_logbook_entry_size */ 16, /* rb_logbook_entry_size */
1, /* rb_logbook_direction */
0x1000, /* rb_profile_begin */ 0x1000, /* rb_profile_begin */
0x3FE00, /* rb_profile_end */ 0x3FE00, /* rb_profile_end */
0, /* pt_mode_global */ 0, /* pt_mode_global */
@ -400,6 +420,7 @@ static const oceanic_common_layout_t aqualung_i450t_layout = {
0x10C0, /* rb_logbook_begin */ 0x10C0, /* rb_logbook_begin */
0x1400, /* rb_logbook_end */ 0x1400, /* rb_logbook_end */
16, /* rb_logbook_entry_size */ 16, /* rb_logbook_entry_size */
1, /* rb_logbook_direction */
0x1400, /* rb_profile_begin */ 0x1400, /* rb_profile_begin */
0x3FE00, /* rb_profile_end */ 0x3FE00, /* rb_profile_end */
0, /* pt_mode_global */ 0, /* pt_mode_global */

View File

@ -329,6 +329,9 @@ oceanic_common_device_logbook (dc_device_t *abstract, dc_event_progress_t *progr
rb_logbook_begin > layout->rb_logbook_end) rb_logbook_begin > layout->rb_logbook_end)
{ {
ERROR (abstract->context, "Invalid logbook begin pointer detected (0x%04x).", rb_logbook_begin); ERROR (abstract->context, "Invalid logbook begin pointer detected (0x%04x).", rb_logbook_begin);
if (layout->rb_logbook_direction == 0) {
return DC_STATUS_DATAFORMAT;
}
// Fall back to downloading the entire logbook ringbuffer as // Fall back to downloading the entire logbook ringbuffer as
// workaround for an invalid logbook begin pointer! // workaround for an invalid logbook begin pointer!
rb_logbook_begin = rb_logbook_end; rb_logbook_begin = rb_logbook_end;
@ -337,7 +340,12 @@ oceanic_common_device_logbook (dc_device_t *abstract, dc_event_progress_t *progr
rb_logbook_end > layout->rb_logbook_end) rb_logbook_end > layout->rb_logbook_end)
{ {
ERROR (abstract->context, "Invalid logbook end pointer detected (0x%04x).", rb_logbook_end); ERROR (abstract->context, "Invalid logbook end pointer detected (0x%04x).", rb_logbook_end);
return DC_STATUS_DATAFORMAT; if (layout->rb_logbook_direction != 0) {
return DC_STATUS_DATAFORMAT;
}
// Fall back to downloading the entire logbook ringbuffer as
// workaround for an invalid logbook end pointer!
rb_logbook_end = rb_logbook_begin;
} }
// Calculate the number of bytes. // Calculate the number of bytes.
@ -366,7 +374,11 @@ oceanic_common_device_logbook (dc_device_t *abstract, dc_event_progress_t *progr
// Create the ringbuffer stream. // Create the ringbuffer stream.
dc_rbstream_t *rbstream = NULL; dc_rbstream_t *rbstream = NULL;
rc = dc_rbstream_new (&rbstream, abstract, PAGESIZE, PAGESIZE * device->multipage, layout->rb_logbook_begin, layout->rb_logbook_end, rb_logbook_end, DC_RBSTREAM_BACKWARD); rc = dc_rbstream_new (&rbstream, abstract,
PAGESIZE, PAGESIZE * device->multipage,
layout->rb_logbook_begin, layout->rb_logbook_end,
layout->rb_logbook_direction ? rb_logbook_end : rb_logbook_begin,
layout->rb_logbook_direction ? DC_RBSTREAM_BACKWARD : DC_RBSTREAM_FORWARD);
if (rc != DC_STATUS_SUCCESS) { if (rc != DC_STATUS_SUCCESS) {
ERROR (abstract->context, "Failed to create the ringbuffer stream."); ERROR (abstract->context, "Failed to create the ringbuffer stream.");
return rc; return rc;

View File

@ -144,6 +144,7 @@ typedef struct oceanic_common_layout_t {
unsigned int rb_logbook_begin; unsigned int rb_logbook_begin;
unsigned int rb_logbook_end; unsigned int rb_logbook_end;
unsigned int rb_logbook_entry_size; unsigned int rb_logbook_entry_size;
unsigned int rb_logbook_direction;
// Profile ringbuffer // Profile ringbuffer
unsigned int rb_profile_begin; unsigned int rb_profile_begin;
unsigned int rb_profile_end; unsigned int rb_profile_end;

View File

@ -72,6 +72,7 @@ static const oceanic_common_layout_t oceanic_veo250_layout = {
0x0400, /* rb_logbook_begin */ 0x0400, /* rb_logbook_begin */
0x0600, /* rb_logbook_end */ 0x0600, /* rb_logbook_end */
8, /* rb_logbook_entry_size */ 8, /* rb_logbook_entry_size */
1, /* rb_logbook_direction */
0x0600, /* rb_profile_begin */ 0x0600, /* rb_profile_begin */
0x8000, /* rb_profile_end */ 0x8000, /* rb_profile_end */
1, /* pt_mode_global */ 1, /* pt_mode_global */

View File

@ -82,6 +82,7 @@ static const oceanic_common_layout_t oceanic_vtpro_layout = {
0x0240, /* rb_logbook_begin */ 0x0240, /* rb_logbook_begin */
0x0440, /* rb_logbook_end */ 0x0440, /* rb_logbook_end */
8, /* rb_logbook_entry_size */ 8, /* rb_logbook_entry_size */
1, /* rb_logbook_direction */
0x0440, /* rb_profile_begin */ 0x0440, /* rb_profile_begin */
0x8000, /* rb_profile_end */ 0x8000, /* rb_profile_end */
0, /* pt_mode_global */ 0, /* pt_mode_global */
@ -97,6 +98,7 @@ static const oceanic_common_layout_t oceanic_wisdom_layout = {
0x03D0, /* rb_logbook_begin */ 0x03D0, /* rb_logbook_begin */
0x05D0, /* rb_logbook_end */ 0x05D0, /* rb_logbook_end */
8, /* rb_logbook_entry_size */ 8, /* rb_logbook_entry_size */
1, /* rb_logbook_direction */
0x05D0, /* rb_profile_begin */ 0x05D0, /* rb_profile_begin */
0x8000, /* rb_profile_end */ 0x8000, /* rb_profile_end */
0, /* pt_mode_global */ 0, /* pt_mode_global */
@ -112,6 +114,7 @@ static const oceanic_common_layout_t aeris_500ai_layout = {
0x0200, /* rb_logbook_begin */ 0x0200, /* rb_logbook_begin */
0x0200, /* rb_logbook_end */ 0x0200, /* rb_logbook_end */
8, /* rb_logbook_entry_size */ 8, /* rb_logbook_entry_size */
1, /* rb_logbook_direction */
0x00200, /* rb_profile_begin */ 0x00200, /* rb_profile_begin */
0x20000, /* rb_profile_end */ 0x20000, /* rb_profile_end */
0, /* pt_mode_global */ 0, /* pt_mode_global */