B
bernatik
hi all
I am trying to control special device through serial port from Linux.
For that purpose I need to control DTR signal. I am watching the signal
on a oscilloscope, so I know exactly what is happening.
terminology from:
(http://www.easysw.com/~mike/serial/serial.html)
when DTR is in SPACE level and I call ioctl to set it to SPACE level,
nothing happen, as expected.
but when DTR is in MARK level and I set it to MARK level, it generates
a short
peak.
switching from MARK to SPACE works as expected.
second strange thing is, that when the program end, DTR does not change
to initial level (even if I restore terminal state), and no matter what
real DTR state is, reading controlbits always returns same result
(0x4006).
I am working with serial port first time, so any help/explanation will
be apreciated.
I am not sure I am doing smething wrong, or this is "normal" behavior.
I tested it on 2 different machines, without any difference.
my code is generally taken from Serial Programming Guide, and looks
like this
( open/save/restore modem exactly from guide)
------
//setting DTR
int controlbits;
ioctl(fd, TIOCMGET, &controlbits);
//to SPACE
controlbits |= TIOCM_DTR;
//to MARK
controlbits &= ~TIOCM_DTR;
ioctl(fd, TIOCMSET, &controlbits);
I am trying to control special device through serial port from Linux.
For that purpose I need to control DTR signal. I am watching the signal
on a oscilloscope, so I know exactly what is happening.
terminology from:
(http://www.easysw.com/~mike/serial/serial.html)
when DTR is in SPACE level and I call ioctl to set it to SPACE level,
nothing happen, as expected.
but when DTR is in MARK level and I set it to MARK level, it generates
a short
peak.
switching from MARK to SPACE works as expected.
second strange thing is, that when the program end, DTR does not change
to initial level (even if I restore terminal state), and no matter what
real DTR state is, reading controlbits always returns same result
(0x4006).
I am working with serial port first time, so any help/explanation will
be apreciated.
I am not sure I am doing smething wrong, or this is "normal" behavior.
I tested it on 2 different machines, without any difference.
my code is generally taken from Serial Programming Guide, and looks
like this
( open/save/restore modem exactly from guide)
------
//setting DTR
int controlbits;
ioctl(fd, TIOCMGET, &controlbits);
//to SPACE
controlbits |= TIOCM_DTR;
//to MARK
controlbits &= ~TIOCM_DTR;
ioctl(fd, TIOCMSET, &controlbits);