LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-23-2009, 02:01 AM   #1
gauravparihar
LQ Newbie
 
Registered: May 2008
Location: India
Distribution: redhat,kubuntu
Posts: 14

Rep: Reputation: 0
Resetting a serial port in Linux?


Hi all,

Scenario:
I communication with different subsystems using serial port. In some subsystems after running for a while, I start getting invalid data inspite of system sending correct data. For dealing with this situation I used to
reset serial ports by closing and reopening serial port, it was doing the
trick but somehow when I have implemented this in my new application, this
also doesn't work. I am struck.
void CPort::ResetPort()
{
tcflush(Fd, TCIFLUSH);//flush all data received but not read
ClosePort();//close port
OpenPort(mStrPortNo);//open the port specified by port number and in read mode
qDebug("\n Reset Subsystem =%s,Port number =%s,Fd=%d ",qPrintable(msSubsystemName),mStrPortNo,Fd);
//code for setting port setting of serial port for individual sub systems
}

The ClosePort function invokes close system call.

Can anybody suggest me some other way to reset serial port in Linux.
I am using RHEL 4, C++ and Qt 4.2.1 for my application development. Also
I have used multithreading to implement each subsystem in a separate thread. Its strange that if A,B,C are three threads, A & B run fine together but when C is introduced B starts receiving invalid data after
sometime and never recovers even after resetting the port as mentioned above.

Any suggestions???????????????????
 
Old 03-23-2009, 02:13 AM   #2
harry_uk
Member
 
Registered: Mar 2009
Posts: 36

Rep: Reputation: 16
http://www.linuxquestions.org/questi...-linux-671894/

Look into the links given in this thread, they are quite useful...

http://www.linuxforums.org/forum/lin...ll-buffer.html

This looks more specific to your problem

Last edited by harry_uk; 03-23-2009 at 02:14 AM.
 
Old 03-24-2009, 12:23 AM   #3
gauravparihar
LQ Newbie
 
Registered: May 2008
Location: India
Distribution: redhat,kubuntu
Posts: 14

Original Poster
Rep: Reputation: 0
Hi,

Thanks for the reply, I tried the CRTSCTS option but it only increased the time after which the problem of broken frames occur. Can somebody suggest something else??????????
 
Old 03-24-2009, 01:14 AM   #4
harry_uk
Member
 
Registered: Mar 2009
Posts: 36

Rep: Reputation: 16
I suggest the mods to move this to the programming thread, maybe then he will get more help, than here. Im not an expert in c programming bro..... i just tried to help with what i found
 
Old 03-24-2009, 03:20 AM   #5
Valery Reznic
ELF Statifier author
 
Registered: Oct 2007
Posts: 676

Rep: Reputation: 137Reputation: 137
stty (especially stty -a) is a convenience way to examine/change serial port settings
 
  


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
Resetting a serial port in Linux? gauravparihar Linux - Newbie 1 03-23-2009 06:41 AM
linux serial port to router console port connection? frankie_fix Linux - General 3 02-26-2007 09:32 PM
Using serial port card(PCMCIA) with IPAQ running Linux, can't find ttyS0 port d2army Linux - Laptop and Netbook 0 11-12-2005 08:07 PM
Resetting USB Port iomari Linux - Hardware 0 01-27-2005 11:31 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:47 PM.

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