CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2010
    Posts
    1

    Smile Recieving data from Serial Port

    Hi all,
    I have been struggling for a while now with using events to receive a string from a serial port and using the data inside my main function.

    To set a bit of context i am sending movements for a buggy to follow and when a movement is complete, the buggy returns a "D". When the program receives this, the next coordinate should be sent.

    I'm sure there is a tidy way of doing this avoiding global variables and i would very much appreciate it if someone with more knowledge in this area could lend a hand.

    Code available on request.

    Thanks in advance, Chris Augier.

  2. #2
    Join Date
    Nov 2002
    Location
    .NET 3.5 VS2008
    Posts
    1,039

    Re: Recieving data from Serial Port

    Quote Originally Posted by chrisaugier
    I'm sure there is a tidy way of doing this avoiding global variables and i would very much appreciate it if someone with more knowledge in this area could lend a hand.
    I don't have a lot of experience of reading from a serial port. But the way you have phrased your question suggests that you have a more general problem. The structure of your program and communication of data through the system can be independent of the target data source. The fact that you are communicating with a serial port shouldn't affect how you deal with variables. Without knowing the exact problem you are facing I would recommend object oriented principles and events for communications (You are already using events by the look of it). Are you facing a specific problem or are you just looking for some pointers to improve what you already have?

  3. #3
    Join Date
    May 2009
    Location
    Bengaluru, India
    Posts
    460

    Re: Recieving data from Serial Port

    http://www.dreamincode.net/forums/in...howtopic=35775

    this link talks abt comport read/write operation using C#...

  4. #4
    Join Date
    Nov 2007
    Location
    .NET 3.5 / VS2008 Developer
    Posts
    624

    Re: Recieving data from Serial Port

    here is a little simpler snippet on reading and writing to the serial port.

    http://www.dreamincode.net/code/snippet2764.htm
    ===============================
    My Blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured