bug-commoncpp
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problem when flow control is turned off in Windows


From: Surratt, Jason
Subject: Problem when flow control is turned off in Windows
Date: Mon, 26 Apr 2004 14:11:04 -0400

 

This may be by design, but I thought I would point it out anyways.

 

I am trying to communicate with a device over the serial port with no hardware flow control (setFlowControl(Serial::flowNone)). However, when I use this command my serial port acts just as though hardware flow control is enabled.

 

When poking around in the commoncpp2 source I noticed in the following methods that the fOutxCtsFlow attribute was originally set to 1. This is defined by Microsft as:

 

fOutxCtsFlow

Specifies whether the CTS (clear-to-send) signal is monitored for output flow control. If this member is TRUE and CTS is turned off, output is suspended until CTS is sent again.

 

Since I want no flow control, I tried disabling the attribute (set to 0) and it appears to have fixed my problem. I’ve included the modifications that I made in serial.cpp at the bottom of the email.

 

Thanks for a great library and please let me know if I misunderstand the intended use.

 

-jason

 

FYI I’m using Windows XP, MSVC 6 sp5 and commoncpp2-1.0.13 (although the relevant source appears to be identical in v1.1.5).

 

void Serial::initConfig(void)

{

#ifdef WIN32

 

#define ASCII_XON       0x11

#define ASCII_XOFF      0x13

 

       DCB * attr = (DCB *)current;

       DCB * orig = (DCB *)original;

 

    attr->DCBlength = sizeof(DCB);

    orig->DCBlength = sizeof(DCB);

 

    GetCommState(dev, orig);

    GetCommState(dev, attr);

 

    attr->XonChar = ASCII_XON;

    attr->XoffChar = ASCII_XOFF;

    attr->XonLim = 100;

    attr->XoffLim = 100;

    attr->fOutxDsrFlow = 0;

    attr->fDtrControl = DTR_CONTROL_ENABLE;

    attr->fOutxCtsFlow = 0; // Changed from 1 to 0

    attr->fRtsControl = RTS_CONTROL_ENABLE;

    attr->fInX = attr->fOutX = 0;

 

    attr->fBinary = true;

    attr->fParity = true;

 

Serial::Error Serial::setFlowControl(Flow flow)

{

#ifdef WIN32

 

       DCB * attr = (DCB *)current;

    attr->XonChar = ASCII_XON;

    attr->XoffChar = ASCII_XOFF;

    attr->XonLim = 100;

    attr->XoffLim = 100;

 

       switch(flow)

       {

       case flowSoft:

              attr->fInX = attr->fOutX = 1;

              attr->fOutxCtsFlow = 0; // Added

              attr->fRtsControl = RTS_CONTROL_ENABLE; // Added

              break;

       case flowBoth:

              attr->fInX = attr->fOutX = 1;

       case flowHard:

              attr->fOutxCtsFlow = 1;

              attr->fRtsControl = RTS_CONTROL_HANDSHAKE;

              break;

       case flowNone:

              attr->fInX = attr->fOutX = 0;

attr->fOutxCtsFlow = 0; // Added

              attr->fRtsControl = RTS_CONTROL_ENABLE; // Added

              break;

       default:

              return error(errFlowInvalid);

       }

 

       SetCommState(dev, attr);


reply via email to

[Prev in Thread] Current Thread [Next in Thread]