Werror Writing to Com Port Get Overlapped Result

  1. December 30th, 2002,11:49 AM #1

    Communication errors (995, CE_OVERRUN) from serial port

    Hi,
    I am using serial port with overlapped mode. After some or many successful reads from the port (in a loop), the GetOverlappedResult() returns an error code 995. I check more on the error with ClearCommError() and it returns CE_OVERRUN has occured.

    Does anybod face this kind of errors ever? How can I fix them! I am using Widows XP. I don't know why this error originates in the first place?

    Thanks


  2. December 30th, 2002,12:11 PM #2

    What type of flow control are you using on the port?

    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.


  3. December 30th, 2002,12:24 PM #3

    I am not using any flow control.

    PHP Code:

        dcb . BaudRate = 115200 ;
    dcb . Parity = NOPARITY ;
    dcb . ByteSize = 8 ;
    dcb . StopBits = ONESTOPBIT ;
    dcb . fBinary = TRUE ;
    dcb . fParity = FALSE ;
    dcb . fOutxCtsFlow = FALSE ; // No CTS output flow control
    dcb . fOutxDsrFlow = FALSE ; // No DSR output flow control
    dcb . fDtrControl = DTR_CONTROL_DISABLE ;
    dcb . fDsrSensitivity = FALSE ; // DSR sensitivity
    dcb . fErrorChar = FALSE ; // Disable error replacement
    dcb . fNull = FALSE ; // Disable null stripping
    dcb . fRtsControl = RTS_CONTROL_DISABLE ;
    dcb . fAbortOnError = TRUE ; // Always respond to errors
    dcb . XonLim = ( WORD )( 0.25 * RXQUEUE ); // RXQUEUE is buffer size
    dcb . XoffLim = ( WORD )( 0.25 * RXQUEUE );
    dcb . fTXContinueOnXoff = FALSE ;
    dcb . fInX = FALSE ;
    dcb . fOutX = FALSE ;
    dcb . XonChar = ASCII_XON ;
    dcb . XoffChar = ASCII_XOFF ;
    dcb . EofChar = 0 ;
    dcb . EvtChar = 0 ;
    dcb . fDummy2 = 0 ;
    dcb . wReserved = 0 ;


  4. December 30th, 2002,12:42 PM #4

    That is why you are getting overruns. You are processing data slower than the device is transmitting it, eventually the buffers run out. You need to implement the proper flow control so you can "throttle" the transmitting device.

    Either that or make your receive processing faster. This is very difficult to do on a window machine since you never know what other programs (including system tasks) might be running which could slow down your program.

    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.


  5. December 30th, 2002,01:21 PM #5

    Can you tell me on what type of flow control should be used here because the device I am talking to has a round pin connector which I think is only 2 or 3 wires...on pc side is of coruse the regular 9 pin serial connector.Is hardware flow control possible with these lines? If not what character should I use for xon/xoff flow control since that can equally be data itself?

    Thanks


  6. December 30th, 2002,01:44 PM #6

    According to your DCB settings, you are actually using XON / XOFF flow control (XON and XOFF are both ASCII characters, by the way). But overrun errors are caused by the driver itself being unable to process incoming data fast enough, and flow control may not help that. I suggest you try lowering your speed from 115KB.

    Regards
    Robert Thompson


  7. December 30th, 2002,02:51 PM #7

    I think I am not using xon/xoff either because fInX = FALSE;

    I tried to increase the the read spead by increasing the read thread priority to highest and I got interesting resuts. With Normal thread priority the GetOverlappedResult() was able to catch the error when a byte was lost (CE_OVERRUN). Now with the high thread priority the bytes are still lost but the no API seems to catch the error. I only know the loss of bytes because the bytes recieved is less than the bytes asked for (or expected).

    Can anybody explain the above why are the APIs silent on errors with high thread priority. I don't want to go down on baud rate but fix this problem.

    Thanks


  8. December 30th, 2002,03:19 PM #8

    You're right, that's my mistake. It just occurred to me, though: why are you worrying about XON / XOFF being interpreted as data? The flow control characters are issued by the receiving end to tell the transmitting end to start or stop. They aren't part of the data transmission at all.

    Regards
    Robert Thompson


Werror Writing to Com Port Get Overlapped Result

Source: https://forums.codeguru.com/showthread.php?224558-Communication-errors-%28995-CE_OVERRUN%29-from-serial-port

0 Response to "Werror Writing to Com Port Get Overlapped Result"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel