Menu

#173 serial module bug under winXP

open
nobody
5
2012-11-20
2004-02-25
No

In version 1.1.0 I have found the undesired behaviour
of the serial module.

When I send the some sequence like "ath", I have got
only first letter "a". This behaviour is occured due to
somthing in the windows reading file mechanizm. I have
written additional function for avoid this.

At the begin, I have changed the CommTimeouts to next
state:
...
CommTimeOuts.ReadIntervalTimeout = MAXDWORD;
// CommTimeOuts.ReadIntervalTimeout = 0;

CommTimeOuts.ReadTotalTimeoutMultiplier = 0 ;
CommTimeOuts.ReadTotalTimeoutConstant = 0;
CommTimeOuts.WriteTotalTimeoutMultiplier = 0 ;
// CommTimeOuts.WriteTotalTimeoutConstant = 1000;
CommTimeOuts.WriteTotalTimeoutConstant = 0;
...

In the serial.h:
...
enum Queue
{
queueInput,
queueOutput
};
typedef enum Queue Queue;
...
public:
...

/**
* Get the size of pending queue.
*
* @return size of the queue
* @param que type of the queue
*/
int getQueueSize(Queue que);
...

In the serial.cpp

...
int Serial::getQueueSize(Queue queue)
{
#ifdef WIN32
unsigned long dwError;
COMSTAT cs;

ClearCommError(dev, &dwError, &cs);

switch(queue)
{
case queueInput:
return cs.cbInQue;
case queueOutput:
return cs.cbOutQue;
}
#else
// not implemented yet...
#endif // !WIN32
return 0;
}
...

After this changes I have fixed the SerialEcho.cpp sample:
...
while (isPending(Serial::pendingInput)) {
int x = getQueueSize(Serial::queueInput);
cout << "queue size: " << x << endl;

while (x-- > 0)
cout.put( get() );
cout << endl;
}
...

Also, the cbInQueue with magic value -1 has special
explanation. This means that COM port is busy (or
attached to some other process).

Additional to all above the TTYSession calss has not
classificied as __EXPORT class. Do you plan rewrite it?

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.