G120 Serial Debugging

Good to note that when serial debugging is enabled, (Mode pin P2.1 held low) you can still change the baud rate of COM1. I could not figure out for the life of me why Visual Studio randomly hangs up while debugging. Now I know. Seems VS likes COM2 @ 115200 :slight_smile:

I now check to see if MODE is low before trying to use that port. It’s an accessory port for my device / emergency debug port.
Running a G120 SoM with Not the beta firmware I’ve seen on this forum.


EDIT: Meant COM1

Good to know. Thanks for sharing.

Not sure I understand. Can you please explain?

@ Gus - I switch between USB debugging and serial debugging. As you know, when your are serial debugging, NETMF runs on COM1 at 115200. In this particular case I have MODE P2.1 pulled low. Please understand that this was not intentional. If I call the following code,

SerialPort rcu = new SerialPort("COM1", 38400);

COM1 on the G120 switches baud rates from 115200 to 38400 when it shouldn’t. At this point debugging through Visual Studio stops and I eventually get “The debugger engine failed to receive any debug events from the debugging target”. Coincidentally my code crashes elsewhere shortly thereafter unrelated to this error. Still in the testing stages of my project. I would have thought I would have received some sort of CLR_E_FAIL exception when I tried to call COM1 but I did not.

@ Gus - Also, subsequent deploy attempts fail until I hard reset the G120.

You are debugging over serial (COM1) and then you are opening COM1 in code? I agree this should raise some error but you should not use COM1 at all once you are using it for debugging, not even at 115200.

@ Gus - I agree Gus, my code was supposed to detect that serial debugging was enabled by checking the MODE pin. This is supposed to disable my class which uses COM1 for an accessory device. Sorry I did not explain it well the first time around.