Pages: [1]   Go Down
Author Topic: Linux code for RTS with Boarduino and FTDI serial  (Read 881 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 4
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
ttyset.c_cflag = CREAD | CS8 | CLOCAL;
to be
Code:
ttyset.c_cflag = CREAD | CS8 | CLOCAL | HUPCL;
That's line 303.

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

Code:
termios.c_cflag = (CS8 | CREAD | CLOCAL );
to be
Code:
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.
Logged

Forum Administrator
Cambridge, MA
Offline Offline
Faraday Member
*****
Karma: 11
Posts: 3538
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

0
Offline Offline
Newbie
*
Karma: 0
Posts: 4
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

Forum Administrator
Cambridge, MA
Offline Offline
Faraday Member
*****
Karma: 11
Posts: 3538
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 267
dinosaur cork
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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



« Last Edit: June 11, 2008, 11:31:09 pm by paulb » Logged

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 267
dinosaur cork
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
« Last Edit: June 17, 2008, 11:01:46 pm by paulb » Logged

Pages: [1]   Go Up
Jump to: