LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Resetting a serial port in Linux? (https://www.linuxquestions.org/questions/linux-software-2/resetting-a-serial-port-in-linux-713713/)

gauravparihar 03-23-2009 02:01 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???????????????????

harry_uk 03-23-2009 02:13 AM

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

gauravparihar 03-24-2009 12:23 AM

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

harry_uk 03-24-2009 01:14 AM

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

Valery Reznic 03-24-2009 03:20 AM

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


All times are GMT -5. The time now is 11:02 PM.