608 Commits

Author SHA1 Message Date
Jef Driesen
0f6d23757f Add a new library context object.
With the introduction of a context object, library initialization and
shutdown can be performed without requiring any global state. A single
process can use multiple independent contexts without any problems. The
lack of a global state also improves the thread-safety of the library.

At the moment, the new context object is primary used to implement an
improved logging system.
2012-08-27 23:02:44 +02:00
Jef Driesen
3df5cb09d7 Require a serial handle for the sleep function. 2012-08-27 23:02:44 +02:00
Jef Driesen
c5105a3788 Remove the IrDA init and cleanup functions.
The Windows WSAStartup() and WSACleanup() functions are now called
automatically when opening and closing IrDA sockets. This causes no
problems because these functions are reference counted and can be called
multiple times.

In practice nothing changes because the Uwatec Smart backend already
called these functions for every connection.
2012-08-27 23:02:44 +02:00
Jef Driesen
83f742080b Remove some unnecessary helper functions. 2012-08-27 23:02:44 +02:00
Jef Driesen
2a72da59ad Don't ignore errors in the ascii/binary conversions.
Instead of silently ignoring errors and logging a warning, the
conversion functions now return an error code that can be checked by the
caller.
2012-08-27 23:02:44 +02:00
Jef Driesen
4296f974d0 Don't include unnecessary header files.
Due to the use of the convenience functions, the device specific header
files are no longer necessary, and can be replaced with the high-level
header files.
2012-08-27 23:02:44 +02:00
Jef Driesen
2095a2d10e Merge branch 'release-0.1'
Integrate the bugfixes from the stable branch.
2012-08-27 22:58:52 +02:00
Jef Driesen
6242978fc0 Add support for the Aeris Manta.
The last memory page is marked as unreadable, and the profile ringbuffer
end is set to 0xFE00.
2012-08-15 07:18:12 +02:00
Jef Driesen
58d0e0a62a Fix the libusb timeout handling.
A bulk transfer of more than 8K of data takes about one second with the
Cobalt. Because we use a one second timeout combined with a 10K buffer,
such a transfer can easily exceed the timeout. Normally this shouldn't
be a problem because the leftover data is supposed to be received with
the next transfer. However to break out of the loop we check the actual
number of bytes received, and ignore the libusb LIBUSB_ERROR_TIMEOUT
return code.

To fix this problem, the internal buffer is reduced to 8K, and the
timeout is increased to 2 seconds. This should avoid hitting the timeout
and allows to consider LIBUSB_ERROR_TIMEOUT a fatal error.
2012-08-11 23:08:24 +02:00
Pascal Manchon
0e1809aac9 Fix some ioctl calls on 64bit Mac OS X.
On Mac OS X (and probably the other BSD's too), the ioctl() syscall
takes an 'unsigned long' integer as the request parameter. On 64bit
systems this is a 64bit type, while on 32bit systems it's a 32bit type.

Some of the request constants are defined as 32 bit negative numbers.
Casting it to a 64bit value will perform a sign extension operation to
preserve the negative value. Because this results in a different request
code when interpreted as an unsigned integer, the ioctl() call fails
with ENOTTY. For example TIOCMBIS is defined as 0x8004746c and becomes
0xffffffff8004746 after the sign extension.

Linux 64bit is unaffected by this problem. None of the request constants
has the sign bit set, and thus the sign extension has no effect. For
example TIOCMBIS is defined as 0x5416.

By using an unsigned integer type, the sign extension can be avoided. We
use the 'unsigned long' type in case one of the request constants
happens to be defined as a 64bit number.
2012-07-08 13:42:13 +02:00
Grischa Toedt
2f4a9abf88 Fix a build error with automake 1.12 or newer.
Since automake 1.12, the warnings in the category 'extra-portability'
are now enabled by '-Wall'. Because of this change, linking libtool
archives requires the new AM_PROG_AR macro.
2012-07-07 22:54:42 +02:00
Jef Driesen
6423edffc8 Fix the profile ringbuffer end.
The profile ringbuffer is smaller than expected. The purpose of the
extra area after the profile ringbuffer is currently unknown.
2012-06-21 21:59:07 +02:00
Jef Driesen
4bc477baa2 Update the examples to use the new convenience functions. 2012-06-21 21:42:37 +02:00
Jef Driesen
6922838695 Add a dc_parser_new convenience function.
The devinfo and clock event data is now cached internally at the device layer.
This allows the new dc_parser_new() convenience function to retrieve the event
data directly from the device handle, and applications don't have to deal with
the events anymore to create a parser.
2012-06-21 21:42:37 +02:00
Jef Driesen
df9897fb3c Add a dc_device_open convenience function.
With the introduction of the device descriptors, the new dc_device_open()
convenience function can take care of the mapping from a particular model to
the corresponding backend internally, without needing any device specific
knowledge in the application. An application can simply query the list of
supported devices, and the library will automatically do the right thing.
2012-06-21 21:42:37 +02:00
Jef Driesen
79eade6e06 Add the device enumeration support.
Applications can now enumerate all the supported devices at runtime,
and don't have to maintain their own list anymore. The internal list
does include only those devices that have been confirmed to work at
least once without any major problems.
2012-06-21 21:42:37 +02:00
Jef Driesen
a78cf2f939 Add a new device descriptor object.
As the name already indicates, a device descriptor is lightweight
object which describes a single device. Currently, the api supports
getting the device name (vendor and product) and model number. But
this can extended with other features when necessary.
2012-06-21 21:42:37 +02:00
Jef Driesen
fbe712fc8f Add a generic iterator interface. 2012-06-21 21:42:37 +02:00
Jef Driesen
c821d40144 Introduce a namespace prefix for the high-level public api.
Adding the "dc_" namespace prefix (which is of course an abbreviation
for libdivecomputer) should avoid conflicts with other libraries. For
the time being, only the high-level device and parser layers are
changed.
2012-06-21 21:42:37 +02:00
Jef Driesen
163d383332 Use a common backend type for the device and parser layers. 2012-06-21 21:42:37 +02:00
Jef Driesen
9136a52835 Use common status codes for the device and parser layers. 2012-06-21 21:42:34 +02:00
Jef Driesen
e65025b501 Separate private and public headers.
The public header files are moved to a new subdirectory, to separate
the definition of the public interface from the actual implementation.
Using an identical directory layout as the final installation has the
advantage that the example code can be build outside the project tree
without any modifications to the #include statements.
2012-06-21 21:39:24 +02:00
Jef Driesen
80f5c7025e Fix the detection of the last dive.
It looks like the Icon HD erases old dives partially with 0xFF bytes
before overwriting them with new dives. If the head of the oldest dive
has been erased, the length field which is stored in the first 4 bytes
is erased as well, and we can use it to detect the last dive.
2012-06-19 23:00:30 +02:00
Jef Driesen
9c59563d4c Add support for eeprom bank number 2.
Devices with firmware version 2.22 (or greater) have an additional
eeprom bank with new custom functions.
2012-06-19 21:28:43 +02:00
Jef Driesen
fa54a55a89 Add a version suffix.
For development snapshots, a 'devel' suffix is added to distinguish from
the final release. If necessary, the suffix can also be used for 'alpha'
and 'beta' releases.
2012-06-19 21:27:46 +02:00
Jef Driesen
53b4a1c225 Post release version bump to 0.1.1 2012-06-03 22:13:38 +02:00
Jef Driesen
52d8f08281 Enable the model hint to speedup the autodetection. 2012-05-23 21:45:46 +02:00
Jef Driesen
781f0db71f Add support for the Heinrichs Weikamp Frog. 2012-04-28 11:18:16 +02:00
Jef Driesen
bb87198622 Add a version suffix.
For development snapshots, a 'devel' suffix is added to distinguish from
the final release. If necessary, the suffix can also be used for 'alpha'
and 'beta' releases.
2012-04-27 23:56:20 +02:00
Jef Driesen
631f2d4a3d Post release version bump to 0.2.0 2012-04-27 23:50:41 +02:00
Jef Driesen
c3ea5a16e4 Release version 0.1.0 v0.1.0 2012-04-27 23:33:57 +02:00
Jef Driesen
b567f0774c Add a README file. 2012-04-27 23:28:42 +02:00
Jef Driesen
ec6795cbf3 Fix the Oceanic Veo 1.0 layout descriptor. 2012-04-24 19:31:39 +02:00
Jef Driesen
94b4ee368a Add partial support for the Oceanic Veo 1.0
The Veo 1.0 has very limited memory and doesn't have a logbook and
profile ringbuffer. Hence downloading dives isn't really supported, but
even this limited amount of data might be useful for someone.
2012-04-23 22:04:23 +02:00
Jef Driesen
0a6e0d93a8 Add support for the Aeris F10. 2012-04-23 21:37:02 +02:00
Jef Driesen
5ae0e37d1f Remove the hardcoded logbook entry size. 2012-04-23 21:37:02 +02:00
Jef Driesen
1faea84b5b Fix the gas mix parsing for the Oceanic VT 4.x. 2012-04-23 21:37:02 +02:00
Jef Driesen
2fe695d38e Adjust the header size calculations. 2012-04-23 21:37:01 +02:00
Jef Driesen
414a8053d5 Allow easier disabling of the tank switch and surface samples. 2012-04-23 21:37:01 +02:00
Jef Driesen
2897d1079a Allow easier disabling of the individual sample types. 2012-04-23 21:36:52 +02:00
Jef Driesen
6c2014732a Fix the gas mix parsing for the Aeris CompuMask. 2012-04-22 22:33:52 +02:00
Jef Driesen
5126ef389a Add support for the Oceanic Atom 3.1 2012-04-15 09:45:31 +02:00
Jef Driesen
a5f8c8cfff Add a small delay before flushing the serial line.
Sometimes there are a few garbages bytes received before the preamble
bytes. This typically happens when trying to download again after a
failed attempt. However trying to flush them immediately after opening
the serial port doesn't work.
2012-04-14 07:48:13 +02:00
Jef Driesen
8cec4d0a42 Increase the read timeout to 4 seconds.
When the OSTC receives the download dives command, it responds
immediately with the preamble bytes. But then it does a linear search
through its internal memory to locate the end-of-profile marker. As a
result the response time increases when the marker is located near the
end of the memory area. In the worst case scenario, the response time
can exceed the 3 second read timeout with a few milliseconds.

Since the required timeout depends on the total amount of profile
memory, this problem was indirectly introduced with firmware v1.91,
which doubled the amount of profile memory from 32K to 64K.
2012-04-14 07:46:50 +02:00
Jef Driesen
a2f4f1cd3f Replace the fixed delay with the new half-duplex emulation code. 2012-04-10 21:31:46 +02:00
Jef Driesen
b6d24e72e2 Add support for half-duplex emulation.
When using half-duplex communication (e.g. only a single wire for both
Tx and Rx) a data packet needs to be transmitted entirely before
attempting to switch into receiving mode.

For legacy serial hardware, the tcdrain() probably works as advertised,
and waits until the data has been transmitted. However for common
usb-serial converters, the hardware doesn't provide any feedback to the
driver, and the tcdrain() function can only wait until the data has been
transmitted to the usb-serial chip. There is no guarantee that the data
has actually been transmitted by the usb-serial chip.

As a workaround, we wait at least the minimum amount of time required to
transmit the data packet over a serial line, taking into account the
current configuration.
2012-04-10 21:31:31 +02:00
Jef Driesen
3c07a3017f Integrate the tcdrain() call into the write function. 2012-04-10 21:30:39 +02:00
Jef Driesen
060cc95d5c Substract the dive time from the date/time value.
The OSTC doesn't store the start of the dive, but the exit time. Hence
the dive time needs to be substracted.

For dives with format version 0x21, we prefer the total dive time in
seconds stored in the extended header. This time value also includes the
shallow parts of the dive, and therefore yields the most accurate start
time. The dive time is rounded down towards the nearest minute, to match
the value displayed by the ostc. For dives with the older format version
0x20, this value isn't available and we default to the normal dive time.
2012-04-10 21:21:52 +02:00
Jef Driesen
90a8452788 Add a wrapper for the mktime function. 2012-04-10 21:21:52 +02:00
Jef Driesen
bb4a498302 Fix the freedive mode detection for the Mares Puck Air. 2012-04-10 20:53:38 +02:00