LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Resetting a serial port in Linux? (https://www.linuxquestions.org/questions/linux-newbie-8/resetting-a-serial-port-in-linux-713707/)

gauravparihar 03-23-2009 01:08 AM

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???????????????????

michaelk 03-23-2009 06:41 AM

Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. This thread is being closed because it is a duplicate.


All times are GMT -5. The time now is 05:53 PM.