From 8add7917ce9da2faa7751798c3fb15a24715ae1e Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Mon, 18 Jun 2012 16:52:41 -0700 Subject: Add some more cochran data parsing code/comments The code is pretty useless, the comments perhaps equally so. I'm trying to figure out what the data pattern is for the cochran CAN files. There definitely *is* a pattern, but it actually seems to be different for the files of different people - and it's not obvious in any case. There probably are multiple versions of the format, and there might be things like "David has a high-pressure sensor, and Alex does not" going on too. Signed-off-by: Linus Torvalds --- cochran.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) (limited to 'cochran.c') diff --git a/cochran.c b/cochran.c index 360f2eb7c..366e5ea30 100644 --- a/cochran.c +++ b/cochran.c @@ -150,6 +150,64 @@ static void parse_cochran_header(const char *filename, free(buf); } +/* + * Cochran export files show that depths seem to be in + * tenth of feet. + * + * Temperature seems to be exported in Fahrenheit. + * + * Cylinder pressure seems to be in multiples of 4 psi. + * + * The data seems to be some byte-stream where the pattern + * appears to be that the two high bits indicate type of + * data. + * + * For '00', the low six bits seem to be positive + * values with a distribution towards zero, probably depth + * deltas. '0 0' exists, but is very rare ("surface"?). 63 + * exists, but is rare. + * + * For '01', the low six bits seem to be a signed binary value, + * with the most common being 0, and 1 and -1 (63) being the + * next most common values. + * + * NOTE! Don's CAN data is different. It shows the reverse pattern + * for 00 and 01 above: 00 looks like signed data, with 01 looking + * like unsigned data. + * + * For '10', there seems to be another positive value distribution, + * but unlike '00' the value 0 is common, and I see examples of 63 + * too ("overflow"?) and a spike at '7'. + * + * Again, Don's data is different. + * + * The values for '11' seem to be some exception case. Possibly + * overflow handling, possibly warning events. It doesn't have + * any clear distribution: values 0, 1, 16, 33, 35, 48, 51, 55 + * and 63 are common. + * + * For David and Don's data, '01' is the most common, with '00' + * and '10' not uncommon. '11' is two orders of magnitude less + * common. + * + * For Alex, '00' is the most common, with 01 about a third as + * common, and 02 a third of that. 11 is least common. + * + * There clearly are variations in the format here. And Alex has + * a different data offset than Don/David too (see the #ifdef DON). + * Christ. Maybe I've misread the patterns entirely. + */ +static void cochran_profile_write(const unsigned char *buf, int size) +{ + int i; + + for (i = 0; i < size; i++) { + unsigned char c = buf[i]; + printf("%d %d\n", + c >> 6, c & 0x3f); + } +} + static void parse_cochran_dive(const char *filename, int dive, const unsigned char *decode, unsigned mod, const unsigned char *in, unsigned size) @@ -187,6 +245,7 @@ static void parse_cochran_dive(const char *filename, int dive, printf("\n%s, dive %d\n\n", filename, dive); cochran_debug_write(filename, buf, size); + cochran_profile_write(buf + offset, size - offset); free(buf); } -- cgit v1.2.3-70-g09d2 From e5692a77c3f99fe485f6490f567f6cc9cea2adff Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Tue, 19 Jun 2012 12:13:50 -0700 Subject: Update cochran depth precision: it's in 3-inch increments The Cochran CSV depth exports are indeed in tenths of feet, but the decimal is always 0, 3, 5 or 8. Where the 3 and 8 are obviously 0.25 and 0.75 rounded up to one decimal place. So Cochran does seem to be very much about imperial units, with depth and cylinder pressure scaled by four (depth in quarter-foot increments, pressume in 4-psi increments) Signed-off-by: Linus Torvalds --- cochran.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cochran.c') diff --git a/cochran.c b/cochran.c index 366e5ea30..933e1de1f 100644 --- a/cochran.c +++ b/cochran.c @@ -152,7 +152,7 @@ static void parse_cochran_header(const char *filename, /* * Cochran export files show that depths seem to be in - * tenth of feet. + * quarter feet (rounded up to tenths). * * Temperature seems to be exported in Fahrenheit. * -- cgit v1.2.3-70-g09d2