Linux code for RTS with Boarduino and FTDI serial

I posted some fixes on at the end of last year for fixing the handling of the RTS serial line in the Linux Arduino software when using a Boarduino board with the FTDI serial adapter. Details are here: I've been asked to post the fix here as well.

In src/SerialImp.c in the RXTXComm package, I changed the line

ttyset.c_cflag = CREAD | CS8 | CLOCAL;

to be

ttyset.c_cflag = CREAD | CS8 | CLOCAL | HUPCL;

That's line 303.

And in ser_posix.c in the Avrdude source, I changed

termios.c_cflag = (CS8 | CREAD | CLOCAL );

to be

termios.c_cflag = (CS8 | CREAD | CLOCAL | HUPCL );

That's line 117.

I got the RXTXComm source from The Arduino app source that I modified was

I made the same change in both places, just adding the "HUPCL" flag. This has the effect of automatically resetting the Boarduino when the serial port is closed so that it works the same way as the Windows Arduino app.

Cool, thanks for posting this.

What version of the Linux kernel are you using? I had the impression that HUPCL was set by default, and thus raises (or lowers?) DTR and RTS whenever the connection is closed. Is that not true? Or only true for certain kernel versions? Or only true for DTR and not RTS?

If you make these changes, does the auto-reset still work using the DTR line (e.g. with the Diecimila)?

Kernel is 2.6.17-11. This was my first adventure into Linux serial handling, so I really can't say anything about what the default behavior should be. Nor can I say anything about Diecimila. The Boarduino is my only Arduino experiernce.

Part of the issue might be that the FTDI doesn't seem to have separate DTR and RTS lines. It only has six wires.

I'm sorry that I can't offer more information about this. Under Ubuntu 6.10 it didn't auto-reset before this change and it did afterward, and that's really all I can say with confidence!

Can anyone else try this with a different Linux version and / or with a Diecimila?

Also, does anyone know if it's possible to set or unset HUPCL or RTS explicitly by using the RXTX API rather than modifying its source code? Maintaining patches to third-party programs is a hassle, even if it's only two lines.

Hi Tim,

Thanks for posting this. I've had a request from some Linux users who are also using the cable, for a fix to this issue. If you wouldn't mind sending me the patched version, I'll put it up on my site for people who are having this issue, and maybe we can also get it tested with a Diecimila to make sure it doesn't break anything.

Probably someone will test it and report back here before too long though. I'm also hoping that this fixes the need to check "set RTS on close" in the windows version.

Have you patched v 11 in a similar manner?

Paul Badger pbadger a t verizon d_ t net

One of my customers put together a patch to do the above modifications, which, to review, are intended to make the FTDI cable do autoreset with Linux.

It's called, and may be found here. I haven't looked at it, since I don't have a Linux machine [use for my Wintel box?]

But comments and suggestions could be posted on the Modern Device Forum.

Paul Badger