- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Solved! Go to Solution.
- Tags:
- usb-serial SDK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Yosuke,
The API to close a device handle is CyClose (CY_HANDLE) as mentioned in section 4.7 in the USB Serial API Guide: https://www.cypress.com/file/123321/download
The reason for not closing the handle is whenever you call CyGetDeviceInfo API, a linked list is created which stores the device handle information for all the devices connected. Since we are not closing the handle, CyOpen() can use the same information and hence eliminates the need to re-create the linked list.
You can close the handle if needed. The information regarding other devices will be deleted at the time of application closure.
Regards,
Mallika
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Yosuke,
The API to close a device handle is CyClose (CY_HANDLE) as mentioned in section 4.7 in the USB Serial API Guide: https://www.cypress.com/file/123321/download
The reason for not closing the handle is whenever you call CyGetDeviceInfo API, a linked list is created which stores the device handle information for all the devices connected. Since we are not closing the handle, CyOpen() can use the same information and hence eliminates the need to re-create the linked list.
You can close the handle if needed. The information regarding other devices will be deleted at the time of application closure.
Regards,
Mallika
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for your quick reply.
Let me check my understanding is correct.
The handles are retrieved internally when cyGetDeviceInfoVidPid is called.
So ,to prevent a handle leak,cyOpen and cyClose are should be called after cyGetDeviceInfoVidPid.
Is correct?
Below is current pseudo code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Yes it seems correct. Using CyClose () shouldn't cause any issues.
Regards,
Mallika
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I tried the modified code, but the number of handles still increases with each CyGetDeviceInfoVidPid function call.
Could you please investigate if there is a problem with the CyGetDeviceInfoVidPid function?
Regards.
Yosuke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Apologies for the delay in response. Did you use Cy_Close()?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Yes, I used CyGetDeviceInfoVidPid() with CYOPEN() and CYCLOSE(),but still get a handle leak.
The handle I mean here is not the CY_HANDLE, but the handle displayed in the Task Manager.(see below https://mywindowshub.com/how-to-check-task-manager-handles-for-solving-port-exhaustion-issues-on-win... )
With each call to CyGetDeviceInfoVidPid or CyGetDeviceInfo, the number of handles increases. This means that a handle leak is occurring.
Regards.
Yosuke