473,671 Members | 2,442 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2116
be******@kn.vut br.cz wrote:
I am trying to control special device through serial port from Linux.


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

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)cybers pace.org | don't, I need to know. Flames welcome.
Nov 15 '05 #2
<be******@kn.vu tbr.cz> wrote in message
news:11******** *************@g 49g2000cwa.goog legroups.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
9087
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 same port to change the direction of the robot. The trajectory frame is managed by an applet, and the project works good when the applet is called by a html document allocated in the same local machine under W98 where the classes and the serial port...
2
13177
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. However, I'm unsure of how exactly I should be designing the program, I thought I could use threading to start class: class scanner(Thread): def __init__(self,port):
3
4097
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 fast. The interupts are an un acceptable solution. We are both connecting at 19200 baud. Does anyone have any suggestions? Here's my incoming data handler: This is located in the constructor: // Create event handler for the serial input....
7
2754
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 while, the serial port seems corrupted because when my data is sent, it doesn't go through the serial port, so as same to receive process. In order to fix this, I have to close the port and reopen the port again. Why?!! Is there any way to fix...
13
4815
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 been told it is not possible to access the serial ports from asp.net. The application is used to control custom hardware. The hardware is connected to a PC through serial ports. Our customer wants to control the hardware from a remote...
4
11187
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. What I would like to do is make the serial port accessible via a web service. The web service and the legacy application would be running on the same machine. The mobile application would access the web service via a network connection. It...
4
17804
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 with this code sample: ManagementObjectSearcher searcher = new ManagementObjectSearcher("Select * from WIN32_SerialPort");
13
6189
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 am sending a short message to a group of embedded boxes daisy chained via the serial port. When I send a 'global' message, all the connected units should reply with their Id and Ack in this format '0 Ack' To be certain that I didn't miss a...
6
6652
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 '%' to serial port and make sure it reached the serial port. 2. Once confirmed, send another character.
0
8401
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8926
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8603
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8673
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7444
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6236
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4416
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2818
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2060
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.