Using auto reset with FTDI cables on Linux / MAC

The IDE uses the DTR line to reset the Arduino boards.

Unfortunately the FTDI cables don't have the DTR line in the plug, but the RTS line. Thus auto reset won't work out of the box.

Here's a littlel Perl script that extracts the serial port passed to avrdude and pulses the RTS line before it calls avrdude. This way the famous auto reset feature works again. The Perl script requires to install the module Device::SerialPort from CPAN !!

#!/usr/bin/perl

use Device::SerialPort;

$avrdude = "./hardware/tools/avrdude_bin";
my $line;
my $opt_string;
my $pulse_time = 100; # time in ms

for $line (@ARGV) {
$opt_string .= "\ ";
$opt_string .= $line;
}

my $serial_port;
$opt_string =~ m/.*-P(\/dev\/\w*)\ -.*/; # devices names can contain letters/numbers and _
$serial_port = $1;

print "Serial Port: ",$serial_port;

my $link = Device::SerialPort->new("$serial_port") || die("could not open port: $port - $!");

$link->pulse_rts_on($pulse_time);
$link->pulse_rts_off($pulse_time);

$avrdude .= $opt_string;
system($avrdude);

To use it, rename "avrdude" to "avrdude_bin" in the "./hardware/tools" folder. Then create a text file named "avrdude" and copy above code into it and save. Now change file permissions to 0700 (rwx,---,---) and you're good to go.

To install Device::SerialPort from CPAN. As root user, Type this in terminal. If you meet asking, Just type Enter.

perl -MCPAN -e shell
install Device::SerialPort
exit

Share