PC Review


Reply
Thread Tools Rate Thread

New serialport in VS 2005

 
 
=?Utf-8?B?c2Vhbmt1Yg==?=
Guest
Posts: n/a
 
      23rd Jun 2005
I am trying to read data from com1 and I am using the new serialport control.
I downloaded the script from microsoft that does a readline from the comm
port, but I keep getting the "operation timed out" error. I then will open
up HyperTerminal and connect and the output then displays? The arguments
appear to match up between my serialport control and what is setup in
HyperTerminal. Any help would be appreciated.
Thanks.

using System;
using System.IO.Ports;

class Sample
{
public static void Main()
{
string input;

SerialPort sp = new SerialPort("COM1", 9600, Parity.None, 8,
StopBits.One);
try
{
sp.ReadTimeout = 20000;

sp.Open();

input = sp.ReadLine();

Console.WriteLine(input);
Console.ReadLine();
}

catch (TimeoutException e)
{
Console.WriteLine(e);
Console.ReadLine();
}
finally
{
sp.Close();
}
}
}
 
Reply With Quote
 
 
 
 
Supra
Guest
Posts: n/a
 
      4th Jul 2005
http://www.opennetcf.org/library/


seankub wrote:

>I am trying to read data from com1 and I am using the new serialport control.
> I downloaded the script from microsoft that does a readline from the comm
>port, but I keep getting the "operation timed out" error. I then will open
>up HyperTerminal and connect and the output then displays? The arguments
>appear to match up between my serialport control and what is setup in
>HyperTerminal. Any help would be appreciated.
>Thanks.
>
>using System;
>using System.IO.Ports;
>
>class Sample
>{
> public static void Main()
> {
> string input;
>
> SerialPort sp = new SerialPort("COM1", 9600, Parity.None, 8,
>StopBits.One);
> try
> {
> sp.ReadTimeout = 20000;
>
> sp.Open();
>
> input = sp.ReadLine();
>
> Console.WriteLine(input);
> Console.ReadLine();
> }
>
> catch (TimeoutException e)
> {
> Console.WriteLine(e);
> Console.ReadLine();
> }
> finally
> {
> sp.Close();
> }
> }
>}
>
>

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SerialPort Control in VC# Express 2005 =?Utf-8?B?QXVkaW9fRGV2ZWxvcGVy?= Microsoft C# .NET 0 18th Jul 2006 10:55 AM
.NET 2005 C++ SerialPort class awu Microsoft VC .NET 2 6th Jul 2006 07:41 AM
Bug in SerialPort Class NET 2005? aayre Microsoft Dot NET Framework 4 7th Jun 2006 02:28 AM
SerialPort read VB.Net 2005 Beta 2 Tolgay Gül Microsoft VB .NET 1 2nd Aug 2005 02:38 PM
How to read All Data from SerialPort (2005) DraguVaso Microsoft Dot NET Framework Forms 4 1st Oct 2004 11:16 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:00 PM.