Connecting Tech Pros Worldwide Help | Site Map

How to read All Data from SerialPort (2005)

  #1  
Old November 21st, 2005, 03:10 AM
DraguVaso
Guest
 
Posts: n/a
Hi,

I'm experimenting with the Serial Port in VB.NET 2005. Although it isn't
that easy to get any feedback from my COM-port as I thought it would be...

How can I read all the Data that the port sends back?

I tryed with SerialPort1.ReadLine, but that blocks the application and takes
a lot of time (10 seconds!), I tryed SerialPort1.Read, but I have to read it
into a buffer and has to indicate the count, but how do I know this?

Does anybody knows a nice way to send and receive smoothly all the data from
the SerialPort?

Thanks a lot in advance,

Pieter


  #2  
Old November 21st, 2005, 03:11 AM
Altman
Guest
 
Posts: n/a

re: How to read All Data from SerialPort (2005)


Have you looked at Microsoft comm control activeX. It makes it real easy to
communicate to the serial port. Once you are connected you set the output
property to what you are sending and then the input property contains what
has been sent back.



"DraguVaso" <pietercoucke@hotmail.com> wrote in message
news:O65VF0hpEHA.1816@TK2MSFTNGP09.phx.gbl...[color=blue]
> Hi,
>
> I'm experimenting with the Serial Port in VB.NET 2005. Although it isn't
> that easy to get any feedback from my COM-port as I thought it would be...
>
> How can I read all the Data that the port sends back?
>
> I tryed with SerialPort1.ReadLine, but that blocks the application and
> takes
> a lot of time (10 seconds!), I tryed SerialPort1.Read, but I have to read
> it
> into a buffer and has to indicate the count, but how do I know this?
>
> Does anybody knows a nice way to send and receive smoothly all the data
> from
> the SerialPort?
>
> Thanks a lot in advance,
>
> Pieter
>
>[/color]


  #3  
Old November 21st, 2005, 03:11 AM
Jay B. Harlow [MVP - Outlook]
Guest
 
Posts: n/a

re: How to read All Data from SerialPort (2005)


Altman,
VS.NET 2005 has a managed SerialPort class (aka comm), no need for an
activeX control.

http://msdn2.microsoft.com/library/30swa673.aspx

The new SerialPort class appears to be even easier then the old activeX comm
control! At the very least you are NOT dealing with COM interop!

Unfortunately I have not used it much yet to answer DraguVaso's question.

Hope this helps
Jay

"Altman" <NotGiven@SickOfSpam.com> wrote in message
news:%23YdPgoipEHA.800@TK2MSFTNGP14.phx.gbl...[color=blue]
> Have you looked at Microsoft comm control activeX. It makes it real easy
> to communicate to the serial port. Once you are connected you set the
> output property to what you are sending and then the input property
> contains what has been sent back.
>
>
>
> "DraguVaso" <pietercoucke@hotmail.com> wrote in message
> news:O65VF0hpEHA.1816@TK2MSFTNGP09.phx.gbl...[color=green]
>> Hi,
>>
>> I'm experimenting with the Serial Port in VB.NET 2005. Although it isn't
>> that easy to get any feedback from my COM-port as I thought it would
>> be...
>>
>> How can I read all the Data that the port sends back?
>>
>> I tryed with SerialPort1.ReadLine, but that blocks the application and
>> takes
>> a lot of time (10 seconds!), I tryed SerialPort1.Read, but I have to read
>> it
>> into a buffer and has to indicate the count, but how do I know this?
>>
>> Does anybody knows a nice way to send and receive smoothly all the data
>> from
>> the SerialPort?
>>
>> Thanks a lot in advance,
>>
>> Pieter
>>
>>[/color]
>
>[/color]


  #4  
Old November 21st, 2005, 03:11 AM
Jay B. Harlow [MVP - Outlook]
Guest
 
Posts: n/a

re: How to read All Data from SerialPort (2005)


DraguVaso,
I have not tried the new SerialPort yet, are you using it from your
MainWindow (thread) or in a separate thread?

Looking at http://msdn2.microsoft.com/library/30swa673.aspx

Have you tried handling the ReceivedEvent?

I would probably use a separate thread...

Again I have not really tried got a chance to play with it.

If you haven't you may want to ask in the VS.NET 2005 newsgroups found at:

http://communities.microsoft.com/new...y&amp;slcid=us

The bottom of the intro has instructions on how to use the newsgroups via
Outlook Express instead of the web interface.

Hope this helps
Jay


"DraguVaso" <pietercoucke@hotmail.com> wrote in message
news:O65VF0hpEHA.1816@TK2MSFTNGP09.phx.gbl...[color=blue]
> Hi,
>
> I'm experimenting with the Serial Port in VB.NET 2005. Although it isn't
> that easy to get any feedback from my COM-port as I thought it would be...
>
> How can I read all the Data that the port sends back?
>
> I tryed with SerialPort1.ReadLine, but that blocks the application and
> takes
> a lot of time (10 seconds!), I tryed SerialPort1.Read, but I have to read
> it
> into a buffer and has to indicate the count, but how do I know this?
>
> Does anybody knows a nice way to send and receive smoothly all the data
> from
> the SerialPort?
>
> Thanks a lot in advance,
>
> Pieter
>
>[/color]


  #5  
Old November 21st, 2005, 03:12 AM
Dick Grier
Guest
 
Posts: n/a

re: How to read All Data from SerialPort (2005)


Hi,

You can read all AVAILABLE data. You should read data as it is acquired and
buffered.

What I do is to use the OnComm receive event. I double-buffer data there
(append to a variable) until all of the data that I need has been received.
I do this by parsing (in you case, append to a string buffer, and use the
IndexOf method of the string to locate the appropriate terminating
condition), or by checking the length of the data that have been buffered.

BTW, I have examples of these sorts of things in my book (see below),
including VS 2005.

Dick

--
Richard Grier (Microsoft Visual Basic MVP)

See www.hardandsoftware.net for contact information.

Author of Visual Basic Programmer's Guide to Serial Communications, 4th
Edition ISBN 1-890422-28-2 (391 pages) published July 2004.


  #6  
Old November 21st, 2005, 03:14 AM
DraguVaso
Guest
 
Posts: n/a

re: How to read All Data from SerialPort (2005)


Thanks for the info!
did you also use an SMS-Modem? Especially the Audiotel Industrial GPRS plus
Modem?

"Dick Grier" <dick_grierNOSPAM@msn.com> wrote in message
news:e%23dN7fkpEHA.3464@TK2MSFTNGP14.phx.gbl...[color=blue]
> Hi,
>
> You can read all AVAILABLE data. You should read data as it is acquired[/color]
and[color=blue]
> buffered.
>
> What I do is to use the OnComm receive event. I double-buffer data there
> (append to a variable) until all of the data that I need has been[/color]
received.[color=blue]
> I do this by parsing (in you case, append to a string buffer, and use the
> IndexOf method of the string to locate the appropriate terminating
> condition), or by checking the length of the data that have been buffered.
>
> BTW, I have examples of these sorts of things in my book (see below),
> including VS 2005.
>
> Dick
>
> --
> Richard Grier (Microsoft Visual Basic MVP)
>
> See www.hardandsoftware.net for contact information.
>
> Author of Visual Basic Programmer's Guide to Serial Communications, 4th
> Edition ISBN 1-890422-28-2 (391 pages) published July 2004.
>
>[/color]


  #7  
Old November 21st, 2005, 03:28 AM
Dick Grier
Guest
 
Posts: n/a

re: How to read All Data from SerialPort (2005)


Hi,

I have not used an SMS modem. It shouldn't matter, though. Modems are
modems... There are individual small variations (and "funnies"), but in
general they work similarly.

Dick

--
Richard Grier (Microsoft Visual Basic MVP)

See www.hardandsoftware.net for contact information.

Author of Visual Basic Programmer's Guide to Serial Communications, 4th
Edition ISBN 1-890422-28-2 (391 pages) published July 2004.


Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
SerialPort Control in VC# Express 2005 Audio_Developer answers 0 July 18th, 2006 09:55 AM
How to read All Data from SerialPort (2005) DraguVaso answers 4 November 22nd, 2005 02:41 PM
SerialPort read VB.Net 2005 Beta 2 Tolgay Gül answers 1 November 21st, 2005 08:27 PM
How to read All Data from SerialPort (2005) DraguVaso answers 4 July 21st, 2005 06:50 PM