Commit graph

3 commits

Author SHA1 Message Date
Anton Lundin
e2c98def26 Turn serial_ftdi.c into a custom_serial
This cleans up serial_ftdi.c from being a libdivecomputer source and
making it into a subsurface custom_serial.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-20 22:59:49 -07:00
Anton Lundin
3104508247 Re-indent and style up serial ftdi
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-20 22:59:42 -07:00
Venkatesh Shukla
f33843ed35 serial_ftdi.c for communication with ftdi devices
This script is based on serial_posix.c and is primarily meant to work on
android, but could be used elsewhere as well. This script communicates with
libftdi devices connected to the system using libftdi library.

ftdi_read_data returns 0 if no data is received from the device. Allowing to
continue on recieving 0 might end up in an infinite loop. But it works in
OSTC3. This needs to be checked further.

libftdi returns -3 when it could not find any device corresponding to the pid
and vid given. (Different from -3 of libusb which means you do not have
permissions to access the device) Use this to return value to check for other
accepted chipsets including the custom pids used by divecomputer manufacturers
such as Cressi (Leonardo), Suunto and Oceanic.

ftdi_read_data returns the number of bytes read (+ve), 0 when there is no data
to read, and negative when there is an error.
Instead of infinitely waiting for the data to appear, it is better to implement
an exponential backoff which times out after MAX_BACKOFF.

[Anton Lundin: This code was originally intended to be included in
	       libdivecomputer, but because we now got the custom-serial
	       patches, its included in subsurface instead, and wired in
	       from there - renamed the resulting file to serial_ftdi.c]

Signed-off-by: Venkatesh Shukla <venkatesh.shukla.eee11@iitbhu.ac.in>
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>

Rename serial_ftdi.c for subsurface source

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-20 22:58:45 -07:00