serial port behavior

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);
 
L

Luc The Perverse

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);

------

ubuntu, 2.6.10-5 kernel, serial port driver compiled in.

thanks for your time, have a nice day

Why in the world would you try to use C instead of something like Labview -
if you have never done this before?

I would assume you could cut orders of magnitude off your development time
if you switch to a "do it for me" system.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,123
Latest member
Layne6498
Top