LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 07-17-2011, 04:14 PM   #1
rtspitz
Member
 
Registered: Jan 2005
Location: germany
Distribution: suse, opensuse, debian, others for testing
Posts: 307

Rep: Reputation: 33
FTDI USB/TTL serial adapter. TIOCM_DTR bit


Hi,

I haven an issue with avrdude (program to talk to Atmel microcontrollers).

In 'ser_posix.c' there is code to set/clear the DTR line similar to this (minimal example):

Code:
#include <termios.h>
#include <fcntl.h>
#include <sys/ioctl.h>
main() {
        int fd, serial;
        fd = open("/dev/ttyUSB0", O_RDWR | O_NOCTTY | O_NONBLOCK );

        usleep(1000000);

        ioctl(fd, TIOCMGET, &serial);
        if (serial & TIOCM_DTR) {
                puts("TIOCM_DTR is not set");
        } else {
                puts("TIOCM_DTR is set");
        }

        usleep(50000);

        serial |= (TIOCM_DTR); // set bit, set line LOW
        //serial &= ~(TIOCM_DTR); // clear bit, set line HIGH
        ioctl(fd, TIOCMSET, &serial);

        ioctl(fd, TIOCMGET, &serial);
        if (serial & TIOCM_DTR) {
                puts("TIOCM_DTR is not set");
        } else {
                puts("TIOCM_DTR is set");
        }

        usleep(50000);

        ioctl(fd, TIOCMGET, &serial);
        if (serial & TIOCM_DTR) {
                puts("TIOCM_DTR is not set");
        } else {
                puts("TIOCM_DTR is set");
        }

        while(1) {
                // wait here
        }

        close(fd);
}
Now it is a verified fact (logic analyzer) that on my system I need to CLEAR the TIOCM_DTR bit to make the physical DTR line go HIGH and vice versa. This low-level code is later used in a function 'ser_set_dtr_rts()'. When this function is fed with '0' the DTR line should be LOW, when fed with a '1' it should set it to HIGH. On my machine this only works with above mentioned inversed register writes. But now there is a patch that inverses this and claims to be correct...

Currently I'm having a discussion on avrdude's site on savannah.nongnu.org about this.

Is the HIGH/LOW business maybe caused by the conversion from RS232 to 5V-TTL-serial?

I was going to ask about this on a suitable linux kernel mailing list, but couldn't find 'the one'.
 
Old 07-19-2011, 08:36 PM   #2
elucches
Member
 
Registered: Jan 2011
Posts: 108

Rep: Reputation: 11
Just guessing, it could be a confusion between voltage and logic level (RS-232 negative voltage for high logic level and viceversa).
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
FTDI USB-to-Serial /dev naming RogueWarrior65 Linux - Hardware 5 09-23-2010 04:05 PM
USB serial driver(ftdi): there is error in receive data plumnut Linux - Newbie 0 03-23-2009 06:30 AM
USB->Serial adapter abolishtheun Linux - Hardware 3 11-25-2008 07:13 PM
ftdi serial to usb converter rightsidedown Linux - Hardware 1 04-29-2008 04:36 PM
zoom external serial with usb to serial adapter foustware Linux - Hardware 1 12-07-2003 02:02 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 03:21 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration