summaryrefslogtreecommitdiffstats
path: root/core/serial_ftdi.c
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2018-03-11 13:03:42 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-03-13 22:34:57 -0700
commitf5e2a17e7d0fa041590ecdc7da3b970cc15537bd (patch)
treec1cf3b19b1808d5b1b25c1fbe1d19ac24d156733 /core/serial_ftdi.c
parent8de887c8ee898c64d36dfda44e1ea55f538f1e2d (diff)
downloadsubsurface-f5e2a17e7d0fa041590ecdc7da3b970cc15537bd.tar.gz
Subsurface update for upstream libdivecomputer changes
So because I merged with upstream libdivecomputer, and it no longer does the "halfduplex emulation" thing in the IO layer, and instead does it in the only Suunto backend that needed it, that also affected our custom IO layer in subsurface. Sure, I could have left a dummy interface and left subsurface with some ugly dead code, but it's really better to just get rid of the code. So when Dirk pulls in the libdivecomputer updates from https://github.com/torvalds/libdc-for-dirk.git Subsurface-branch this patch to remove the halfduplex code in subsurface is also needed. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Cc: Stefan Fuchs <sfuchs@gmx.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'core/serial_ftdi.c')
-rw-r--r--core/serial_ftdi.c53
1 files changed, 0 insertions, 53 deletions
diff --git a/core/serial_ftdi.c b/core/serial_ftdi.c
index 6471c2f0d..166bf0894 100644
--- a/core/serial_ftdi.c
+++ b/core/serial_ftdi.c
@@ -66,8 +66,6 @@ typedef struct ftdi_serial_t {
* Custom implementation using libftdi functions could be done.
*/
- /* Half-duplex settings */
- int halfduplex;
unsigned int baudrate;
unsigned int nbits;
unsigned int databits;
@@ -173,7 +171,6 @@ static dc_status_t serial_ftdi_open (dc_custom_io_t *io, dc_context_t *context,
device->timeout = -1;
// Default to full-duplex.
- device->halfduplex = 0;
device->baudrate = 0;
device->nbits = 0;
device->databits = 0;
@@ -365,21 +362,6 @@ static dc_status_t serial_ftdi_set_timeout (dc_custom_io_t *io, long timeout)
return DC_STATUS_SUCCESS;
}
-static dc_status_t serial_ftdi_set_halfduplex (dc_custom_io_t *io, unsigned int value)
-{
- ftdi_serial_t *device = (ftdi_serial_t*) io->userdata;
-
- if (device == NULL)
- return DC_STATUS_INVALIDARGS;
-
- // Most ftdi chips support full duplex operation. ft232rl does.
- // Crosscheck other chips.
-
- device->halfduplex = value;
-
- return DC_STATUS_SUCCESS;
-}
-
static dc_status_t serial_ftdi_read (dc_custom_io_t *io, void *data, size_t size, size_t *actual)
{
ftdi_serial_t *device = (ftdi_serial_t*) io->userdata;
@@ -432,13 +414,6 @@ static dc_status_t serial_ftdi_write (dc_custom_io_t *io, const void *data, size
return DC_STATUS_INVALIDARGS;
struct timeval tve, tvb;
- if (device->halfduplex) {
- // Get the current time.
- if (gettimeofday (&tvb, NULL) != 0) {
- SYSERROR (device->context, errno);
- return DC_STATUS_IO;
- }
- }
unsigned int nbytes = 0;
while (nbytes < size) {
@@ -456,33 +431,6 @@ static dc_status_t serial_ftdi_write (dc_custom_io_t *io, const void *data, size
nbytes += n;
}
- if (device->halfduplex) {
- // Get the current time.
- if (gettimeofday (&tve, NULL) != 0) {
- SYSERROR (device->context, errno);
- return DC_STATUS_IO;
- }
-
- // Calculate the elapsed time (microseconds).
- struct timeval tvt;
- timersub (&tve, &tvb, &tvt);
- unsigned long elapsed = tvt.tv_sec * 1000000 + tvt.tv_usec;
-
- // Calculate the expected duration (microseconds). A 2 millisecond fudge
- // factor is added because it improves the success rate significantly.
- unsigned long expected = 1000000.0 * device->nbits / device->baudrate * size + 0.5 + 2000;
-
- // Wait for the remaining time.
- if (elapsed < expected) {
- unsigned long remaining = expected - elapsed;
-
- // The remaining time is rounded up to the nearest millisecond to
- // match the Windows implementation. The higher resolution is
- // pointless anyway, since we already added a fudge factor above.
- serial_ftdi_sleep (device, (remaining + 999) / 1000);
- }
- }
-
INFO (device->context, "Wrote %d bytes", nbytes);
if (actual)
@@ -608,7 +556,6 @@ dc_custom_io_t serial_ftdi_ops = {
.serial_configure = serial_ftdi_configure,
.serial_set_dtr = serial_ftdi_set_dtr,
.serial_set_rts = serial_ftdi_set_rts,
- .serial_set_halfduplex = serial_ftdi_set_halfduplex,
// Can't be done in ftdi?
// only used in vyper2
.serial_set_break = serial_ftdi_set_break,