Commit graph

153 commits

Author SHA1 Message Date
Miika Turkia
6953824bd6 CSV import: add support for DC hw info
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-27 06:34:43 -07:00
Miika Turkia
3ef5dbaacb Add hw info to Seabear import
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-27 06:34:18 -07:00
Miika Turkia
fed9aa8086 Include debug printout for easier manual testing
When Subsurface is run with high enough verbosity level, generate
command line to test Seabear import manually with xsltproc.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-22 11:54:12 -07:00
Miika Turkia
2192443a1e Fix Seabear CSV import
It seems that adding parameters to the Seabear import has resulted in
the parameters to be missed. And this led to parsing error / recursion.
This patch tries to tackle the problem by introducing dynamic parameter
counter to the mix.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-22 11:51:31 -07:00
Miika Turkia
d1d12ad1db Clean up some parameters on CSV import
We do not really need the buffers when doing CSV import. Instead we use
dynamic memory allocation for the values. Note that Seeabear part is not
tested as it that import is not working for me anymore.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-22 11:22:33 -07:00
Miika Turkia
b98396e10f Fix Seabear import if line ends with NL
We need to start second search from the start of the buffer if \r\n
search returns nothing.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-22 11:21:59 -07:00
Miika Turkia
2d2d890ac7 Increase the recursion for Seabear CSV import
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-22 11:21:02 -07:00
Miika Turkia
b28517b9b0 Add setpoint support for CSV import
The import of setpoint values is tested with Seabear data.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-21 07:34:24 -07:00
Miika Turkia
e98cbdf020 Divinglog import: basic dive info for DB import
This parses the basic metadata of a dive when importing Divinglog
database. (Discarding deleted dives is my best guess as I do not have
that in my sample dive.)

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-12 13:58:16 -07:00
Miika Turkia
b4d5f6fd53 Divinglog import: hook up processing of .sql files
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-12 13:58:16 -07:00
Dirk Hohndel
08a451d24a More debug message cleanup
Remove several very noise messages on dive site handling (this seems to
work well now, so I think we can remove most of them - a couple were left
that indicate actual issues).

And also remove all the calls to "translate" when outputting data to
stderr. Error messages that indicate issues where the user will basically
have to come and ask the developers for help shouldn't be localized. They
should be in English to make it easier for us to figure out what's going
on.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-02 11:22:22 -07:00
Anton Lundin
4867363ec5 Move model tagging to xslt
Instead of replacing all the empty model tags after a csv to xml
transform with some text, just produce that text in the csv to xml
transform instead.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-27 14:43:04 -07:00
Anton Lundin
f04b3bc166 Add support for importing O2 sensors from CSV file
This adds support for importing individual O2 sensors from a CSV file,
e.g. an APD log viewer file.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-27 14:42:05 -07:00
Dirk Hohndel
66375689b8 Prevent null dereference
In each case there are scenarios where we would have dereferenced NULL.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-21 21:53:53 -07:00
Dirk Hohndel
f5726c3d18 Fix a number of resource leaks
Free memory returned from parse_mkvi_value()
Free memory returned from printGPSCoords()
Free memory allocated in added_list and removed_list
Free memory allocated when adding suffix to dive site name
Free memory allocated in cache_deco_state()
Free memory allocated in build_filename()
Free memory allocated in get_utf8()
Free memory allocated in alloc_dive()
Free memory allocated as cache but never used

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-21 21:13:32 -07:00
Dirk Hohndel
ccc9d80015 Remove all the no longer necessary code that aborts read of first V2 file
This was a poorly implemented hack when we executed the reverse geo lookup
in the main thread and opening a V2 file could take a very long time. We
need to do the "Welcome" message quite differently.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-16 14:41:56 -07:00
Dirk Hohndel
a2c546152e Don't crash with NULL string in settings
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-16 09:33:22 -07:00
Dirk Hohndel
c593dea119 Cloud storage: use preference member instead of hard coded strings
This creates the basis to allow other backends to be used with the cloud
storage infrastructure.

So far this should all just transparently continue to work. A user would
have to manually add the cloud_base_url entry to the CloudStorage section
in their config file in order to use a different backend server.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-15 10:22:00 -07:00
Dirk Hohndel
3d62f89bce Cloud storage: Remove another git related message
Once we failed to load data from cloud storage (for example the first time
we try to use it when the remote repository is empty), don't show git
related errors to the user. It's enough to tell them that the cloud
storage is empty.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-13 13:16:08 -07:00
Dirk Hohndel
df255e2573 Don't show an error if you fail to open the cloud storage
The lower level functions will already report that things didn't connect
successfully, no reason to repeat it here (which then exposes the git
URL).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-13 09:14:48 -07:00
Dirk Hohndel
9a22efb97b Move git related declarations into their own header file
Also change the name of the enum and make sure all the inner functions get
passed the remote transport information.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-13 09:14:48 -07:00
Dirk Hohndel
e21cae2d46 Cloud storage: sync the remote after save
This change once again tests if the remote can be reached. Even with a
fairly big data file and a medium speed internet connection the remote
sync is fast enough to call it nearly instantaneous. Maybe a couple of
seconds.

We may need more checks / different heuristics / warnings if the sync
didn't happen, etc. But for now this should allow more reasonable testing.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-12 13:56:23 -07:00
Miika Turkia
c80d1879b7 Add suit field for CSV import
Fixes #853

[Dirk Hohndel: fixed test compile]

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-04-24 06:50:50 -07:00
Dirk Hohndel
959077c66b Remove debug output about verbosity
This snuck in on commit f4f791ffbd ("Add verbose debug output to
parse_manual_file").

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-04-22 11:18:00 -07:00
Salvador Cuñat
3ca4e14d5c OSTCTools-Add support to import .dive files
OSTCTools is a windows based software by Robert Angeymar which performs
configuration upgrade, memory analysis and download tasks for H&W OSTC
devices.

Downloaded dives are stored in files (one archive each) with the raw
binary data heavily padded at the begining of the file, and some other
data not included in H&W dive header protocol as the device's serial
number.

The import function simply takes the raw data part of the file and lets
libdivecomputer do the parseing.

Then adds some additional info as OSTC reported dive number and serial
device number.

Please note that OSTCTools is *not* a real logging software, it simply
gets the DC raw data, so there isn't any information about dive site,
equipment and so.

Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-04-04 10:33:49 -07:00
Salvador Cuñat
ed6ae14a9f Move extern declaration to header file
Move extern declaration of function datatrak_import() to file.h, where it
fits better than in file.c

Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-04-04 10:33:11 -07:00
Miika Turkia
03fc9e3c26 Fix a bug in detecting CSV file content
NL should be set only if there is an empty line in the input file. That
way the return if no empty line exists (simplistic test for Seabear CSV
file) makes more sense.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-03-30 12:55:36 -07:00
Miika Turkia
86ac7fdf47 Import support for new Seabear format
This add support for Seabear's new import format that is used by H3 and
T1. In the future also the Hudc  should switch to the new format. The
main difference to the old one is that time stamps are no longer
recorded in the samples, but intervali is specified in the header.

The header contains other useful information as well that we should
build support for. E.g. surface pressure, gas mixes, GF, and mode might
be useful additions later on.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-03-23 05:44:06 -07:00
Miika Turkia
cb49c37b31 Fix Seabear new line detection
We need to take both \r\n and \n new line formats into account before
failing Seabear validity check on import. (Seabear file has empty lines,
if import file does not have one -> return.)

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-03-23 05:43:52 -07:00
Marcos CARDINOT
384b9dd09b File.c - Missing break in switch
Simple control flow issue. Missing break in switch.

Signed-off-by: Marcos CARDINOT <mcardinot@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-03-23 05:38:17 -07:00
Dirk Hohndel
f4f791ffbd Add verbose debug output to parse_manual_file
This way it's easier to figure out which arguments to use when creating
tests.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-03-14 18:08:26 -07:00
Dirk Hohndel
9b2c1df8e6 Temporary fix to allow importing of CSV files
In commit 0ed4356fc2 ("Display slowness warning before opening a V2
file") I changed the xml parser to abort if it detects an V2 XML file so
that the main application can show a warning message (and eventually, a
few choices for the user) before parsing and processing older XML files.

The input that gets pre-processed by XSLT files claims to be V2 XML and so
the parser aborts - yet the code to show a warning and restarting the
parse isn't present in this code path, so XSLT based imports always fail.

This hack works around this by temprarily setting the variable that claims
that the warning has been shown to the user.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-03-14 16:24:24 -07:00
Lubomir I. Ivanov
2a1a868db2 datatrak: some codings style fixes and fopen() usage
- subsurface_fopen() is needed
- translated one puts("") message
- sizeof(unsigned char | char) is always 1
- pointer symbol (*) location
- padding fixes
- braces fixes

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-03-11 07:38:22 -07:00
Salvador Cuñat
44b55bd1a2 Import Datatrak/WLog files
Sequentially parses a file, expected to be a Datatrak/WLog divelog, and
converts the dive info into Subsurface's dive structure.

As my first DC, back in 90s, was an Aladin Air X, the obvious choice of log
software was DTrak (Win version). After using it for some time we moved to WLog
(shareware software more user friendly than Dtrak, printing capable, and still
better, it runs under wine, which, as linux user, was definitive for me). Then,
some years later, my last Aladin died and I moved to an OSTC, forcing me to
look for a software that support this DC.
I found JDivelog which was capable of import Dtrak logs and used it for some
time until discovered Subsurface existence and devoted to it.

The fact was that importing Dtrak dives in JDivelog and then re-importing them
in Subsurface caused a significant data loss (mainly in the profile events and
alarms) and weird location of some other info in the dive notes (mostly tag
items in the original Dtrak software). This situation can't actually be solved
with tools like divelogs.de which causes similar if no greater data loss.

Although this won't be a core feature for Subsurface, I expect it can be useful
for some other divers as has been for me.

Comments and issues:

Datatrak/Wlog files include a lot of diving data which are not directly
supported in Subsurface, in these cases we choose mostly to use "tags".

The lack of some important info in Datatrak archives (e.g. tank's initial
pressure) forces us to do some arbitrary assumptions (e.g. initial pressure =
200 bar).

There might be archives coming directly from old DOS days, as first versions
of Datatrak run on that OS; they were coded CP437 or CP850, while dive logs
coming from Win versions seems to be coded CP1252. Finally, Wlog seems to use a
mixed confusing style. Program directly converts some of the old encoded chars
to iso8859 but is expected there be some issues with non alphabetic chars, e.g.
"ª".

There are two text fields: "Other activities" and "Dive notes", both limited to
256 char size. We have merged them in Subsurface's "Dive Notes" although the
first one could be "tagged", but we're unsure that the user had filled it in
a tag friendly way.

WLog adds some information to the dive and lets the user to write more than
256 chars notes. This is achieved, while keeping compatibility with DTrak
divelogs, by adding a complementary file named equally as the .log file and
with .add extension where all this info is stored.  We have, still, not worked
with this complementary files.

This work is based on the paper referenced in butracker #194 which has some
errors (e.g. beginning of log and beginning of dive are changed) and a lot of
bytes of unknown meaning. Example.log shows, at least, one more byte than those
referred in the paper for the O2 Aladin computer, this could be a byte referred
to the use of SCR but the lack of an OC dive with O2 computer makes impossible
for us to compare.

The only way we have figured out to distinguish a priori between SCR and non
SCR dives with O2 computers is that the dives are tagged with a "rebreather"
tag. Obviously this is not a very trusty way of doing things. In SCR dives,
the O2% in mix means, probably, the maximum O2% in the circuit, not the O2%
of the EAN mix in the tanks, which would be unknown in this case.

The list of DCs related in bug #194 paper seems incomplete, we have added
one or two from WLog and discarded those which are known to exist but whose
model is unknown, grouping them under the imaginative name of "unknown". The
list can easily be increased in the future if we ever know the models
identifiers.
BTW, in Example.log, 0x00 identifier is used for some DC dives and from my own
divelogs is inferred that 0x00 is used for manually entered dives, this could
easily be an error in Example.log coming from a preproduction DC model.

Example.log which is shipped in datatrak package is included in dives
directory for testing pourposes.

[Dirk Hohndel: some small cleanups, merged with latest master, support
               divesites, remove the pointless memset() before free() calls
	       add to cmake build]

Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-03-10 10:03:08 -07:00
Dirk Hohndel
74fad4a7ce xsltMaxVars was only introduced in libxslt 1.1.27
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-17 22:00:26 -08:00
Miika Turkia
f39962469d Increase the limits for recursion and variables on XSLT parsing
This increases the limits when parsing CSV files with dive profiles,
allowing us to import bigger files in one go.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-10 15:03:28 -08:00
Miika Turkia
2dc1a42b29 Fix crash if one selects incorrectly Seabear CSV
Fixes #814

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-01 07:06:12 -08:00
Miika Turkia
29c6d03dfa Fix a bug if CSV file does not have ending new line
Add a new line when importing a CSV file, so we get the last dive
imported as well (in case file ends without last new line).

See #814

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-24 14:49:45 -08:00
Dirk Hohndel
cbab6cc9c8 When importing dives from CSV, mark them accordingly
The dive computer model string should indicate that these were imported
from CSV.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-22 06:54:03 +12:00
Robert C. Helling
e219bc70f8 Refactor dctype -> divemode
... and repair a failed rebase (sorry).

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-10 17:27:25 -08:00
Anton Lundin
c8c29ac8cf Adjust array size to fit all csv params
Back in e544796199 ("Add missing divemaster field to the manual
import"), divemaster field got added without extending the array length.
This corrects that.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-08 14:04:44 -08:00
Dirk Hohndel
e544796199 Add missing divemaster field to the manual import
No idea why I didn't notice earlier that this was missing.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-06 20:19:45 -08:00
Miika Turkia
48b88f6aca Do not add uninitialized setpoint or ndl
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-04 23:11:03 -08:00
Miika Turkia
65ee482adb Add duration format to XSLT call
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-31 08:35:30 -08:00
Miika Turkia
ce1f69f025 Initial support for Divesoft Freedom
This parses the dive profile from Divesoft Freedom log file. Only the
depth profile is currently supported. There is also something wrong as
the log file cannot be given as parameter but must be opened or imported
once Subsurface is running. Note that so far no metadata is parsed.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-28 06:41:21 -08:00
Miika Turkia
071cea15c0 Glue between GUI and XSLT for additions in CSV import
This code sets the parameters properly to support the new fields in
manual CSV import.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-20 11:30:52 -08:00
Miika Turkia
3be4aa47b5 Bare implementation of Cobalt Divelog Program
This implements importing of dive profile and temperature graph along
with some meta data from a Cobalt Divelog database.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-20 11:28:57 -08:00
Anton Lundin
e6c587ad62 Remove debug printf
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-13 13:36:08 -08:00
Dirk Hohndel
b92a10ea98 Mark new string for translation
This needs to be the same string as used for the entry in the Import
dialog... since translate() is a macro in this .c file and defined to have
only two arguments, I'm using the NOOP3 macro to get this correctly added
to the translation sources, including the comment. That makes the code a
little odd, but seems to work.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-08 14:30:08 -07:00
Dirk Hohndel
d9be07670c Don't ignore when we can't parse a file
We are quite inconsistent when it comes to reporting back errors.
One case where this caused somewhat unexpected behavior was when the
user would try to open a .csv file by passing it as command line
argument. The file was silently ignored, but treated as if it had been
opened successfully.

Now we issue a somewhat reasonable error message.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-08 11:28:23 -08:00