USB trace tool

Heres a handy bit of code, for capturing debug messages from a USBizi connected via USB, It demonstrates using the MFDeploy interfaces provide by .NET, nb this is a PC Console app.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

// dll added from tools directory
using Microsoft.NetMicroFramework.Tools.MFDeployTool.Engine;
using System.Threading;

namespace MfTrace
{
    class Program
    {
        static void Main( string[] args )
        {
            // access the deploy engine
            using ( MFDeploy deploy = new MFDeploy() )
            {
                // pick up the usb devices
                IList<MFPortDefinition> portDefs = deploy.EnumPorts( TransportType.USB );
                
                // display them
                Console.WriteLine( "USB Devices:" );
                foreach ( MFPortDefinition portDef in portDefs )
                {
                    Console.WriteLine( portDef.Name );
                }

                // check if we have our device
                if ( portDefs.Count == 0 )
                {
                    Console.WriteLine( "No device found." );
                    return;
                }

                // connect to first device
                Console.WriteLine( "Connecting to " + portDefs[0].Name );

                using ( MFDevice device = deploy.Connect( portDefs[0] ) )
                {
                    Console.WriteLine( "Connection OK" );

                    // subscribe to debug events
                    device.OnDebugText += new EventHandler<DebugOutputEventArgs>( device_OnDebugText );

                    // and hang around forever
                    Thread.Sleep( Timeout.Infinite );
                }

                Console.WriteLine( "No devices found." );
            }
        }

        static void device_OnDebugText( object sender, DebugOutputEventArgs e )
        {
            Console.Write( e.Text );
            //throw new NotImplementedException();
        }
    }
}

Oh very nice, having a quick look through the MFDeploy namespace looks like USB boot loaders are going to be easy :wink:

This should be added to fez panel software :slight_smile:

hint Toshko hint :smiley:

Very nice!

Speaking of the FEZ Panel, I tried to use it and just got an exception. Anyone else?

I haven’t really looked at it, what’s the link again?

Look in the wiki at “FEZPanel”

Which board Chris? I have had it working with both domino and cobra?

Domino

I am having the same problem Chris is having when I use FEZ panel with my Domino.
I try to run the panel, and don’t see any devices. Bottom of app reads “No device”. If I ignore this and use Device->connect menu I get an exception:
System.NullReferenceException: Object reference not set to an instance of an object.
I know this tool should be self explanatory, but a little help would be appreciated.
For instance should the domino be in “normal mode” or “bootloader mode” I tried both with no difference in behavior.

Dave, do you have a second serial port? I have a feeling that’s where the issue is coming from.

Can one of the nice monkeys donate me 80 experience points for this contribution,
(actually I have been using Micro .NET for over 2 years)
so I can access the beta downloads page
cheers

Why 80? I added 100 points :slight_smile:
thanks

thanks gus