Gentoo Archives: gentoo-embedded

From: Daniel Stonier <d.stonier@×××××.com>
To: gentoo-embedded@l.g.o
Subject: Re: [gentoo-embedded] serial port handling question
Date: Thu, 14 Jan 2010 02:56:18
Message-Id: 27dfa3d1001131856u29a0b5e0s82001c90956b27c@mail.gmail.com
In Reply to: [gentoo-embedded] serial port handling question by David Relson
1 I've never actually used the RTS on - always had it off. But just in
2 case you didn't find the details there's a setting in the termios
3 options structure for rts - have you tried that?
4
5 'man termios' - look for CRTSCTS.
6
7 I usually use a bit of code to set the flag off for my connections:
8
9 *******************************
10
11 termios options;
12 // Disable Flow control
13 #if defined(CRTSCTS)
14     options.c_cflag &= ~CRTSCTS; // Disable hardware flow control (old)
15 #elif defined (CNEW_RTSCTS)
16     options.c_cflag &= ~CNEW_RTSCTS; // Disable hardware flow control (new)
17 #endif
18 tcsetattr(file_descriptor,TCSAFLUSH,&options);
19
20 *******************************
21
22 Above, file_descriptor is the handle you get back from the previously
23 called open(...).
24
25 2010/1/14 David Relson <relson@×××××××××××××.com>
26 >
27 > G'day,
28 >
29 > I'm porting some old DOS code to Linux for a medical device that is
30 > being upgraded.  Among other goodies, it has a sensor that sends data at
31 > 115KB to an onboard NS16550A (or equivalent).
32 >
33 > The sensor is controlled (in part) by setting RTS on and off. I looked
34 > high and low (pun intended) for an ioctl or similar call that would
35 > allow this level of control and couldn't find anything. I finally ended
36 > up using the ollowing lines of code:
37 >
38 >  outb(inportb(MCR) |  0x02, MCR);  //DTR,RTS=ON
39 >  outb(inportb(MCR) & ~0x02, MCR);  //DTR=ON,RTS=OFF
40 >
41 > Directly tweaking the I/O port runs against the grain, but it's the
42 > only thing I've found that works.
43 >
44 > Is there a better way to control the chip?
45 >
46 > Regards,
47 >
48 > David
49 >
50
51
52
53 --
54 Phone : +82-10-5400-3296 (010-5400-3296)
55 HomePage: http://snorriheim.dnsdojo.com/
56 Yujin Robot: http://www.yujinrobot.com/
57 Projects: http://snorriheim.dnsdojo.com/redmine/projects
58 Embedded Control Libraries: http://snorriheim.dnsdojo.com/redmine/wiki/ecl

Replies

Subject Author
Re: [gentoo-embedded] serial port handling question Peter Stuge <peter@×××××.se>