LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 12-19-2004, 02:05 PM   #1
ZeRoN
LQ Newbie
 
Registered: Dec 2004
Posts: 1

Rep: Reputation: 0
Question How to make /dev/ttyS0 automatic control DTR for TX/RX


Dear All,

How to make /dev/ttyS0 automatically control DTR for TX/RX.

I mean, When I write to /dev/ttyS0, DTR=ON,send a character,DTR=OFF, repeat until sent all characters in buffer.

THX IN ADV.
ZeRoN
 
Old 12-27-2004, 12:51 AM   #2
cppkid
Member
 
Registered: Jul 2004
Location: Pakistan
Distribution: Ubuntu
Posts: 185

Rep: Reputation: 30
All i can do for you is that i can provide you the way to clear and set DTR. Here it is....

You have to #include<sys/ioctl.h>
m_hCom is the handle to the Port or ttyS0

Code:
//________________________Set_DTR__________________bool Set_DTR(void)
{
int nRet;
int status;
status = 0;
nRet = ioctl(m_hCom, TIOCMGET,&status);
	if(nRet < 0) return FALSE;
status |= TIOCM_DTR;
nRet = ioctl(m_hCom, TIOCMSET, &status);
	if(nRet < 0) return FALSE;
return TRUE;
}


//________________________Clr_DTR__________________bool Clr_DTR(void)
{
int nRet;
int status;
status = 0;
nRet = ioctl(m_hCom, TIOCMGET,&status);
	if(nRet < 0) return FALSE;
status &= ~TIOCM_DTR;
nRet = ioctl(m_hCom, TIOCMSET, &status);
	if(nRet < 0) return FALSE;
return TRUE;
}

Last edited by cppkid; 12-27-2004 at 12:55 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how and by what is /dev/ttyS0 made? dansawyer Linux - Software 10 10-26-2005 05:51 AM
does udev make /dev/ttyS0 ? dansawyer Linux - Software 2 10-23-2005 11:16 PM
Minicom in /dev/ttyS0 Luis GUSTAVO Linux - Software 0 07-31-2003 05:42 PM
chmod g+w /dev/ttyS0 jISV Linux - General 4 04-13-2002 06:01 PM
/dev/ttyS0 problems rbermude Linux - Software 2 06-27-2001 10:43 AM


All times are GMT -5. The time now is 11:23 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration