By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
463,088 Members | 602 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 463,088 IT Pros & Developers. It's quick & easy.

Saving Serial Port Data To File

P: 3
Hello everyone,

I generally look at Google and other websites before I post a question, but trust me I still cannot find and answer to this problem.

I'm using My problem being is that I don't know how to redirect the serial port output to a selected file. I looked in the forum but no luck.

Here is the sequence of events.

User selects a file to write to. No problem here.
Sends a command to the equipment to start outputting text. No problem here.

At the moment the text is going to text box. Is easy to wait for the output to finish and then save the file. But I do not want this. The user does not need to see the text. Just some sort of indication that data is being sent. No Problem here.

Is more like a Serial Port Data Log.

Friend Sub DataReceived(ByVal sender As Object, ByVal e As SerialDataReceivedEventArgs)

Dim newReceivedData As String

' Get data from the COM port.

newReceivedData = selectedPort.ReadExisting

' Save the number of characters received.

receivedDataLength += newReceivedData.Length

RaiseEvent UserInterfaceData("AppendToMonitorTextBox", newReceivedData, Color.Black)

' I guess I could choose to Write the line to the file instead.

Catch ex As Exception
DisplayException(ModuleName, ex)
End Try
End Sub

Any suggestions? Thanks!
Nov 23 '07 #1
Share this Question
Share on Google+
2 Replies

Expert 5K+
P: 8,434
Isn't it just a matter of opening the text file in Append mode and writing the data to it?
Nov 30 '07 #2

P: 3
Isn't it just a matter of opening the text file in Append mode and writing the data to it?
Hi Killer,

Opening the data file and appending to it is not the problem. Is just where to put the code to write to the file while the serial port is outputting data. For example
when the serialport read.existing happens then do a file writeline. That's all I need.

Thanks for your reply.
Dec 1 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.