ttystream in win32

Deniz Koprulu <[email protected]> Fri, 25 Aug 2006 01:13:11 -0700 (PDT)
Newsgroups gmane.comp.gnu.bayonne.devel
Message-ID <[email protected]>
Hi everyone,

The TTYStream class does not seem to work under WinXP SP2 (VS6
commoncpp2-1.4.2).

I have a null modem cable plugged in COM1. The following code is expected to echo the message "hi" every 3 seconds, but it does not. I tested two other serial applications that echo perfectly. So my hardware setup is ok.

I also tried with the ttysream class, and with different timeout values in the isPending call. No way...

Any clues?

Thanks.

-------------------------------------------

#include <iostream>
#include <cc++/serial.h>

using namespace ost;
using namespace std;

void main()
{
  TTYStream *s = new TTYStream("\\\\.\\COM1");

  if(s->setSpeed(38400)) cout << s->getErrorString() << endl;
  if(s->setCharBits(8)) cout << s->getErrorString() << endl;
  if(s->setParity(Serial::parityNone)) cout << s->getErrorString() << endl;
  if(s->setStopBits(1)) cout << s->getErrorString() << endl;
  if(s->setFlowControl(Serial::flowHard)) cout << s->getErrorString() << endl;

  for(int i=0;;i++)
  {
    if(i%3==0)
      *s<<"hi\r"<<endl;

    if(s->isPending(TTYStream::pendingInput,1)) 
      cout<<s->get()<<endl;

    SleepEx(1000,TRUE);
  }

  delete s;
}


 		
---------------------------------
How low will we go? Check out Yahoo! Messenger’s low  PC-to-Phone call rates.