CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9

Threaded View

  1. #1
    Join Date
    Feb 2009
    Location
    .NET3.5/Visual Studio 2008
    Posts
    5

    Serial Port Bluetooth Communication with a windows form

    Heya,

    I'm having problems trying to connect to a serial port to receive data and store it in a text file. The funny thing is it works perfectly when I step through it using breakpoints. I think I need to implement some sort of delay but thats only my best guess.

    Thanks so much!

    Chris

    Here is the code I currently have to setup the serial port:

    Code:
    private void FETT_START_RECEIVING_Click(object sender, EventArgs e) 
            {       
                SERIALPORT_1.PortName = "COM17"; 
                SERIALPORT_1.Open(); 
                SERIALPORT_1.DataReceived += new System.IO.Ports.SerialDataReceivedEventHandler(DataRecievedOnPort); 
     
               
            } 
             
            private void DataRecievedOnPort(object sender, SerialDataReceivedEventArgs e) 
            { 
                 
               SerialPort Temp = sender as SerialPort; 
               string text = Temp.ReadExisting(); 
               string path = FETT_RECEIVING_FILEBROWSING_DIALOG.SelectedPath + "\\" + "test.txt"; 
               StreamWriter tw = new StreamWriter(path); 
               tw.Write(text); 
               tw.Close(); 
               
     
            }
    Last edited by Chris.Coder; March 2nd, 2009 at 01:03 PM.

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