Visit Jeremy's Blog.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 08-02-2010, 01:15 PM   #1
LQ Newbie
Registered: Jul 2010
Posts: 11

Rep: Reputation: 0
Serial flow control

Hi guys,
do you know how to configure serial port RS-232 to use flow control??
The reason is without flow control is is not working properly(dala loss etc...)
Im trying to run it as it is just with setting the flow control flag and Im sending my data via loop-back on the rs-232 to GTK TERM on the same computer... but when I enable IXON/IXOFF in GTK TERM, my sending program cant even open the port...

My current settings is:
struct termios termios_p;
	tcgetattr(sc.fd, &termios_p);
	termios_p.c_cflag = B9600;
	termios_p.c_cflag |= CS8;
	termios_p.c_cflag |= CREAD;//Enable receiver
	termios_p.c_cflag |= CLOCAL;//Ignore modem status lines
	//termios_p.c_cflag &= ~ICANON;
	termios_p.c_iflag = IGNPAR | IGNBRK;//Ignore characters with parity errors | Ignore break condition
	termios_p.c_iflag |=(IXON);//|IXOFF|IXANY);
	termios_p.c_cflag &= ~PARENB;
	termios_p.c_cflag &= ~CSTOPB;
	termios_p.c_cflag &= ~CSIZE;
	termios_p.c_cflag &= ~CRTSCTS;
	termios_p.c_oflag = 0;
	termios_p.c_lflag = 0;
	termios_p.c_cc[VTIME] = 0;
	termios_p.c_cc[VMIN] = 1;
	printf("Configuring the port...");
	if(tcsetattr(sc.fd, TCSANOW, &termios_p)==-1){
		printf(" ERROR: Unable to configure the port correctly\n");
		printf(" OK\n");

	tcflush(sc.fd, TCOFLUSH);
	tcflush(sc.fd, TCIFLUSH);
Thank you guys

Last edited by zdenekkrejci; 08-02-2010 at 01:19 PM.
Old 08-03-2010, 12:01 AM   #2
Wim Sturkenboom
Senior Member
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
CTS/RTS is the hardware flow control; it requires the pins to be physically wired.
XON/XOFF is a software flow control that needs to be implemented at both sides in software. for some info on RS232 ports
Old 08-04-2010, 02:25 AM   #3
LQ Newbie
Registered: Jul 2010
Posts: 11

Original Poster
Rep: Reputation: 0
Hi yes I know about the pins in case of HW flow ctrl and also know XON/XOFF in case of software flow ctrl.
but when I enable IXON/IXOFF in GTK TERM, my sending program cant even open the port... Thats the problem


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
Serial communication and hardware flow control CoderMan Programming 1 03-26-2009 03:26 AM
flow control rehan999 Linux - Networking 3 05-05-2008 02:58 AM
Serial flow control in 2.6.8 kidzmom3 Linux - General 1 12-08-2004 08:47 AM
Disable Hardware Flow Control at serial port DJ_Cyberdance Linux - Hardware 0 11-27-2003 02:00 AM
what should be my flow control values? HW? SF? or NONE? kublador Linux - Networking 0 06-07-2003 11:03 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:10 AM.

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