473,387 Members | 1,578 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to read All Data from SerialPort (2005)

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
Jul 21 '05 #1
4 3213
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&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" <pi**********@hotmail.com> wrote in message
news:O6**************@TK2MSFTNGP09.phx.gbl...
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

Jul 21 '05 #2
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.
Jul 21 '05 #3
Thanks for the info!
did you also use an SMS-Modem? Especially the Audiotel Industrial GPRS plus
Modem?

"Dick Grier" <di**************@msn.com> wrote in message
news:e%****************@TK2MSFTNGP14.phx.gbl...
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.

Jul 21 '05 #4
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.
Jul 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Don Tucker | last post by:
Hello, I am using Visual Studio .Net 2005 beta. I have my computer's two comm ports connected with a serial cable (and null modem). I'm trying to write the letter 'a' out on comm port 1 with the...
6
by: DraguVaso | last post by:
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...
1
by: Tolgay Gül | last post by:
I need some codes that able to send and read data by serialport in VB.Net 2005 beta 2. I wrote some codes and It can send data via serialport but It cannot read what I send. I have looked up on...
0
by: pandi | last post by:
Hi, I am using a check scanner.It has functions which gives output like image ,checknumber. i am using serial port to get this output in my coding. My problem is i am not able to read the display...
13
by: Jean Paul Mertens | last post by:
Hello, Someone can tell me why I dont get serial port events in a Service, I created a separate Thread to open the port but no events are coming up (the same happens when I use the timer...
4
by: chenatcr | last post by:
Hello, I added a serial-USB converter to my laptop, it appear as USB serial port COM4, and I wrote an application to read 78k data from this port. In my VC++ express code, I defined...
3
by: Adriano | last post by:
Hello, I'm developing an application in VB.NET 2005 that communicates with a device through RS232, and need to send the following sequence of hexadecimal data to the device: 0xFF, 0x01, 0xC3,...
1
by: qwer | last post by:
hi im actually doing on a SMS application using Visual Basic.Net whereby the objective is to allow the user to send a SMS to the visual basic programme and i should decode out the hp no, car plate,...
1
by: ghjk | last post by:
I'm write code to read data from GSM modem. but it couldn't read modem response. Could you please help me? I'll post my code. using System; using System.Collections.Generic; using...
3
by: cmdolcet69 | last post by:
Im trying to raed data over a com port. The data comes over the serial port as such reading CRLF reading CRLF and so on. The code below only sees the first reading CRLF and then only added that...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.