Signed-off-by: Anton Lundin glance@acc.umu.se --- src/hw_ostc_parser.c | 9 +++++++++ 1 file changed, 9 insertions(+)
diff --git a/src/hw_ostc_parser.c b/src/hw_ostc_parser.c index a3ee279..800dac4 100644 --- a/src/hw_ostc_parser.c +++ b/src/hw_ostc_parser.c @@ -75,6 +75,7 @@ typedef struct hw_ostc_sample_info_t { typedef struct hw_ostc_layout_t { unsigned int datetime; unsigned int maxdepth; + unsigned int avgdepth; unsigned int divetime; unsigned int atmospheric; unsigned int salinity; @@ -108,6 +109,7 @@ static const dc_parser_vtable_t hw_ostc_parser_vtable = { static const hw_ostc_layout_t hw_ostc_layout_ostc = { 3, /* datetime */ 8, /* maxdepth */ + 45, /* avgdepth */ 10, /* divetime */ 15, /* atmospheric */ 43, /* salinity */ @@ -121,6 +123,7 @@ static const hw_ostc_layout_t hw_ostc_layout_ostc = { static const hw_ostc_layout_t hw_ostc_layout_frog = { 9, /* datetime */ 14, /* maxdepth */ + UNSUPPORTED, /* avgdepth */ 16, /* divetime */ 21, /* atmospheric */ 43, /* salinity */ @@ -134,6 +137,7 @@ static const hw_ostc_layout_t hw_ostc_layout_frog = { static const hw_ostc_layout_t hw_ostc_layout_ostc3 = { 12, /* datetime */ 17, /* maxdepth */ + 73, /* avgdepth */ 19, /* divetime */ 24, /* atmospheric */ 70, /* salinity */ @@ -329,6 +333,11 @@ hw_ostc_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsigned case DC_FIELD_MAXDEPTH: *((double *) value) = array_uint16_le (data + layout->maxdepth) / 100.0; break; + case DC_FIELD_AVGDEPTH: + if (version == 0x22) + return DC_STATUS_UNSUPPORTED; + *((double *) value) = array_uint16_le (data + layout->avgdepth) / 100.0; + break; case DC_FIELD_GASMIX_COUNT: if (version == 0x22) { *((unsigned int *) value) = 3;
On 2015-01-21 08:38, Anton Lundin wrote:
static const hw_ostc_layout_t hw_ostc_layout_ostc = { 3, /* datetime */ 8, /* maxdepth */
- 45, /* avgdepth */ 10, /* divetime */ 15, /* atmospheric */ 43, /* salinity */
@@ -121,6 +123,7 @@ static const hw_ostc_layout_t hw_ostc_layout_ostc = { static const hw_ostc_layout_t hw_ostc_layout_frog = { 9, /* datetime */ 14, /* maxdepth */
- UNSUPPORTED, /* avgdepth */ 16, /* divetime */ 21, /* atmospheric */ 43, /* salinity */
This fails to compile because UNSUPPORTED isn't defined. According to the frog documentation the average depth is stored at offset 45, just like the ostc.
case DC_FIELD_AVGDEPTH:
if (version == 0x22)
return DC_STATUS_UNSUPPORTED;
*((double *) value) = array_uint16_le (data + layout->avgdepth) /
100.0;
break;
With the above info, you no longer need to special case the frog here.
PS: The average depth field is not implemented for any backend. I added the field because I thought it made sense at that time. But most applications seem to prefer to calculate avg depth from the profile (which has the advantage of being able to take into account preferences like ignore shallow samples, etc), so I just never bothered to implement this.
Jef
On 21 January, 2015 - Jef Driesen wrote:
On 2015-01-21 08:38, Anton Lundin wrote:
static const hw_ostc_layout_t hw_ostc_layout_ostc = { 3, /* datetime */ 8, /* maxdepth */
- 45, /* avgdepth */ 10, /* divetime */ 15, /* atmospheric */ 43, /* salinity */
@@ -121,6 +123,7 @@ static const hw_ostc_layout_t hw_ostc_layout_ostc = { static const hw_ostc_layout_t hw_ostc_layout_frog = { 9, /* datetime */ 14, /* maxdepth */
- UNSUPPORTED, /* avgdepth */ 16, /* divetime */ 21, /* atmospheric */ 43, /* salinity */
This fails to compile because UNSUPPORTED isn't defined. According to the frog documentation the average depth is stored at offset 45, just like the ostc.
Ah, thats because the UNSUPPORTED flag only exists in the subsurface branches, and if its at offset 45 it can easily be fixed.
Btw. From where have you gotten any frog documentation? Have you gotten it straight from HW? As far as i know, none have bin published, at least not on bitbucket where i've found the OSTC{2,3} documentation.
case DC_FIELD_AVGDEPTH:
if (version == 0x22)
return DC_STATUS_UNSUPPORTED;
*((double *) value) = array_uint16_le (data + layout->avgdepth) /
100.0;
break;
With the above info, you no longer need to special case the frog here.
PS: The average depth field is not implemented for any backend. I added the field because I thought it made sense at that time. But most applications seem to prefer to calculate avg depth from the profile (which has the advantage of being able to take into account preferences like ignore shallow samples, etc), so I just never bothered to implement this.
Yea, i saw the field when i dug around in the OSTC{2,3} documentation to try to figure out other things, so i thought id implement it.
When i check, the eonsteel backed actually implements it.
Maybe it should raise some deprecation warning in dc_parser_get_field?
//Anton
On 2015-01-21 09:59, Anton Lundin wrote:
On 21 January, 2015 - Jef Driesen wrote:
On 2015-01-21 08:38, Anton Lundin wrote:
static const hw_ostc_layout_t hw_ostc_layout_ostc = { 3, /* datetime */ 8, /* maxdepth */
- 45, /* avgdepth */ 10, /* divetime */ 15, /* atmospheric */ 43, /* salinity */
@@ -121,6 +123,7 @@ static const hw_ostc_layout_t hw_ostc_layout_ostc = { static const hw_ostc_layout_t hw_ostc_layout_frog = { 9, /* datetime */ 14, /* maxdepth */
- UNSUPPORTED, /* avgdepth */ 16, /* divetime */ 21, /* atmospheric */ 43, /* salinity */
This fails to compile because UNSUPPORTED isn't defined. According to the frog documentation the average depth is stored at offset 45, just like the ostc.
Ah, thats because the UNSUPPORTED flag only exists in the subsurface branches, and if its at offset 45 it can easily be fixed.
Btw. From where have you gotten any frog documentation? Have you gotten it straight from HW? As far as i know, none have bin published, at least not on bitbucket where i've found the OSTC{2,3} documentation.
Yes, I got the documentation from HW. As far as I know it has never been published.
PS: The average depth field is not implemented for any backend. I added the field because I thought it made sense at that time. But most applications seem to prefer to calculate avg depth from the profile (which has the advantage of being able to take into account preferences like ignore shallow samples, etc), so I just never bothered to implement this.
Yea, i saw the field when i dug around in the OSTC{2,3} documentation to try to figure out other things, so i thought id implement it.
When i check, the eonsteel backed actually implements it.
Maybe it should raise some deprecation warning in dc_parser_get_field?
Well, I'm not really sure whether we should deprecate it or not. It might still be useful for someone. I just mentioned this in case you were wondering why it's not implemented in any other backend (with the exception of the eonsteel) :-)
Jef