1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 <2007> 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 | Index | 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 <2007> 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 |
<== Date ==> | <== Thread ==> |
---|
Subject: | Re: Out of order replies from a serial device |
From: | Dirk Zimoch <[email protected]> |
To: | Phillip Sorensen <[email protected]> |
Cc: | TechTalk EPICS <[email protected]>, [email protected] |
Date: | Mon, 05 Feb 2007 14:45:31 +0100 |
Phillip Sorensen wrote:
I took some time to look at the asyn code this morning. I am looking at ASYN 4-6.
Mark Rivers wrote:
I believe asyn is doing the flush operation that Emmanuel suggested.
As far as I can tell, there is no flush before writes at either the devGpib level or the port driver level for drvAsynSerialPort or drvAsynIPPort. What I did find was that in the drvAsynSerialPort.c file that a timeout at this level causes a flush. There is no similiar flush in the drvAsynIPPort.c code.
I suspect you are not getting out of order replies. I think you are getting a timeout, but then stale data from some buffer is ending up in the apparent data you received with the timeout.
The "out of order" data seems to be coming from the OS socket buffer (I am running under linux). They are never flushed after a timeout.
This looks like a "possible" bug to me, and think that flushing the buffer would do away with my "out of order error", BUT I don't think it is the root cause of my problem.
After taking a second look at the code, I think I have found the root of my problem. I was puzzled by the fact that the code seemed to work with an older version of ASYN and that increasing the timeout parameter had no effect on the problem.
It appears that when the timeout handling code was removed from the drvAsynIPPort driver the SOCK_EINTR error return from the recv is now treated as if it were a timeout. In the previous version of the code that I have and in the drvAsynSerialPort code, the recv was inside a for(;;) loop which would retry the read in the EINTR error state.
I will try to put together a patch to retry to the recv on SOCK_EINTR in the next day or so.
Phil Sorensen CHESS
-- Dr. Dirk Zimoch Swiss Light Source Computing and Controls Paul Scherrer Institut phone +41 56 310 5182 fax +41 56 310 4413