1

Situtation

I have a FEZ Cobra II NET running test code. It sends data every second to a server on the LAN. The server writes the data to a text file. After 27 hours and 97,200 successful sends, the Cobra stops sending. Clearly I am not going to debug for 27 hours, and I am not sure how else to trouble shoot, because standard software trouble shooting approaches do not apply.

Question

  • If I were to write to log errors on the Cobra, how would I access them?
  • Does NETMF have application logs? How can we access them?
  • Is there an event viewer?
  • What other trouble shooting / debugging steps are viable here?

Code

public class Program
{
    private static Timer timer;
    private Network network;

    public static void Main()
    {
        Program p = new Program();
        p.network = new Network();
        p.RepeatedlySendDataToWcfService();
        Thread.Sleep(Timeout.Infinite);
    }

    private void RepeatedlySendDataToWcfService()
    {
        Program.timer = 
            new Timer(this.TimerCallback_SendSbcData, new object(), 0, 1000);            
    }

    private void TimerCallback_SendSbcData(object stateInfo)
    {
        SbcData data = new SbcData();
        this.network.Send(data);
    }
}

Search and Research

Community
  • 1
  • 1
Shaun Luttin
  • 133,272
  • 81
  • 405
  • 467
  • 2
    Can you make it send more often to see if it is related to the number of packets? – peter_mcc Apr 08 '14 at 19:53
  • @peter_mcc That's a terrific idea! It seems so obvious now that you mention it. – Shaun Luttin Apr 08 '14 at 19:54
  • 1
    "Clearly I am not going to debug for 27 hours" - Why not run the device with a debugger attached, and periodically check on it? At the very least you could check the application state once it fails, to spot variables with unexpected values for example. – Snixtor Apr 08 '14 at 21:02
  • @Snixtor That's a good idea. I will give it a go. Now, how do we remotely attach a debugger to an embedded NETMF program? – Shaun Luttin Apr 08 '14 at 21:04
  • 1
    One of the articles you linked to states "After you deploy a .NET Micro Framework application, you can debug it in Visual Studio using essentially the same techniques you would use for any other managed C# application." I would think, worst case scenario, you have to use an emulator. – Snixtor Apr 08 '14 at 21:08
  • 1
    I notice on NetMF timer examples they wrap the target method in 'new TimerCallback()'. It may just be a network blip, which a Try/Catch around the data sending should handle. You could log errors to the memory card. – WhoIsRich Apr 08 '14 at 21:21
  • @WhoIsRich If you write an answer suggesting to log errors to the memory card, then I will accept that as the answer. – Shaun Luttin Apr 08 '14 at 21:26
  • Try using WatchDog class – gandarez Jul 29 '14 at 12:20

1 Answers1

1

As the Fez has a memory card slot, you could log send errors to that:

private void TimerCallback_SendSbcData(object stateInfo)
{
    try
    {
        SbcData data = new SbcData();
        this.network.Send(data);
    }
    catch (Exception ex)
    {
        MyLogToCardMethod(ex.ToString());
    }
}

Mounting the card instructions are on the manufacturer site:

https://www.ghielectronics.com/docs/51/netmf-file-system

WhoIsRich
  • 4,053
  • 1
  • 33
  • 19
  • I know this is quite an old thread, but how about using the **Debug.Print** option while debugging? I just wanted to add this as for someone else coming to this thread, it may also be useful. –  Aug 22 '14 at 11:02