Click here to Skip to main content
14,449,906 members
Rate this:
Please Sign up or sign in to vote.
See more:
I'm having problems with serial communication.

Accordingly, I downloaded SC code
--which I presumed to be Working Perfectly, like in its Video--

from the link provided Here:

Visual Basic Serial COM Port Tutorial (Visual Studio 2010) - Part 3 - YouTube[^]

The program runs smoothly, leaving a clearly debugged Sub,
then dies, who knows where.

Is there a way to use the debugger to step-by-step, See the next step (Next Sub) where the code goes to Die?

What I have tried:

I have verified that the Subs that I know to lead up to the Crash are Clean,
but can't tell where it goes from there.
Posted
Updated 10-Feb-20 6:18am
Comments
Member 14563206 9-Feb-20 14:01pm
   
I'm glad I structured my question as I did, since it provoked this informative response.

However, I would STILL like a Direct reply to the heart of my question.

Is there a debugger option that would start where designated,
then proceed forward --stopping one line at a time--
without having to Manually put stops Everywhere?
Richard MacCutchan 10-Feb-20 11:31am
   
Member 14563206 10-Feb-20 14:00pm
   
Thank you! I never would have noticed that green arrow, if you hadn't brought my attention to it.
Rate this:
Please Sign up or sign in to vote.

Solution 2

Stepping through VB code can be done with breakpoints and F11 executes a single step. You can step through both your main thread and worker threads, even those you didn't implicitly create, by using the 'Thread' drop down box right under your Start/Stop/Continue button.
   
Rate this:
Please Sign up or sign in to vote.

Solution 1

Quote:
Accordingly, I downloaded SC code
--which I presumed to be Working Perfectly, like in its Video--

Well, there is your first mistake.
Quote:
The program runs smoothly, leaving a clearly debugged Sub,

There is your second.
Quote:
Is there a way to use the debugger to step-by-step, See the next step (Next Sub) where the code goes to Die?

And the third one.

Just because a method doesn't fall over immediately, just because it seems to work in a video (particularly a YouTube video) doesn't mean it does what you want it to, or what you need to to in order to work with your code. Debugging is a much more complicated process than "it didn't crash when it ran".

And one of the problems with serial communications is that received data does not "arrive" on the main thread - it uses a totally different thread to pass you each character as it arrives. So "predicting the next sub" the code will execute is meaningless, because as soon as you introduce serial data, your thread becomes multithreader, and the concept of "next" because very vague: the next executed code could happen before, during, or after the current line of code and you can't control that.

And debugging multithreaded apps is a lot more complicated! Start here: Learn to debug multithreaded applications - Visual Studio | Microsoft Docs[^] and here: Debug multithreaded applications - Visual Studio | Microsoft Docs[^] and begin reading!
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100