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