I have changed nothing , references are there, version of sdk is 4.3
using System.Threading;
using GHI.Usb;
using GHI.Usb.Client;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware.UsbClient;
public class Program
{
public static void Main()
{
// Start Cdc
Cdc vsp = new Cdc();
Controller.ActiveDevice = vsp;
// 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 (Controller.State !=
UsbController.PortState.Running)
{
Debug.Print("Waiting to connect to PC...");
}
else
{
vsp.Stream.Write(bytes, 0, bytes.Length);
}
Thread.Sleep(1000);
}
}
}
The code always crashes at âController.ActiveDevice = vsp;â
with error message: An unhandled exception of type âSystem.InvalidOperationExceptionâ occurred in GHI.Usb.dll
windows 8.1
visual studio 2012
.netmf sdk v4.3 QFE1
tinybooter v 4.3.4.0
tinyCLR v4.3.6.0
fez spider connected through the usb client dp module
Left switch of the for is set to on
Honestly i dont know what option that is: âserial to usbâ or "usb to serial"
I only found the transport option which is mentioned in the description of the sample.
Do you have Serial to USB module or any tool that let PC talks to Spider by serial? and it is connected to socket 11? I guess you do, because you can debug and see where the exception is.
If you doesnât have that module, and there are only FEZ Spider and USB Client DP, nothing is connected on socket 11, and you still can debug in VS, it means your configuration is wrong.
If the switch #4 is on then you can NOT deploy, debug by USB port. The FEZ Spider (or EMX_EMX) should not be shown on MF DEPLOY or FEZ Config.
usb to serial mode:
Default FEZ Spider is in USB debugger mode (switch 4 is off). In this mode, you can deploy, run, debug your app by USB port. If you want CDC, you have turn switch 4 is on => change from USB mode to serial mode. In this mode, as above, you can not debug in VS via USB port. If you want to debug in this, unless a Serial connection must be connect in socket 11.
Without VS, just hit reset then take a look under device mananger, you will see new Comport is displayed (or searching driver icon appears if the driver is not installed)
@ Dat - Might be worth while to add a document about serial debugging. The section on CDC in the USB Client document does not mention that serial debugging may have to be used.