cancel
Showing results for 
Search instead for 
Did you mean: 

USB virtual COM port hot plug problem

yesralph
Associate
Posted on October 17, 2012 at 16:58

Hi,

I have a problem while developing a USB-to-serial device and I am looking for a solution.

I successfully implemented a USB virtual COM port on STM32F407 microcontroller. I can send and receive data to/from the computer via hyperterminal program perfectly using the generic virtual COM driver provided by Windows 7. However, if I unplug the USB cable while Hyperterminal is still in ''connected'' state, the communication cannot be established when I plug it back. To resume the communication, I have to 1. disconnect Hyperterminal, 2. unplug USB cable, 3. plug it back again and then 4. connect Hyperterminal.

To clarify the situation I am in, here are two senarios:

Senario 1:

- plug USB cable

- connect Hyperterminal

- communication established successfully and worked well

- disconnect Hyperminal

- unplug USB cable

- plug USB cable back 

- connect Hyperterminal

- communication established successfully and worked well

Senario 2:

- plug USB cable

- connect Hyperterminal

- communication established successfully and worked well

- unplug USB cable

- plug USB cable back 

- Hyperminal not working (but Windows device manager sees the disappearance and reappearance of the virtual COM port)

- disconnect Hyperminal

- connect Hyperterminal (FAIL! Hyperterminal cannot connect to this virtual COM port even if device manager has it in the COM port list)

- unplug USB cable (now Hyperterminal is in disconnected state)

- plug USB cable

- connect Hyperterminal

- communication established successfully and worked well

I captured the USB traffic with SourceUSB and found that when I tried to disconnect Hyperterminal in Senario 2, it said ''No such device''.

Any suggestions are appreciated! Thanks!

Shuozhi

6 REPLIES 6
crt2
Associate II
Posted on October 18, 2012 at 13:54

I dont really see the question in your thread but I would think you'd like that once you re-plug the device would keep working without hyperterminal restart.

I dont know much about Microsoft Hyperterminal, but I would suggest you make rts-cts checks on uC and if they fail few times re-establish handshake of protocol (or maybe smarter to start with termination protocol which is followed by handshake - so terminal will drop connection and then re-establish it, as that seems to be the problem from your description). That way you might trick hyperterminal that you're now re-establishing connection and he will keep working. It would be smart to check if that is really the idea, or he just hangs up within some nifty bug.

sdellinger
Associate II
Posted on December 10, 2012 at 22:27

I'd like to know how to fix this problem too. Is it a bug in the PC Virtual Com Port Driver or a bug in the STM32 library or is it the proper behavior? Everytime you rebuild code or cycle power you have to physically unplug and replug in the USB connector, remembering to disconnect from HyperTerminal first. It should auto re-enumerate when the processor reboots but something gets in a weird state.

terence-b
Associate II
Posted on December 20, 2012 at 07:47

Hi,

I am also using this MCU, the STM32F407VGT6 to be exact, on the discovery board.

How did you modify the virtual com port example to work on this MCU please?

Thanks,

Terence

info239955_st
Associate
Posted on January 20, 2014 at 21:52

Is there still no solution???

chen
Associate II
Posted on January 21, 2014 at 11:44

''Is there still no solution???''

NO

The problem is that it is a serial port EMULATION!

You cannot unplug a serial port in real life. So there is no way to signal the terminal program that the serial port connect is closed.

The terminal program just leaves the VCP port open - even though the other end has gone.

dthedens23
Associate II
Posted on January 21, 2014 at 17:53

More to the point, it is a hyper tem problem.

Windows does send a message to all applications  WM_DEVICECHANGE

this can notifie an app of insertion or removal of USB devices.

it is up to the app to determine if the device is important to the app