473,779 Members | 2,072 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Rea dLine, but that blocks the application and takes
a lot of time (10 seconds!), I tryed SerialPort1.Rea d, 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
Nov 21 '05 #1
6 17024
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" <pi**********@h otmail.com> wrote in message
news:O6******** ******@TK2MSFTN GP09.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.Rea dLine, but that blocks the application and
takes
a lot of time (10 seconds!), I tryed SerialPort1.Rea d, 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

Nov 21 '05 #2
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" <No******@SickO fSpam.com> wrote in message
news:%2******** *******@TK2MSFT NGP14.phx.gbl.. .
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" <pi**********@h otmail.com> wrote in message
news:O6******** ******@TK2MSFTN GP09.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.Rea dLine, but that blocks the application and
takes
a lot of time (10 seconds!), I tryed SerialPort1.Rea d, 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


Nov 21 '05 #3
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" <pi**********@h otmail.com> wrote in message
news:O6******** ******@TK2MSFTN GP09.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.Rea dLine, but that blocks the application and
takes
a lot of time (10 seconds!), I tryed SerialPort1.Rea d, 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

Nov 21 '05 #4
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.
Nov 21 '05 #5
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%******** ********@TK2MSF TNGP14.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.

Nov 21 '05 #6
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.
Nov 21 '05 #7

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

Similar topics

4
3233
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 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?
1
8486
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 C# program and see it appear in a Hyperterminal window open on comm port 2. Hyperterminal is configured with the same settings that the port 1 is opened with (see below), but I do not get an 'a', I get some funky ASCII character that looks like a...
1
8580
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 internet and msdn and found some codes and samples but they are also can't read serial port. . It was so easy in VB 6.0 with mscomm object and oncommread events but now I don't understand how it reads data from serialport. You can see the codes...
0
9815
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 image ( which i scanned using scanner ). I used serail port as well as MSCOMM control.but i couldn't get the output. Can anybody knows this and help me to sort out my problem -- it is very urgent here i am using windows 2000 professional OS and i...
13
7822
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 component, using the System.Timers.Timer it works fine) tnx in advance Jean Paul
4
4622
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 ReadBufferSize = 78k, and ReceivedBytesThreashold = 78k so that I can get the whole data with one ReadExisting() method when DataReceived event fires.
3
31283
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, 0xE3, 0xFF, 0xFF. That's the configuration:
1
1468
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, time in,time out and date.And finally import the data(hp number, car plate number....as stated earlier) into Miscrosoft Access.I have already successfully decoded the data and May I know how i can import the decoded information/data into Microsoft...
3
4381
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 into the DSIDXPort arraylist and never adds readings 2 through 16..... How can I get it to read those?
0
9636
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10306
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10075
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9931
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8961
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7485
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6727
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5504
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3632
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.