LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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 03-05-2003, 02:04 AM   #1
bajen_hasse
LQ Newbie
 
Registered: Feb 2003
Posts: 8

Rep: Reputation: 0
tcdrain


Hi !

tcdrain() seems to have some serios problems. If I call tcdrain after a write it just hangs there forever. Any ideas?
the code:

write(fd,(char *)&x,sizeof(x));
tcdrain(fd); <--- here we hang....
write(...)
tcdrain();
write(...);
etc..

the fd is opened with:

open("/dev/ttyS1",O_RDWR|O_NOCTTY|O_NDELAY);

If I call tcflush before I start writing(and remove the tcdrains) it works better.
 
Old 03-06-2003, 07:43 AM   #2
wapcaplet
LQ Guru
 
Registered: Feb 2003
Location: Colorado Springs, CO
Distribution: Gentoo
Posts: 2,018

Rep: Reputation: 48
I think you need to use flush() after doing write().
 
Old 03-06-2003, 07:46 AM   #3
bajen_hasse
LQ Newbie
 
Registered: Feb 2003
Posts: 8

Original Poster
Rep: Reputation: 0
But according to the man page tcdrain should wait until all bytes are written. flush sholud discard them.
 
Old 03-06-2003, 10:12 AM   #4
wapcaplet
LQ Guru
 
Registered: Feb 2003
Location: Colorado Springs, CO
Distribution: Gentoo
Posts: 2,018

Rep: Reputation: 48
I always thought flush caused the bytes to actually be written. It doesn't discard anything. (I could be wrong though... haven't done much with networking and I/O stuff)
 
Old 03-07-2003, 12:59 AM   #5
bajen_hasse
LQ Newbie
 
Registered: Feb 2003
Posts: 8

Original Poster
Rep: Reputation: 0
Normally flush works like that. But according to the termios man page drain waits and flush discards. Anyway tcdrain just hangs forevever...
 
Old 03-07-2003, 06:26 AM   #6
wapcaplet
LQ Guru
 
Registered: Feb 2003
Location: Colorado Springs, CO
Distribution: Gentoo
Posts: 2,018

Rep: Reputation: 48
I am afraid I don't know what to tell you then Hopefully someone else here can shed some light.
 
  


Reply



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



LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:27 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration