Continuing on with testing our G120 replacement board for our existing EMX boards now that a new batch of (working) G120s has arrived, I’ve come across what is for now a show-stopper.
The EMX boards detect when they are connected (as clients) to a PC, and then when they are disconnected, however the G120 boards see the first connection, but fail to notice any subsequent disconnections.
In our case we are a custom USB device, with specific operating modes depending on whether we are connected or disconnected. However I’ve built a minimum example, based directly on the kb device example from the USBClientController Class documentation, to demonstrate the problem.
When run on an EMX, when you connect to the PC, you get a Connected (state 5), unplug and it goes to state 6, plug in again, back to 5, every time.
When run on my G120, it starts in state 6, detects the connection (state 5), but fails to see the subsequent disconnection and remains in the Connected state.
— Actually, when I started this entry, it had done this every time. I’ve now continued testing, and found that sometimes it does detect the first disconnect after start-up, sometimes even the second and third, but I’ve never seen more than that, it always gets into a state where it thinks it is constantly connected.
If someone else is able to confirm (or otherwise), that would be great. If it is only me, then perhaps I managed to get another bad module, but I really doubt that as it has behaved impeccably so far.
Note that you must be running in COM port debug mode to do this test!
using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using GHI.Premium.USBClient;
using GHI.Premium.Hardware;
namespace USBClient_Example
{
public class Program
{
public static void Main()
{
// Check debug interface
// If current debug interface is USB, It must be changed to something else before proceeding. Refer to your platform user manual to change the debug interface.
// Start keyboard
USBC_Keyboard kb = USBClientController.StandardDevices.StartKeyboard();
USBClientController.State USBState;
string s;
int i=0;
while (true)
{
// Check if connected to PC
USBState = USBClientController.GetState();
s = i++ + " USBState: " + USBState;
if (USBState == USBClientController.State.Running)
s = s + " (Connected)";
Debug.Print(s);
Thread.Sleep(1000);
}
}
}
}