|
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 VB.net (2005) . 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
Try
' 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!
|
|
|
|
|
Since you're already adding the text to a TextBox, it's trivial to convert that code to write to a file instead. What's the problem? A TextBox just shows the contents of a String. A file just stores the very same String.
|
|
|
|
|
Dave, Thanks for your reply.
Well, that is what I'm trying to avoid. I do not want the text displayed while data is being output. I can do that already and save it to a file.
Right now I can stop the data from being displayed by removing the appropriate code but can't seem to figure out how to pass it to a file. What I want to do is save each port.readline() to a file file.writeline()
Is like a serial port data log. I hope this clears things a bit. Thanks.
|
|
|
|
|
Wherever you have the code to put the text in the textbox, you replace it with a call to a method that takes one or two parameters, the line to write and maybe the path to the log file. This method would open your log file, write the line, and then close the file. What's so difficult?
|
|
|
|
|
Dave,
You just answered my question. That is what I was looking for. I just didn't know where to put the code and how. Problem solved. Thanks!
|
|
|
|
|
I have to read the last 5 lines of several very very huge ASCII files, several times.
I want to see if it is possible to read only those last lines, instead of reading the whole junk data and getting to those 5 ending lines.
Could someone please help me, how to decrease this amount of waste of cpu time and un-wanted I/O?
|
|
|
|
|
Please don't cross post.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Can anyone help me to expalin how we can set and display only time value in propertygrid control in VB.net
Mahmood
|
|
|
|
|
Your object has to expose a public property that exposes a DateTime object.
If you want a custom editor to change that value, you have to make a custom UiTypeEditor, like this[^].
|
|
|
|
|
Hi All,
How to insert data into MS Project 2003 through VB 6.0 application.
Awating for your early reply.
Thanks.
Ahmed.
Ayaqoob.
|
|
|
|
|
I have a Binding source in a form. And I want to move to a Particular location in the Binding source. But I don't know the Position where to move, rather I know the Field Value of a unique field in the Records. Is there any way so that I can directly jump to that position in the binding source or I have to loop and check for that value in the records ?
Please Advice.
Thanks in Advance.
Sekhar
|
|
|
|
|
SekharOne wrote: Is there any way so that I can directly jump to that position
The binding won't find it for you. You have to know the position of the record, then tell the binding the position to use. So, yes, you have to find it yourself first.
|
|
|
|
|
hello frnd,
i have a XML document i want to read complete XML with DOM.
how can i do it...
cay code sample or link ????
thankx in advance
regards,
koolprasad2003
Be a good listener...Because Opprtunity knoughts softly...N-Joy
|
|
|
|
|
Stop cross posting the same question in multiple forums.
You've been told this repeatedly, yet you persist.
|
|
|
|
|
i want to known how we can read one by one pixels from image and compare
|
|
|
|
|
You can't - VB is crap. Your best bet is to use the code in my C# image processing articles. Otherwise you're stuck with get/setpixel, which is very slow.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Christian Graus wrote: You can't - VB is crap. Your best bet is to use the code in my C# image processing articles. Otherwise you're stuck with get/setpixel, which is very slow.
Actually it's get/setpixel that's crap not so much vb.
|
|
|
|
|
Christian's right that get/setpixel is too slow if you are manipulating alot of pixels. I did this one time by reading and writing a filestream though but this requires a little knowledge of the File format. I can give you an example for a 24 bit bitmap of how to read and write pixels that is fast if you give me a day or two. Would that help you?
|
|
|
|
|
I should ask. Are you familiar with things like file streams? If not then my example isn't going to make any sense.
|
|
|
|
|
I have written a utility that displays runing processes. The only problem that it doesn't show if I have windows explorer open in the process list. I've nnarrowed the list down to show applications that are currently running, but doesn't show any instances of Windows Explorer.
Thanks for your help.
I am always greteful for any help!
|
|
|
|
|
Well, without knowing anything about how you're enumerating the processes or where you're getting your information from, it's pretty impossible to tell you what you're doing wrong.
For soemthing like this, I'd probably use the Process class and it's GetProcesses method. This will return all running processes, including explorer.exe.
|
|
|
|
|
Thanks Dave,
I've been using the Process class and the GetProcess method. This works well but doesn't list a separate process if I have windows explorer open on a certain directory/folder. I'm trying to list all running applications including any instances of windows explorer and the folder/directory that it is pointing to.
I've read somewhere that the listing of windows explorer is a top-level listing and that is why it doesn't appear in running process.
Thanks
Graeme Guildford
I am always greteful for any help!
|
|
|
|
|
GuildfordG wrote: I'm trying to list all running applications including any instances of windows explorer and the folder/directory that it is pointing to.
Those are not seperate processes. Each is a window belonging to a single instance of explorer.exe. You have to enumerate the windows using the Shell.Application COM object and it's Windows[^] property.
|
|
|
|
|
Thanks Dave, I'll give it a go and let you know.
I am always greteful for any help!
|
|
|
|
|
Sorry Dave but I've looked everywhere for the Shell.Application COM object in Visual Basic 2005. Can you please help me to locate and use this object?
Thanks again
Graeme
I am always greteful for any help!
|
|
|
|