Main Site Documentation

Debug statements firing only intermittently in .Net Micro Framework simple LED project


#1

I have a very simple .Net Micro Framework LED project (running on netmf 4.2 GHI code on an ARM Cortex-M4 CPU). Here is the relevant code:


    using Microsoft.SPOT.Hardware;

[…]


    OutputPort _RedLED;
    OutputPort _GreenLED;
    OutputPort _BlueLED;

[…]


    _RedLED = new OutputPort(GHI.Hardware.FEZCerb.Pin.PB15, false);
    _GreenLED = new OutputPort(GHI.Hardware.FEZCerb.Pin.PB14, false);
    _BlueLED = new OutputPort(GHI.Hardware.FEZCerb.Pin.PB13, false);

[…]


    for (var i = 0; i < numTimes; i++)
    {
        Debug.Print("Go white ...");
        _RedLED.Write(true);
        _GreenLED.Write(true);
        _BlueLED.Write(true);
        Thread.Sleep(2000);
        Debug.Print("Go dark ...");
        _RedLED.Write(false);
        _GreenLED.Write(false);
        _BlueLED.Write(false);
        Thread.Sleep(2000);
        Debug.Print("Go red ...");
        _RedLED.Write(true);
        Thread.Sleep(2000);
        _RedLED.Write(false);
        Debug.Print("Go green ...");
        _GreenLED.Write(true);
        Thread.Sleep(2000);
        _GreenLED.Write(false);
        Debug.Print("Go blue ...");
        _BlueLED.Write(true);
        Thread.Sleep(2000);
        _BlueLED.Write(false);
    }

When I run the code on the device the LEDs come on and off as expected but the output window in Visual Studio 2013 shows

[quote]Go white …
Go red …
Go green …
Go blue …
Go white …
Go dark …
Go red …
Go blue …
Go red …
Go green …[/quote]

Why aren’t all the debug statements making it through? Is Thread.Sleep the wrong ‘pattern’ to use?


#2

Vs2013? You’re on your own there. I have seen other people talk about missed content thru debug stream, but have not experienced it myself to comment. Can you try running mfdeploy and seeing if that repro’s there?


#3

Thanks Brett - I had forgotten about connecting mfdeploy to see the debug output. When I do the trace is even stranger, this is from one:

Go green …
Go dark …
?E?s
q??
’e
??
I)
?E?s
q??
Go dark …
?E?s
q??
Go dark …
?E?s