1 |
David Relson wrote: |
2 |
> I'm porting some old DOS code to Linux for a medical device that is |
3 |
> being upgraded. |
4 |
|
5 |
Interesting, this business. |
6 |
|
7 |
|
8 |
> The sensor is controlled (in part) by setting RTS on and off. |
9 |
|
10 |
What is controlled, exactly? What is RTS being used for? If it is |
11 |
indeed flow control then you are lucky and can simply enable hardware |
12 |
flow control for the serial port, and Linux will then take care of |
13 |
everything for you. |
14 |
|
15 |
If not flow control and some other signalling, you have to write a |
16 |
line discipline driver. I have done both this and serial drivers |
17 |
(also related to DOS era equipment) and documentation is not the |
18 |
greatest. Let me know if you would like some help. |
19 |
|
20 |
|
21 |
> I looked high and low (pun intended) for an ioctl or similar call |
22 |
> that would allow this level of control and couldn't find anything. |
23 |
|
24 |
The best thing out there is tcsetattr() and friends. |
25 |
|
26 |
By switching between baud rate 0 and something else you can reliably |
27 |
and easily control both RTS and DTR, and nothing but RTS and DTR, but |
28 |
always both at the same time. |
29 |
|
30 |
Line disciplines can call the tty_throttle() and tty_unthrottle() |
31 |
functions in the serial driver, which will then control RTS |
32 |
accordingly, but the default TTY line discipline does not expose any |
33 |
API that will result in throttle function calls. |
34 |
|
35 |
|
36 |
> outb(inportb(MCR) | 0x02, MCR); //DTR,RTS=ON |
37 |
> outb(inportb(MCR) & ~0x02, MCR); //DTR=ON,RTS=OFF |
38 |
> |
39 |
> Directly tweaking the I/O port runs against the grain, but it's the |
40 |
> only thing I've found that works. |
41 |
|
42 |
Not only against the grain, it can mess up internal state in the |
43 |
kernel serial layer and worst case lead to a kernel BUG_ON (kernel |
44 |
hangs) or best case serial port hang (unhang e.g. by closing all file |
45 |
handles for the port and opening again). It is not at all nice to |
46 |
change these signals behind Linux' back. |
47 |
|
48 |
|
49 |
//Peter |