CDC failes after a device reboot

I create a CDC connection over USB (Vitual Comport) and sends data to a terminal program (as an example).

-> USBC_CDC cdc = USBClientController.StandardDevices.StartCDC();
-> cdc.Write(TempBuffer, 0, TempBuffer.Length);

This works fine.

Then I need to reboot my device - if a fatal error shows up.

-> PowerState.RebootDevice(false, 1000);

Under the reboot the ComPort goes away in the Windows Device Manager.
Then it shows up again when the device is running and CDC called again.

BUT, now I get no data in the Terminal program. Even not if the port is closed and reopened.

When I close the Terminal program and restarts it, then I cannot see the ComPort in the selection list.
But, it exists in the device manager!

I have tried with several programs and I see the same problem - the CDC is not working after a device reboot.

Same problem is seen if the USB cable is unplug and repluged.

What goes wrong?

Windows is very picky about CDC devices. You can’t reboot while connection is open.

Thats is so true…

How to shut down the CDC?

I have found examples on how to open it but not hoe to close it.

Just close the related COM port usually does work.

Do You mean on the PC side?

But how to close the CDC on the FEZ side?

I usually do not need to close it on device side. I do not think it is possible

Here is a solution:

The FEZ can reboot faster than Windows can detect a hardware change!

If one makes a 10 sec sleep before calling StartCDC

 cdc = USBClientController.StandardDevices.StartCDC();

then windows will act correctly.

If the e.g. gets a power failure, reboot or a hardware watchdog reset this will then work.