473,395 Members | 1,689 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,395 software developers and data experts.

Need help reading data from serial port please

I am trying to use code below to read data form the port. I know it is not
correct but I am not finding what I need in MSDN to help me.

private void serialPort1_DataReceived(object sender,
SerialDataReceivedEventArgs e)
{
string getRelayStates;
getRelayStates = serialPort1.ReadLine();
MessageBox.Show(getRelayStates);

Any ideas?
thanks
Nov 8 '07 #1
1 1490
CMartin,

Well, you are trying to read an entire line, but when the DataReceived
event is fired, it isn't guaranteed that an entire line is available. Can
you read one character at a time?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"CMartin" <CM*****@discussions.microsoft.comwrote in message
news:D0**********************************@microsof t.com...
>I am trying to use code below to read data form the port. I know it is not
correct but I am not finding what I need in MSDN to help me.

private void serialPort1_DataReceived(object sender,
SerialDataReceivedEventArgs e)
{
string getRelayStates;
getRelayStates = serialPort1.ReadLine();
MessageBox.Show(getRelayStates);

Any ideas?
thanks
Nov 10 '07 #2

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

Similar topics

4
by: ^CeFoS^ | last post by:
Hello to everybody, I've done an application that draws in a frame the trajectory of a robot. The robot position is readed through the serial port, and several commands are wrote through the...
5
by: Confused User | last post by:
I am working on device that utilizes a Motorola 68HC16 microcontroller. I am using an old unsupported piece of crap Whitesmith's / Intermetrics / Tasking compiler. The embedded compiler business...
1
by: bill | last post by:
Good Day, I am developing an application that utilizes the serial port. I have looked through the news groups and seen some examples. Here is my dilemna: I am creating a processing...
1
by: David | last post by:
I have written an application in VB.NET 2003 that uses the SAX serial component for RS232 communications with hardware. The program sets up 2 serial ports so that it can talk to 2 different...
3
by: ampeloso | last post by:
Hello, I am having a tough time reading from a serial port. My code allows me to ask the device for 255 bytes at 9600 baud.I have to do this many times to get all the data. 1. I make a call to...
0
by: pranavkrish | last post by:
I am using serialPort control to read data from a barcode scanner , Can you please suggest me the most reliable methof to do this. Now I generate an even based on the data received in the serial port...
0
by: RG | last post by:
I am trying to read from my serial port a 24 bit binary number. I was able to read this number as a HEX but I was getting errors as at times using the vBCrLf indicator. I also can read it as an...
9
by: Hal Vaughan | last post by:
I've done a fair amount of Googling for information on reading the serial port in C++ (and in Linux). Unfortunately, out of every 4 hits, 1 seems to be an unanswered question, 1 is someone saying,...
1
by: ghjk | last post by:
I'm trying to read sms from GSM modem using c#. my code is only working for at command. When I enter at+cmgr=1 it says"ERROR". but when i typr it hyperterminal. It is working.Could you please tell me...
6
by: anu29dolly | last post by:
Hello everyone... I have written a program to write and read data from serial port.... I am able to write 80(in binary)..and is expecting 1B but i am uable to read it... My code goes as...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
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...
0
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...

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.