Libdivecomputer Android API discussion

Venkatesh Shukla venkatesh.shukla.eee11 at iitbhu.ac.in
Wed Jun 25 05:22:04 PDT 2014


Hello

I have been working on bringing libdivecomputer on android.
I have started with support for ftdi-chipset based divecomputers. For
talking with ftdi based devices on android, I have implemented
serial_ftdi.c. . I have tried to implement all the the necessary functions.
Though some of them are left out due to their unavailability in libftdi.

These left out functions are

   1. serial_set_break  - This is used only in reefnet_sensus_pro
   hanshaking. I do not know if it uses ftdi chipset. If it does, it would
   become important to implement this function. In the present implementation,
   it remains unusable.
   2. serial_send_break - I could not find any usage of this function in
   libdivecomputer.
   3. serial_get_transmitted - Even though the received bytes in the buffer
   can be accessed, I couldn't find any way to get the transmitted bytes. This
   function is used internally for logging. Returns -1 as it is not
   implemented.


Changes made for building libdivecomputer for android are

   1. Check for presence of libftdi1
   2. serial_ftdi.c is compiled and used instead of serial_posix.c
   3. libftdi1 is included in Libs.private in libdivecomputer.pc

All these changes can be viewed here
<https://github.com/venkateshshukla/libdivecomputer>. I have been testing
it with universal script and subsurface-android. Results have been
encouraging.

Now, toward providing a workable API for android, I have following points
in mind. These were mentioned by Jef in an earlier mail.

   1. Support for only ftdi devices are implemented for now. But support
   for other chipsets need to be included later on. Hence, serial_ftdi.c alone
   is not enough. We need a serial_android.c which will redirect calls to
   respective chipset specific scripts.
   2. I have come to the conclusion that for android, it will be best if we
   pass the file descriptor of the USB device after acquiring the necessary
   permissions. This fd can be used to create a libusb_device and subsequently
   all USB related features can be accessed. For making a libusb_device from
   file descriptor obtained from android, I had tweaked libusb. This tweaked
   version is present here ( https://github.com/venkateshshukla/libusb ).
   This libusb_device could be used to obtain VID and PID and then control can
   then be branched accordingly to ftdi, pl2303, cp210x and other chipset
   specific scripts on android.
   3. We will require a generalized mechanism for passing parameters. This
   is especially needed now as we have several branches - Normal TTY usage (
   posix/win32 , path to the device), android (file descriptor) and Bluetooth
   address.

Please provide your thoughts on the above points. Also any other thing that
I should keep in mind for android API?

-- 
Venkatesh Shukla
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://libdivecomputer.org/pipermail/devel/attachments/20140625/cd431f6b/attachment.html>


More information about the devel mailing list