Communicating with PC

Hello there,
I am rather new to FEZ, so I understand this may well be a very ‘Newbie’ question, but here goes:

I am working with FEZ Domino and have written a program to access data from a sensor via I2C.
This is working fine.
Now I want to send this data to an Application on my PC, so as to visualize the Data using a 3D Engine.

I have looked for a way to communicate over the same USB-Cable used for deploying - the one that came with the FEZ Domino. As I understand it, I can use Virtual Serial (CDC) for that as can be read here:

So the first thing I tried was simply running the example from the TinyCLR Wiki.
This one to be precise:

using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using GHIElectronics.NETMF.USBClient;
using GHIElectronics.NETMF.Hardware;
namespace USBClient_Example
    public class Program
        public static void Main()
            // Check debug interface
            if (Configuration.DebugInterface.GetCurrent() != Configuration.DebugInterface.Port.USB1)
                throw new InvalidOperationException("Interface must be USB.");
            // Start CDC
            USBC_CDC cdc = USBClientController.StandardDevices.StartCDC_WithDebugging();
            // Send "Hello world!" to PC every second. (Append a new line too)
            byte[] bytes = System.Text.Encoding.UTF8.GetBytes("Hello world!\r\n");
            while (true)
                // Check if connected to PC
                if (USBClientController.GetState() != USBClientController.State.Running)
                    Debug.Print("Waiting to connect to PC...");
                    cdc.Write(bytes, 0, bytes.Length);

Now, when I try to step through the program using F11, it says ‘the Thread ended’ (or something to that effect), once I reach

if (Configuration.DebugInterface.GetCurrent() != Configuration.DebugInterface.Port.USB1)

I have updated my firmware and now have no idea how to fix this problem.
Am I even using the right method? I simply want to send a byte array from my FEZ Domino Application to my PC Application…

Thanks for your replies,

William Stacey wrote an awesome serial “terminal” program for us at [url][/url] . You run the CDC “server” which will open a virtual COM port on your PC. He’s got a few basic commands in there, and you can add whatever you like. The terminal client app is WinForms (I think). Crank that up and open the new virtual port, which should be listed.

Search for FezTerm on this forum and you’ll find a bunch more info.

Have fun!

Thanks for the tip, I have tried this and have gotten a little further through examining the source code of this project.

You need to manually ‘Break All’ and ‘Continure’ in VS to get it to initialize though. Would there be any way to automate this? My goal is to have the Windows Application start the FEZ Application in the background, so it would be somewhat bad if the FEZ App required manual Initialization.

Any way to perform the ‘Break All’ and ‘Continue’ by code? From the Windows Apllication perhaps?

You only have to do the manual piece if you are debugging and have the vcom port open at the same time (both over the built-in USB client). You can do CDC without debugging to avoid this, but I don’t exactly know where sample code is located. If you need to debug, just use a serial to USB adapter like this [url][/url] . I like the second approach because it keeps things simpler in code, plus I can use that adapter on any other board that has serial COM but might not have a built-in USB client.

Well, firstly, a huge thank you because I have now got communications up and running ;D
Also, as you said, if I start the FEZ Domino Application without Debugging, I do not need to manually reset.

But I do have one last question (sorry to be so persistent):
How do I compile the program into an .exe so I can have the Winows Application start it via (just an example):

 Process FEZsensorApp = new Process();

Everytime I try start the .exe (via the Explorer) from bin/Debug or bin/Release I get a Console Window with the following error:

Unhandled Exception: System.IO.FileNotFoundException: The file or assembly "Microsoft.SPOT.Native [...] could not be found"

Now, if I copy the assembly in question over to the executable’s directory instead of only referencing it as an assembly, the error message becomes the following:

Unhandled Exception: System.Security.SecurityException: ECall methods must be packaged into a system module.

Has anyone else ever encountered this? How do you go about compiling your .NET Micro Framework applications into Executables? Is that even possible?

If you are talking about your application that supposed to run on PC,then make sure you don’t reference any micro framework assemblies.

Do some homework on how NETMF is designed to work. You’re mixing apples and oranges, and assuming they grow on the same tree :wink:

[quote]You’re mixing apples and oranges, and assuming they grow on the same tree

Mixing apples and oranges is appropriate when making sangria.


Did someone say sangria? Count me in!


Okay, looking back, I realize that was rather stupid :slight_smile:

Then all that’s left to say is thanks for all the help.