G120 not detecting USB disconnection

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)";




I just tested your code and i have the same behavior than yours.

When I wait 8-10 secondes before unplug the USB, the G120 is able to see the disconnection 2-3 times. But never more.

My config is : G120(The Cobra II board) firmware v4.2.10.1

Thisshould not be too difficult to fix. We will get back to you with an answer in few days.

I also can confirm this from my own custom design, but I did not really care because a reset fixes the problem…

“did you try turning it off and on again…”

[EDIT] and the watchdog will kick this :stuck_out_tongue:

Not an option in our production units, they remain on all the time.

In operation the user removes from USB (where they have had the latest schedules loaded), goes out in the plant and takes several thousand readings, comes back and plugs into USB where the readings are downloaded to the database, battery is recharged, and new schedules loaded, ready for the next shift.

Boot-up time is still too long, we use hibernate and only shut down if battery level becomes critical.

We don’t even have an off switch - we did have, but we’re removing them to stop operators turning off during SD writes or USB transactions.

Agree on the “not a option quote” but

How many seconds do you have? I have a 6 sec’s boot time on G120.

On the G120 I get 13 seconds from power-on until it is ready to take readings. Only 8 seconds from power-on until it first enables the display, but then it has to do some initializing of the SD card before it is ready.

Identical code on the EMX gives 14.5 seconds from power-on until ready to work, but only 6 seconds from power-on until the display lights up.

Interesting, as I was hoping the G120 would be significantly faster.

it has been fixed.
Thank for yuor feedback

We need a update for this?

1 Like

Yes, fixed means this is coming in next sdk … whenever that happens, but not too long.