[PATCH] Profile support for multiple concurrent pressure sensors
Linus Torvalds
torvalds at linux-foundation.org
Sun Jul 30 13:27:38 PDT 2017
On Sun, Jul 30, 2017 at 1:23 PM, Robert Helling <helling at atdotde.de> wrote:
> On 30. Jul 2017, at 21:37, Linus Torvalds <torvalds at linux-foundation.org> wrote:
> >
> > The logic for breaking the segment is in
> > populate_pressure_information() in case somebody else ends yup looking
> > at this.
>
> I am looking at this but this stuff is really hard to digest…
Yeah, I agree, and I had a few thinko's there.
Here's the patch that should actually fix things. And now I really
need to run, so I won't have time to check out all the other cases,
but it fixes your thing.
Linus
-------------- next part --------------
core/gaspressures.c | 20 ++++++++++----------
core/profile.c | 4 +++-
2 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/core/gaspressures.c b/core/gaspressures.c
index 13196b61..ce88df04 100644
--- a/core/gaspressures.c
+++ b/core/gaspressures.c
@@ -409,16 +409,6 @@ void populate_pressure_information(struct dive *dive, struct divecomputer *dc, s
current->end = pressure;
}
- // If we have no pressure information, we will need to
- // continue with or without a tracking entry. Mark any
- // existing tracking entry as non-dense, and remember
- // to fill in interpolated data.
- if (!pressure) {
- missing_pr = 1;
- dense = 0;
- continue;
- }
-
// We have a final pressure for 'current'
// If a gas switch has occurred, finish the
// current pressure track entry and continue
@@ -429,6 +419,16 @@ void populate_pressure_information(struct dive *dive, struct divecomputer *dc, s
continue;
}
+ // If we have no pressure information, we will need to
+ // continue with or without a tracking entry. Mark any
+ // existing tracking entry as non-dense, and remember
+ // to fill in interpolated data.
+ if (current && !pressure) {
+ missing_pr = 1;
+ dense = 0;
+ continue;
+ }
+
// If we already have a pressure tracking entry, and
// it has not had any missing samples, just continue
// using it - there's nothing to interpolate yet.
diff --git a/core/profile.c b/core/profile.c
index 7b582741..eccbb561 100644
--- a/core/profile.c
+++ b/core/profile.c
@@ -816,13 +816,15 @@ static void add_plot_pressure(struct plot_info *pi, int time, int cyl, int mbar)
static void setup_gas_sensor_pressure(struct dive *dive, struct divecomputer *dc, struct plot_info *pi)
{
- int prev = -1, i;
+ int prev, i;
struct event *ev;
unsigned int seen[MAX_CYLINDERS] = { 0, };
unsigned int first[MAX_CYLINDERS] = { 0, };
unsigned int last[MAX_CYLINDERS] = { 0, };
struct divecomputer *secondary;
+ prev = explicit_first_cylinder(dive, dc);
+ seen[prev] = 1;
for (i = 0; i < MAX_CYLINDERS; i++)
last[i] = INT_MAX;
More information about the subsurface
mailing list