Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / General / June 2005

Tip: Looking for answers? Try searching our database.

New serialport control in VS 2005??

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
seankub - 23 Jun 2005 17:48 GMT
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();
        }
    }
}
Wayne Wood - 25 Jun 2005 04:55 GMT
i wrote a very simple program about this serial port class, and it works
fine.  i used the form designer, dragged two serial port controls, then
set one "COM1" and another "COM2" via the property window: COM1 was used
to send something, and COM2 was used to receive, so i gave a receive
event handler to serial port control 2

i linked COM1 and COM2 with a cross serial line, then in my program, i
sent a string like "hello, world!" or so via COM1, then a receive event
of COM2 raised: i did receive the correct content which i sent by COM1.

now the code is not on hand, if you need, i can post in another day.

i suggest that there's really no need to use hyperterminal, if you
really want to, i remember there's a option called "hardware control" or
so, you can switch it on/off to see if it can solve your weird problem
:( another point, i suggest you use the receive event, a simple blocked
read operation may not be a good choice.  only personal opinion :(

good luck

seankub 写道:
> 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
[quoted text clipped - 38 lines]
>     }
> }
seankub - 27 Jun 2005 15:00 GMT
Can you send me the code you used?  
Thanks.

> i wrote a very simple program about this serial port class, and it works
> fine.  i used the form designer, dragged two serial port controls, then
[quoted text clipped - 59 lines]
> >     }
> > }

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.