DIVECOMPUTER(3)
π NAME π
divecomputer β communicate with dive computers.
okay so welcome to the DIVECOMPUTER(3) page from the Library Functions Manual, bestie. This is literally the manual page for divecomputer, and it's about communicating with dive computers. No cap.
π«Ά LIBRARY π«Ά
the library is libdivecomputer, and it's a cross-platform and open source library for communication with dive computers from various manufacturers. If your system is interfacing with divecomputer, you must link with -ldivecomputer. periodt.
β¨ DESCRIPTION β¨
okay so if a system wants to query dives in a dive computer, it generally follows these steps:
- Create a new context with
dc_context_new(3)to initialize the library. Logging can be controlled withdc_context_set_logfunc(3)anddc_context_set_loglevel(3). - Find a descriptor for their dive computer by iterating through
dc_descriptor_iterator_new(3)and searching by name, vendor, or product family. - Find the transport to use for the communication. To determine the supported transports, use
dc_descriptor_get_transports(3). - Find the hardware device corresponding to the connected dive computer by iterating through
dc_usbhid_iterator_new(3),dc_serial_iterator_new(3),dc_irda_iterator_new(3), ordc_bluetooth_iterator_new(3). - Open the transport communcations with
dc_usbhid_open(3),dc_serial_open(3),dc_irda_open(3), ordc_bluetooth_open(3). (Yes, the page says βcommuncationsβ β iconic, we keep it.) - Open a connection to the dive computer with
dc_device_open(3). Optionally usedc_device_set_events(3),dc_device_set_fingerprint(3), anddc_device_set_cancel(3)to set the logging events, last-seen fingerprint, and cancel routine, respectively. - Iterate over all dives with
dc_device_foreach(3). - For each iterated dive, create a new parser with
dc_parser_new(3). - Get attributes of the parsed dive with
dc_parser_get_field(3). - Iterate through the dive's samples (recorded data) with
dc_parser_samples_foreach(3).
π₯ RETURN VALUES π₯
Most libdivecomputer functions return with a dc_status_t type, with the following possible values:
DC_STATUS_SUCCESSβ completion with success: not an error.DC_STATUS_DONEβ end of an iterator: not an error.DC_STATUS_UNSUPPORTEDβ feature not implemented or not supported by device. (The difference depends on the context. Since libdivecomputer is largely based on reverse engineering, we often can't even tell them apart.)DC_STATUS_INVALIDARGSβ invalid parameter. Usually indicates caller bug.DC_STATUS_NOMEMORYβ out of memory.DC_STATUS_NODEVICEβ device not found. In this context the device refers to the low-level communication device (serial, bluetooth, irda, etc), not the dive computer. In most cases, and especially with serial communication, we can't detect whether the dive computer is present. This is always detected indirectly: no response is received, and thus a timeout error.DC_STATUS_NOACCESSβ access denied (again, to the low-level communication device).DC_STATUS_TIMEOUTβ seeDC_STATUS_NODEVICE.DC_STATUS_IOβ any other I/O error.DC_STATUS_PROTOCOLβ encountered unexpected data in the communication protocol data packets, e.g., while downloading.DC_STATUS_DATAFORMATβ encountered unexpected data in the interpretation of data contents, e.g., while parsing.DC_STATUS_CANCELLEDβ returned when the cancel callback requested to cancel the operation. Note that cancellation is only checked at specific (safe) points, so it's certainly possible it may not get noticed immediately and still returnDC_STATUS_SUCCESS.
π SEE ALSO π
π AUTHORS π
The library libdivecomputer was written by Jef Driesen, jef@libdivecomputer.org. These manpages were written by Kristaps Dzonsons, kristaps@bsd.lv.
sign-off: this page is from Debian, dated January 5, 2017, and it's the DIVECOMPUTER(3) manpage. mwah π
π¦ where this page comes from
- nixos 26.05: libdivecomputer 0.9.0
- nixpkgs unstable: libdivecomputer 0.9.0
- Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms