51 Commits

Author SHA1 Message Date
Florian Klink
fc008312b5 Remove trailing whitespaces
Most of them appear in the disclaimers, but some are in the code as
well.
2014-03-19 09:16:07 +01:00
Jef Driesen
6419e189a4 Add a single isinstance function per object type.
Currently, each backend has it's own function to verify whether the
object vtable pointer is the expected one. All these functions can be
removed in favor of a single isintance function in the base class,
which takes the expected vtable pointer as a parameter.

Functions which are called through the vtable, don't need to verify the
vtable pointer, and those checks are removed.
2013-04-16 12:18:54 +02:00
Jef Driesen
007479fc92 Rename the backend structure to vtable.
The term "backend" can be confusing because it can refer to both the
virtual function table and the device/parser backends. The use of the
term "vtable" avoids this.
2013-04-16 12:18:53 +02:00
Jef Driesen
8fa25ea9f3 Fix the fingerprint offset for the Suunto D4i, D6i and D9tx.
When support for these models was introduced, I fixed the date/time
parsing, but forgot about the fingerprint offset.
2013-02-03 09:03:45 +01:00
Jef Driesen
45e9c08e92 Read the version info when opening the connection.
The d9 backend already reads the version info, to autodetect the
protocol variant. When doing the same in the vyper2 backend, we don't
have to read the version info again when downloading the dives.
2012-12-22 21:58:28 +01:00
Jef Driesen
985323eefb Move the version function to the device specific api.
The version function requires device specific knowledge to use it (at
least the required buffer size), it is already called internally when
necessary, and only a few backends support it. Thus there is no good
reason to keep it in the high-level public api.
2012-12-05 16:07:32 +01:00
Jef Driesen
cd31ff9dff Properly store the context pointer internally.
I forgot to update the device and parser initialization functions to
store the context pointer into the objects. As a result, the internal
context pointers were always NULL.
2012-08-28 08:44:47 +02:00
Jef Driesen
38c7b022cd Integrate the context object in the serial code. 2012-08-27 23:08:38 +02:00
Jef Driesen
53e9d72a40 Integrate the context object in the library.
The public api is changed to require a context object for all
operations. Because other library objects store the context pointer
internally, only the constructor functions need an explicit context
object as a parameter.
2012-08-27 23:08:38 +02:00
Jef Driesen
3df5cb09d7 Require a serial handle for the sleep function. 2012-08-27 23:02:44 +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
a2f4f1cd3f Replace the fixed delay with the new half-duplex emulation code. 2012-04-10 21:31:46 +02:00
Jef Driesen
3c07a3017f Integrate the tcdrain() call into the write function. 2012-04-10 21:30:39 +02:00
Jef Driesen
2a0defe30d Adjust the total amount of memory for the newer Suunto's.
The D9tx, D6i and D4i have twice the amount of memory compared to the
previous versions (64K versus 32K). To support both variants, a new
layout descriptor is introduced.
2011-10-07 22:02:54 +02:00
Jef Driesen
154f767a9c Convert assertions into error codes. 2011-01-08 23:40:15 +01:00
Jef Driesen
887d744e6d Use a more consistent typedef in the serial and irda backends. 2010-10-04 23:08:39 +02:00
Jef Driesen
f6d35fa2c2 Add cancellation support.
To be able to cancel an operation, an application should register a
callback function that returns a non-zero value whenever the active
operaton should be cancelled. A backend can invoke this callback function
to query the application for a pending cancellation request.
2010-02-15 13:16:26 +00:00
Jef Driesen
ce84e85bb6 Do not ignore the return value when writing data. 2010-01-25 19:46:24 +00:00
Jef Driesen
a4247b7505 Define the WARNING macro only once. 2009-08-06 14:15:52 +00:00
Jef Driesen
872f5a594d Add a common base class.
The transfer protocol of the Suunto Vyper 2 and D9 devices is very
similar, which allows to share most of the transfer code between the
backends.
2009-08-06 09:52:50 +00:00
Jef Driesen
a65e9d56c5 Fixed a bug in the write command.
The packet size should include both the number of parameter bytes and
the number of data bytes. The packet verification code is modified to be
able to deal with this change too.
2009-06-12 19:13:43 +00:00
Jef Driesen
be2a27c58b Remove the handshake function from the public api. 2009-04-14 21:37:39 +00:00
Jef Driesen
c1745cc535 Merge the typedef with the struct declaration. 2009-04-06 07:26:16 +00:00
Jef Driesen
20cdb4b188 Resend the command after timeouts and protocol errors. 2009-03-30 19:58:06 +00:00
Jef Driesen
ce705f8244 Use the new byte order functions everywhere. 2009-03-11 10:18:28 +00:00
Jef Driesen
a2ccc4926d Add fingerprint support for the Suunto Vyper2 and D9. 2009-02-23 13:04:08 +00:00
Jef Driesen
4368b94ff0 Added basic support for the fingerprint feature. 2009-02-23 13:03:20 +00:00
Jef Driesen
626c28ad6c Add a device info event for the Suunto D9 and Vyper2. 2009-02-20 12:25:50 +00:00
Jef Driesen
845e6442f6 Port the Suunto Eon, Vyper, Vyper2 and D9 to the new event code. 2009-02-20 12:11:52 +00:00
Jef Driesen
eb9efb47e1 Check the length of the provided buffer space before the data transfer. 2009-02-11 10:43:44 +00:00
Jef Driesen
596af5a17b Add LGPL license headers. 2008-10-05 20:14:18 +00:00
Jef Driesen
ffe99a8724 Always read at least 8 bytes, because reading fewer bytes is unreliable. 2008-09-27 06:09:14 +00:00
Jef Driesen
276f45acd2 Allow the library to be compiled as C++ code.
Moved the initialization of the backend pointers to the beginning of the 
source file. Without the need for a tentative definition, the library 
can be compiled with a C++ compiler.
2008-09-03 10:16:35 +00:00
Jef Driesen
dfeea21c36 Add explicit casts to improve type safety. 2008-09-03 08:51:07 +00:00
Jef Driesen
599827d5a3 Improve the type safety by using the device_status_t enum. 2008-09-03 08:46:21 +00:00
Jef Driesen
b031d8dc2c Stop abusing status codes to return size information to the application.
When necessary, an output parameter is added to provide the size 
information. Status codes are strictly reserved for providing status 
information only.
2008-08-28 09:07:09 +00:00
Jef Driesen
dd847c5cf6 Implemented progress notifications for the Suunto D9 and Vyper2. 2008-08-19 10:17:13 +00:00
Jef Driesen
7c03ddcb15 Moved all the checksum functions to a common file. 2008-07-30 08:56:08 +00:00
Jef Driesen
5ae3b98d5d Implement the device_dump() function on top of device_read(). 2008-07-22 06:05:36 +00:00
Jef Driesen
16b14e55ef Allow to abort a transfer by returning FALSE from the callback. 2008-07-22 05:35:08 +00:00
Jef Driesen
4f63295802 Add a function to initialize the base class. 2008-07-22 05:31:26 +00:00
Jef Driesen
eaf10b59da Rename the device_download() function to device_dump().
The new name makes it more clear that it's not the recommended function 
to download data.
2008-07-17 05:25:53 +00:00
Jef Driesen
d0823f6a9d Port the Suunto Vyper2 to the new api. 2008-07-04 14:10:38 +00:00
Jef Driesen
3ec8bb025c Added a constant for the size of the version data. 2008-07-04 06:37:25 +00:00
Jef Driesen
0f625f601f Defined a few macros for the ringbuffer code. 2008-07-03 05:26:47 +00:00
Jef Driesen
d629e02ca2 Moved all ringbuffer operations to a common location. 2008-06-20 13:20:29 +00:00
Jef Driesen
27ce6102ee Updated the Suunto Vyper2 code to match the D9 code. 2008-06-20 12:54:34 +00:00