Go Down

Topic: Linux code for RTS with Boarduino and FTDI serial (Read 958 times) previous topic - next topic

timv

I posted some fixes on ladyada.net 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: http://www.ladyada.net/forums/viewtopic.php?t=4703 I've been asked to post the fix here as well.

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

Code: [Select]
ttyset.c_cflag = CREAD | CS8 | CLOCAL;
to be
Code: [Select]
ttyset.c_cflag = CREAD | CS8 | CLOCAL | HUPCL;
That's line 303.

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

Code: [Select]
termios.c_cflag = (CS8 | CREAD | CLOCAL );
to be
Code: [Select]
termios.c_cflag = (CS8 | CREAD | CLOCAL | HUPCL );
That's line 117.

I got the RXTXComm source from http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7r2.zip. The Arduino app source that I modified was http://www.arduino.cc/files/avrdude-5.4-arduino-0010-src.tgz.

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.

mellis

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)?  

timv

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!

mellis

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.

paulb

#4
Jun 12, 2008, 06:29 am Last Edit: Jun 12, 2008, 06:31 am by paulb Reason: 1
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




paulb

#5
Jun 18, 2008, 05:59 am Last Edit: Jun 18, 2008, 06:01 am by paulb Reason: 1
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 LinuxFixArduino.zip, 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.

http://moderndevice.com/connect.shtml

Paul Badger

Go Up