|
-
May 19th, 2013, 03:05 PM
#3
Thread Starter
Junior Member
Re: ReadTimeout not Working?
 Originally Posted by dbasnett
Change your Catch to this
Code:
Catch ex As TimeoutException
Debug.WriteLine(ex.Message)
Debug.WriteLine(myArray(1))
timeout = True
Beep()
In general you should not use a ReadLine in the DataReceived event handler. You are probably assuming that the handler will only be called once for the data being transmitted by your Arduino. My guess is that the event is being raised several times, but the first time it is called it is blocked, so the remaining events are queued. The code I provided will show how many times it is raised, and how many bytes are available when it is.
My debug output window shows debug messages but nothing from the debug.WriteLine method. Should I have something turned on in the VB settings to enable this?
Also it doesn't seem to be possible to set breakpoints within the catch block of code. I have also added an integer variable within this block which should get incremented and count the number of times an exception occurs. Even though the beep sounds, the variable never gets incremented. I also used a variable to count the number of times the DataReceived handler fires and it only does this once. If the ReadLine method is blocking, can a re-entrance occur on this handler? If not then it's ok in my example to use ReadLine within the handler and block for a response. At the moment, the responses from the Arduino are simple short replies to commands from the PC. I'm not downloading any data and the Arduino isn't continuously streaming information.
Last edited by Eugbug; May 19th, 2013 at 05:29 PM.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|