- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If I open the USB Serial COM port in my terminal program and disconnect the USB, the USB Serial Port device will remain in the Windows Device Manager and the terminal program will not have any indication that the device is disconnected. If I close the terminal program, then the USB Serial Port is removed from Device Manager. This only happens with the Cypress driver. I am using version 3.13.0.59. If I change the VID to some unrecognized value in Windows and let it load the default Windows driver, I don't see this problem. Once I disconnect USB, the port is gone from Device Manager and my terminal program shows an error. I am using Windows 10 64-bit. Does anyone know why this happens? I prefer the behavior of the Windows driver. Can I change something on the CYUSBS234 config or Cypress driver to make it behave like the Windows driver?
Solved! Go to Solution.
- Labels:
-
ispn:38623:1:0
-
l1:314:1:0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
You may do this by using the "ManagementEventWatcher" class. It subscribes to temporary event notifications based on a specified event query. You can also register a callback function which get triggered when an event happens. EventArrivedEventHandler can be used for the same. Please find the example code snippet below:
string m_deviceRemovalQuery = "SELECT * FROM Win32_DeviceChangeEvent WHERE EventType = 3";
m_removalEvtWatcher = new ManagementEventWatcher(m_deviceRemovalQuery);
m_removalEvtWatcher.EventArrived += new EventArrivedEventHandler(m_removalEvtWatcher_EventArrived);
m_removalEvtWatcher.Start();
void m_removalEvtWatcher_EventArrived(object sender, EventArrivedEventArgs e)
{
}
Regards,
Keerthy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
This is a feature of the Cypress driver called port persistence. The terminal application using the COM port can continue accessing the device even if the device is disconnected and reconnected. The COM port is not lost from the device manager if the application has the device opened.
Best regards,
Srinath S
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks. How do I detect the device is disconnected in my application? I have a test app that calls SetCommMask(hComm, EV_RXCHAR); then WaitCommEvent(). After the device is disconnected, WaitCommEvent() does not return any error. Using the Windows driver, it will return an error so I know to alert the user or do some other cleanup code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
You may do this by using the "ManagementEventWatcher" class. It subscribes to temporary event notifications based on a specified event query. You can also register a callback function which get triggered when an event happens. EventArrivedEventHandler can be used for the same. Please find the example code snippet below:
string m_deviceRemovalQuery = "SELECT * FROM Win32_DeviceChangeEvent WHERE EventType = 3";
m_removalEvtWatcher = new ManagementEventWatcher(m_deviceRemovalQuery);
m_removalEvtWatcher.EventArrived += new EventArrivedEventHandler(m_removalEvtWatcher_EventArrived);
m_removalEvtWatcher.Start();
void m_removalEvtWatcher_EventArrived(object sender, EventArrivedEventArgs e)
{
}
Regards,
Keerthy