robustness of the PC serial link

11 Jan 2014

I have an mbed connected to a PC and use the mbed USB link for passing back-and-forth data from my real-time apps on the PC and mbed. The application requires that this communication link be robust to various anomalous datalink occurrences. Things that can go wrong are:

1) mbed loses power, but is restarted 2) PC loses power, but is restarted 3) mbed code "hangs" or crashes, but is restarted 4) PC code hangs or crashes, but is restarted 5) USB cable gets unplugged, but is replugged

Ideally, I'd like to lose data only over the period where I get the system restarted

Occasionally, I have found that the mbed-to-PC communication just wont work. The only way to get things restarted is if I unplug and replug the USB cable and restart the mbed.

When this occurs, I can see the PC mbed device in the device manager, and I can see that the mbed application is running (by checking some once-per-sec LEDs) In the mbed code. Every printf() has a "if pc.writeable()" protection so that the main mbed loop doesn't crash if the USB link goes away. The PC real-time code also runs fine, just there is no communication.

I believe the problems are that the PC opens a serial port with the correct baud rate for the mbed. I can see that the serial link opens correctly. But the mbed running application doesn't recognize that the PC serial link has been re-opened.

Anyone else ran into this?

Jim

12 Jan 2014

I have spent more than ten years supporting USB Audio recording systems and also have experience with USB communications with LPCXpresso as well as mbed. If I were you I would eliminate all other possible solutions before using a USB connection in a system if reliability is a priority.

Having said that, if you have no other choice the best thing you can do is to minimise disruptions. Try following these guidelines. Warning: I haven't done any proper scientific analysis so some might just be superstition ;-)

  • Use decent quality USB cables.
  • Use primary USB ports in preference to USB hubs
  • Use a PC which is not continually being reconfigured by connecting / disconnecting other USB devices
  • Disable power-saving / hibernation features on the PC.
  • Use a UPS if you experience frequent power interruptions at your location.
  • Make the connection between the PC and the mbed as persistent as possible

Regards, Chris Burrows

CFB Software http://www.cfbsoftware.com

12 Jan 2014

Thanks for the thorough response. USB links are ubiquitous, cheap, here to say. alas, customer requirements!

My problem is more with the PC and mbed serial links and not the USB (I think). There are three things that can go wrong: 1) PC stops (code or hardware). 2) USB cable gets unplugged (or otherwise stops), and 3) the mbed stops (its code or hardware). I'd like to be able restart the realtime process by restarting component that failed (e.g., PC, USB, or mbed).

The only reliable way I have found to restart everything, given any failure, is to turn off the mbed, unplug/replug the USB, and rerun the PC app. Then I have to restart in the order: USB, PC app, mbed. Operationally, this is pretty ugly. The client might accidently unplug his USB cable and then he cant restart the system cause he must repower things in a particular order.

I am thinking there is something in the PC mbed driver that doesn't re-acquire the USB serial interface if it is lost and then comes back. I'll do some more tinkering with the various options and see if I can get a better clue.

Jim

12 Jan 2014

The USB enumeration sequence is described in detail here. That might give you some clues of where to go looking:

http://www.lvr.com/usbcenum.htm

Also a USB protocol analyser might help - I haven't had any experience with using one of these so don't know for sure e.g.

http://www.sysnucleus.com/usbtrace_features.html

Chris.