View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Christof Kluß Christof Kluß is offline
external usenet poster
 
Posts: 2
Default CommRead data with unknown length


Is there a way to implement a SerialPort.ReadExisting in VBA?

For NET there is

http://msdn.microsoft.com/library/sy...dexisting.aspx

Am 20-09-2012 20:37, schrieb Christof Kluß:
Hi Bruce

Am 20-09-2012 20:10, schrieb Bruce Bowler:
On Thu, 20 Sep 2012 17:13:42 +0200, Christof Kluß wrote:
How does the device terminate what ever it is it sends? If that's known,
you should be able to read a character at a time, concatenating them
together, until you get the "end of data" indicator...


I only know that the output comes in lines that end with "CRLF", but it
is not set how many lines. Perhaps I can read until long time nothing
comes (after a CRLF)? Do you have an idea how to do this?

Probably, like you said, I have to read one character at time, but how
do I know, if I am out of time?

Do
lngStatus = CommRead(intPortID, strData, 1)
buffer = buffer & strData
...
Loop Until outoftime

Christof