Main Site Documentation

USB trace tool


#1

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();
        }
    }
}


#2

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


#3

This should be added to fez panel software :slight_smile:


#4

hint Toshko hint :smiley:


#5

Very nice!

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


#6

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


#7

Look in the wiki at “FEZPanel”


#8

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


#9

Domino


#10

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.


#11

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


#12

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


#13

Why 80? I added 100 points :slight_smile:
thanks


#14

thanks gus