SerialPort Class

A

Aidan

Hello,

We are experiencing a strange problem. We have a thread that transmits and
receives ASCII from a remote device.

The basic flow is before transmitting we call DiscardInBuffer() and
DiscardOutBuffer(), we use the Write() method to send each character in a
buffer. The thread then checks the BytesToRead member and calls the Read()
method until a 'special character is received or a timeout elapses.

This process is repeated very 20 seconds. After a couple of days we get a
timeout whilst receiving...which could be due to the remote
device...granted...the strange thing is that after then calling the
Discard..() members the thread calls the Write() function and never returns
after the first call....an exception is not returned either....

Does anyone know if there are any issues with longterm operation of the
SerialPort class in CF 2.0 ?

Thanks in advance,

Aidan Browne
 
G

Germán Schuager

Hi,
Does your application stop or hangs?
I've experienced sudden stops (no exceptions) due to a memory leak.
I'd look for memory that is not being released somewhere.

Germán.
 
A

Aidan

Hello Germán,

The thread calling the method does hang...the rest of the application
carries on. But that is a good thought.

Thanks

Aidan
 
D

DrewCE

Are you running with the debugger attached? I've noticed strange behavior,
mainly in the form of missing or wrong bytes, when using the SerialPort
class while attached with the debugger. I've seen this on both the Compact
Framework and the desktop.

Not sure it's related to the problem you are describing, just throwing it
out there in just in case...

-Drew
 
D

Dick Grier

I don't ever use DiscardInBuffer, so I'll just offer this suggestion. Try
calling Read with a dummy buffer (the result is the same as
DiscardInBuffer).

I haven't seen what you are seeing... But, I seldom have process that run
continuously for hours, much less days.

Dick

--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
See www.hardandsoftware.net for details and contact information.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top