New topic: serial output issue
<http://forums.realsoftware.com/viewtopic.php?t=32187> Page 1 of 1 [ 3 posts ] Previous topic | Next topic Author Message pbart Post subject: serial output issuePosted: Mon Jan 25, 2010 8:46 pm Joined: Sat Oct 10, 2009 6:40 am Posts: 50 Hi all The issue is mine of course, I have hit a bit of a wall, on what I just know is a simple problem. I am reading data from the serial port, and appending it to 2 text areas. One gets all the data, the other is supposed to stop when it receives the string "Boot Mode". I am using the following code: Code:Sub DataAvailable() Dim opt As String = me.ReadAll Dim i As Integer = InStr(opt, "Boot Mode") if i =0 Then GhostOutput.AppendText opt end if Output.AppendText opt End Sub The trouble is when "Boot Mode" does not appear in opt anymore, the textarea continues to append. Can anybody suggest the best way to control the toggle. I did try using the textchange function but it caused me other problems. _________________ Regards Paul Top timhare Post subject: Re: serial output issuePosted: Mon Jan 25, 2010 11:02 pm Joined: Fri Jan 06, 2006 3:21 pm Posts: 7161 Location: Portland, OR USA Set a flag that tells you when you found the string. Code:Sub DataAvailable() Static DoneAppending as Boolean Dim opt As String = me.ReadAll Dim i As Integer = InStr(opt, "Boot Mode") if i> 0 then DoneAppending = true if not DoneAppending then GhostOutput.AppendText opt end if Output.AppendText opt End Sub Also, be aware that the entire string may not appear in the same DataAvailable event. You could get "Boot M" in one event and "ode" in the next, depending on the timing of events. You might want to append all the input you get into one big string until you find "Boot Mode". Tim Top pbart Post subject: Re: serial output issuePosted: Mon Jan 25, 2010 11:35 pm Joined: Sat Oct 10, 2009 6:40 am Posts: 50 Thanks Tim _________________ Regards Paul Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 3 posts ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
