PORTS Forum

Ports and Interfaces => Serial Ports => Topic started by: waqas on February 10, 2011, 02:28:55 am

Title: Writting data from serial port to a file
Post by: waqas on February 10, 2011, 02:28:55 am
Hello everyone !

I am trying to modify the code of the serial reading and displaying program ( available at :  http://lvr.com/files/com_port_terminal_cs.zip ) in such a way that it would also write the received data to a text file. I believe I need to integrate the following three code lines at different locations in the original code :

TextWriter tw = new StreamWriter("data.txt");
tw.WriteLine(newReceivedData);
tw.Close();

Can anybody help me in placing these code lines in the original code.
Thanks in advance.
Waqas
Title: Re: Writting data from serial port to a file
Post by: Jan Axelson on February 12, 2011, 09:36:39 am
You can write the data to the file any time after receiving it on the serial port and before the variable is overwritten with new received data.

Please note the file location is now http://janaxelson.com/files/com_port_terminal_cs.zip
Jan
Title: Re: Writting data from serial port to a file
Post by: mdlayt on February 16, 2011, 04:09:51 pm
And before the variable goes out of scope.