Main Site Documentation

Emulator : InvalidOperationException : FEZ Panda not detected!



I’m trying to build an emulator for FEZ Panda.
When running my FEZ Panda Application I get this exception :

[quote] #### Exception System.InvalidOperationException - 0x00000000 (2) ####
#### Message: FEZ Panda not detected!
#### GHIElectronics.NETMF.FEZ._Checker::.cctor [IP: 000c] ####
An unhandled exception of type ‘System.InvalidOperationException’ occurred in FEZPanda_GHIElectronics.NETMF.FEZ.dll[/quote]

The application still runs but I would like to eliminate this ugly exception. Is there a way to fake this in the emulator ?

After looking at the GHIElectronics.NETMF.FEZ._Checker::.cctor code seems like it expects SystemInfo.SystemID.Model to return 1 but it returns 2 witch corresponds to FEZ Domino :

public enum FEZ_Type : byte
    Cobra = 3,
    Domino = 2,
    Mini = 1,
    Rhino = 4,
    Unknown = 0

Is there a way to make the emulator return 1 for SystemInfo.SystemID.Model


The emulator that ships with the .NETMF SDK only covers the base .NETMF API. If you want it to emulate GHI classes then you have to extend the emulator yourself.


As far as I know, you can modify the emulator anyway you like but I do not think I have tried to change system info.

This is a very useful project you are doing and GHI will support you a lot of you get it going…points gifts…free boards :wink:

Same for anyone helps in making this happen.


I ordered a FEZ Panda and a 128x64 LCD and it will take a while before I’ll get them because not only it isn’t available yet but also I live in France …
Meanwhile I intend to make an emulator for Panda and the LCD to play with it before I get the real thing.


After finding out how to develop emulator components and how to emulate SPI the display emulation was pretty easy, it worked the first time.

Next I’ll develop a Joystick Shield (like the one on SFE) emulator and then try to make a little game, maybe a Nibbles/Snake one.

So I’m going to cancel my FEZ Panda order … just kidding :smiley:


You maybe new to fez but I am sure you are a very experienced c# programmer. Great to have you aboard :slight_smile:


Yeah, Gus said it twice he was so impressed.

Awesome work. Can someone hand Randoom some bonus points as soon as he publishes this ?!

Also Gus, can you organise to hold off sending him the Panda so there’s more time for this work to progress? ;D

Personally speaking Randoom, I’ve always thought it’d be great to be able to figure out how to do what you’re doing. Then building the emulation bits for things like 1-wire devices etc so that you get a dial to control the return value - I’m a hopeless programmer so can’t help, but if it helps I will share some test code with you. I’ve just bought Jens Kuhner’s book (don’t yet have it) that apparently has a lot of content on custom emulator configs, so perhaps there’ll be a time when I can assist more.


Very impressive work, can’t wait to see the source for it.


I managed to fake the value returned by SystemInfo.SystemID.Model on the emulator and the exception is gone.

How did I do it (FEZ Panda checks for SystemInfo.SystemID.Model == 1):

Install .NET Micro Framework 4.1 Porting Kit

Edit the file MicroFrameworkPK_v4_1\Solutions\Windows2\TinyCLR\Various.cpp and replace

OEM_MODEL_SKU OEM_Model_SKU = { 1, 2, 3 };


OEM_MODEL_SKU OEM_Model_SKU = { 1, 1, 3 };

Rebuild :
msbuild /t:Build /p:MfSettingsFile=%spoclient%\solutions\Windows2\Windows2.settings /p:FLAVOR=Debug

In the Visual Studio emulator project replace the reference “Microsoft.SPOT.CLR” with MicroFrameworkPK_v4_1\BuildOutput\public\Debug\Server\dll\Sample.Emulator.CLR.dll


The emulator is a very intense work and we want to support anyone working on making a FEZ emulator :slight_smile:

500 points just get your started and more points come for more progress :wink:


Thank you for the points, Gus !

I want to emulate AnalogIn so I downloaded the FEZopen Firmware but I can’t fin the source code for AnalogIn in it. Is it because FEZOpen is under development or the source code for this class will never be available ?


The source code is targeted for the specific hardware and so it will not help you ion the emulator.

You only need to match the same methods we have and then fill them in anyway you like.

Maybe do the whole thing in C# so there is no need to make interops. Easier for you and everyone to enhance in future.


Last night I managed to emulate AnalogInput of Netduino :

I downloaded the firmware source witch contained the source of their API as a Visual Studio solution. When compiling a .net micro framework project there is an option in project properties to generate “stubs” witch generates some .h & .cpp files.

I copied those files to my CLR source code in MicroFrameworkPK_v4_1\Solutions\MyCLR\TinyCLR and added them to the TinyCLR.proj, then compiled it and referenced it in the emulator.

Then I modified projects MicroFrameworkPK_v4_1\CLR\Tools\EmulatorInterface & MicroFrameworkPK_v4_1\Framework\Tools\Emulator : added AnologIo.cs, IAnalogIo.cs and modified IHal.cs, Hal.cs & Emulator.cs (I did this by coping and adapting the Gpio classes/interfaces)

I just tried to do the same thing for GHIElectronics.NETMF.Hardware.dll but the source code isn’t available… So I decompiled it using Reflector and, after some modifications, I generated the stubs, copied them to my CLR project and compiled. It didn’t compile the first time so I deleted some files (TinyBooter & Touch). But when trying to use the generated dll in my emulator I get this message :

[quote]Invalid native checksum: GHIElectronics.NETMF.Hardware 0x454412FE!=0x266DE38A

Error: 96000000[/quote]

Is this because the stubs weren’t correctly generated ? Or ?


No. There is a checksum for interops that needs to match on native and managed sides


Thanks, I found it in Stubs\GHIElectronics_NETMF_Hardware.cpp

const CLR_RT_NativeAssemblyData g_CLR_AssemblyNative_GHIElectronics_NETMF_Hardware =

Now I have another problem : I get a Debug Assert Failed : value.DataSize() == 1 when calling Read(); SetLinearScale() doesn’t give any error tho …

            AnalogIn analogIn = new AnalogIn((AnalogIn.Pin)FEZ_Pin.AnalogIn.An0);
            int read = analogIn.Read();


Not sure