473,385 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

serial port behavior

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

Nov 15 '05 #1
2 2099
be******@kn.vutbr.cz wrote:
I am trying to control special device through serial port from Linux.


(You're looking for the folks in comp.unix.programmer.)

Your post is off-topic for comp.lang.c. Please visit

http://www.ungerhu.com/jxh/clc.welcome.txt
http://www.eskimo.com/~scs/C-faq/top.html
http://benpfaff.org/writings/clc/off-topic.html

for posting guidelines and frequently asked questions. Thank you.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Nov 15 '05 #2
<be******@kn.vutbr.cz> wrote in message
news:11*********************@g49g2000cwa.googlegro ups.com...
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.

--
"It's better to have rocked and lost than never to have rocked at
all." -John Flansburgh
Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: ^CeFoS^ | last post by:
Hello to everybody, I've done an application that draws in a frame the trajectory of a robot. The robot position is readed through the serial port, and several commands are wrote through the...
2
by: willie | last post by:
Hi, I'm writing a program which requires the use of three serial ports and one parallel port. My application has a scanning devices on each port, which I can access fine with pyserial. ...
3
by: Daniel Passwater via DotNetMonster.com | last post by:
I have a serial connection in C# with a device running embedded C. My problem is that if the owner of the C code puts interupts in, I receive data. Without the interupts the transfer seems to be too...
7
by: Michael Chong | last post by:
I wrote a program that communicate with SerialComm. In every 300 milliseconds, my program continuously send & receive data via the serial port once the program starts. My program is once in a...
13
by: Al the programmer | last post by:
I need to access the serial ports on my webserver from an asp.net page. I have no problem accessing the serial ports from a windows form application, but the code doesn't work in asp.net. I have...
4
by: joe bloggs | last post by:
I am writing a mobile application to interface with a legacy system and I am planning to use web services to communicate with this system. The legacy system receives data through a serial port. ...
4
by: Frank | last post by:
Hello, how to get information about all serial ports in the PC? I use the following code, but i got only the data of the FIRST serial port. All other serial port information are not available...
13
by: Rob | last post by:
Hi all, I am fairly new to python, but not programming and embedded. I am having an issue which I believe is related to the hardware, triggered by the software read I am doing in pySerial. I...
6
by: terry | last post by:
Hi, I am trying to send a character to '/dev/ttyS0' and expect the same character and upon receipt I want to send another character. I tired with Pyserial but in vain. Test Set up: 1. Send...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.