divecmd is a suite of open source command-line UNIX tools to extract and manipulate dives from dive computers. Why use it instead of, say, Subsurface? Because it's built to work in a command-line workflow with other command-line tools for processing, such as grap(1) piped into groff(1) or LaTeX.
My workflow usually begins with dcmd(1) on the day of my dive. First, I extract the dives from my Suunto D6i into an XML file for the day. dcmd(1) keeps track of my last extracted dive, so it will only extract new dives (presumably from the current day):
dcmd d6i > daily.xml
In reality, I usually archive my dives after each day of diving to prevent me from overrunning the computer's internal memory and losing dives.
dcmd d6i > daily-`date +%F`.xml
Following that, I'll analyse my dives by plotting them with dcmd2grap(1) via dcmd2pdf(1). In the case of free diving, for example, I might do this:
dcmd2pdf -m summary daily.xml > daily.summary.pdf
dcmd2pdf -m restscatter daily.xml > daily.restscatter.pdf
These graphs let me see my dive depths and times, and also see whether I'm following the surface-time rule of thumb, where rest is twice the prior dive. Note: if you're free diving and using a dive computer that lumps all free dives into one huge dive without splitting them up by surface time, use dcmdfind(1) to canonicalise the dives. My HW OSTC 2C does this. Or I'll take a sneak peak only at the day's dives on my terminal:
dcmdfind -ldate=today daily.xml | dcmdls
dcmdfind -ldate=today daily.xml | dcmdterm
Want to see a full analysis of these dives in PDF?
dcmdfind -ldate=today daily.xml | dcmd2pdf -a -m all >daily.pdf
To use divecmd, you'll need a reasonably up-to-date UNIX system (OpenBSD, Linux, Mac
OSX, etc.).
You'll also need the excellent libdivecomputer, which does
the heavy lifting to interface with your device.
Just run ./configure
, sudo make install
(or doas
).
printable graphs
The dcmd2grap(1) utility converts from XML into the grap(1) format. Aside: why grap(1)? Because it fits into the standard piped UNIX workflow. I can send the output directly into groff(1) without needing to manage the intermediary files of gnuplot or LaTeX. I use these other tools all of the time, but prefer to avoid them for that reason. See also dcmd2pdf(1), which manages the groff pipeline.
There are a number of graphing modes available to dcmd2grap(1).
In all of them, I use daily.xml, multiday.xml, day1.xml, and/or day2.xml, as input.
The graph names (e.g., aggr
) are used in the -m argument.
terminal graphs
The divecmd suite also has
dcmdterm(1), which formats graphs on a UNIX terminal.
This is useful for a quick peek
at one's dives.
It was the first output mode I wrote, just to test that dcmd(1) was exporting
reasonable data.
dcmdterm(1) doesn't have as many fancy modes as dcmd2grap(1), but it's still a quick and easy way to see one's dives. Especially when setting up a groff(1) pipeline takes too many characters.
other utilities
The arguably most-used output mode is also the simplest: dcmd2json(1), which converts graphs to JSON. I use it constantly for divelog.blue, specifically to show the dive profiles. Technically, I could simply bundle the native dcmd(1) output directly and use an XML-to-JSON formatter in the client, but this is easier.
As much as I use dcmd2grap(1) and friends for my needs, others prefer using tools like Subsurface To do so, one needs to be able to export into a format used by Subsurface. The divecmd suite has dcmd2csv(1), which exports a (for the time being minimal) set of information in CSV format. This can then be imported into Subsurface using the import utility.
If you have lots of dive files and want to consolidate, you can use the dcmdfind(1) utility, which is able to pull together a lot of files, de-duplicate entries, and print them out again. Some dive computers, like the HW OSTC 2c, put all free dives into a single dive sequence. The dcmdedit(1) lets you split those apart for analysis. (You can also merge them back together with the same tool.)
The helpful dcmdls(1) tool accepts a set of files, groups them by dive computer and diver, and lists their contents. This makes browsing through a lot of dives much easier!
For integration with Subsurface, I also provide dcmd2ssrf(1) and ssrf2dcmd(1), which convert into and out of the Subsurface native XML format.