Reset PCAN-USB initialized state by software

The free CAN Software API (Application Programming Interface) for Windows®

Reset PCAN-USB initialized state by software

Postby opelissier » Thu 18. Oct 2018, 17:22

Hello.
I develop software with PCAN-USB and PCANBasic.
Sometimes, sofware crashes (normal while developping). But PCAN-USB is not correctly disconnected because when I try to Initialize (CAN_Initialize()), I have error status.
Problem can be seen too in PCAN-View where there is a warning: "This hardware is already in use by another software!" and it is not possible to connect.
The only solution is to reboot computer.

How reset this state of "already in use" with a call to function of PCANBasic?

Thanks
opelissier
 
Posts: 1
Joined: Thu 18. Oct 2018, 17:04

Re: Reset PCAN-USB initialized state by software

Postby U.Wilhelm » Fri 19. Oct 2018, 11:36

At the latest when Visual Studio is restarted the channel should be freed. A channel remains connected as long as the owner process is valid; the device driver will automatically delete any abandoned connection, as long as this is an invalid process. If the owner process stays active at background, then the driver cannot remove the connection.
Please check within the task manager, that visual studio is not keep running after you close it (you can have several instances of it, and maybe one is not completely closed). Please be sure you are using latest version for driver and API, you can see the current versions and history of changes here. You should also check for Visual Studio updates.
--------------------------------
PEAK-System Technik
Technical Support Team
support@peak-system.com
-------------------------------
User avatar
U.Wilhelm
Sales & Support
Sales & Support
 
Posts: 1013
Joined: Fri 10. Sep 2010, 18:34
Location: Darmstadt

Re: Reset PCAN-USB initialized state by software

Postby mkitby » Wed 28. Nov 2018, 07:10

I also met this problem, and I did and checked everything like you said, but it did not work.
Last edited by M.Gerber on Tue 4. Dec 2018, 16:48, edited 2 times in total.
Reason: Removed full quote of preceding post
mkitby
 
Posts: 1
Joined: Wed 28. Nov 2018, 06:56

Re: Reset PCAN-USB initialized state by software

Postby U.Wilhelm » Wed 28. Nov 2018, 09:15

We have checked it with the latest driver and DLL Version - work without any problem - so you have to be sure that your system is up to date.
--------------------------------
PEAK-System Technik
Technical Support Team
support@peak-system.com
-------------------------------
User avatar
U.Wilhelm
Sales & Support
Sales & Support
 
Posts: 1013
Joined: Fri 10. Sep 2010, 18:34
Location: Darmstadt

Re: Reset PCAN-USB initialized state by software

Postby paulh3030 » Thu 7. Feb 2019, 17:41

I am also observing the "This hardware is already in use by another software!", but in my case the issue is even worse, as the problem does not go away when the computer is restarted. We have built an application that uses the PCAN-Basic API running on Windows 10. The latest PEAK-System_Driver-Setup.zip package was used to install the drivers (Device Manager shows the PCAN-USB driver version to be 4.1.4.16279). When the PCAN-USB (IPEH-00002021) was attached, the device was recognized by PCAN-View. At first the device seemed to work as expected, but after using it for a short time with our application, PCAN-View was no longer able to connect to it, even after restarting the computer, even after completely uninstalling the driver, and reinstalling it, and not running our application. After this a second PCAN-USB was attached, and PCAN intially was able to connect to the second device, but not the first device. After a short time, PCAN-View was not able to connect to either device, even after a device reboot. As far as I am aware, there are no services that are running that would attempt to connect to the PCAN-USB device.

I need to find a work around for this issue. How can I find additional information about what this "another software!" is? It would be nice if the error message included the PID for the "another software". How can I completely remove any settings related to PCAN-USB on my machine so that it will return to its state before anything related to PCAN-USB was ever installed?

Your prompt help will be much appreciated! Please let me know if you need any additional information from me. I have attached a screen capture of PCAN-View with the warning.
PCAN-ViewWarning.PNG
Screen capture of PCAN-View showing "This hardware is already in use by another software!" warning.
PCAN-ViewWarning.PNG (34.56 KiB) Viewed 1111 times
Last edited by paulh3030 on Thu 7. Feb 2019, 22:16, edited 1 time in total.
paulh3030
 
Posts: 5
Joined: Thu 7. Feb 2019, 16:22

Re: Reset PCAN-USB initialized state by software

Postby M.Maidhof » Thu 7. Feb 2019, 18:09

Hi,

please contact our support team by email. There are tools available, which we can send to you to check your system.

When using Windows 7, please also check your USB3 chipset drivers. The issue could also be caused by a bad USB3 chipset driver.

regards

Michael
M.Maidhof
Support
Support
 
Posts: 1171
Joined: Wed 22. Sep 2010, 13:00
Location: Darmstadt, Germany

Re: Reset PCAN-USB initialized state by software

Postby paulh3030 » Thu 7. Feb 2019, 22:55

Thank you Michael. I appreciate the quick reply. I have sent an e-mail off to technical support and look forward to working with them. - Paul
paulh3030
 
Posts: 5
Joined: Thu 7. Feb 2019, 16:22

Re: Reset PCAN-USB initialized state by software

Postby paulh3030 » Fri 8. Feb 2019, 22:21

I have contacted the support team, and while I was waiting to hear back from them, I continued to run additional experiments, and I am updating this post with some recent discoveries/observations that I have made. I am new to our project, and I have just started to familiarize myself with how our utility is built, and I discovered that there may have been a mismatch between the PCAN-Basic libraries being linked in and the associated runtime dlls. I have downloaded the latest PCAN-Basic API package, and replaced our older one with this one, and linked against the PCAN-Basic API/Win32/VC_LIB/PCANBasic.lib from that package, and ran our utility using the PCAN-Basic API/Win32/PCANBasic.dll from that package. This seemed to make things more stable, but eventually my system wound up in a state as described above where PCAN-View would warn about a connection with "another software". Even after resetting the computer, I would still see the warning. After resetting the computer a second time, the warning would usually go away, and I could continue to use the device as normal. I have found a way to reproduce this issue which involves running our software from the Visual Studio Debugger, and then pausing the software while it is running, and then stopping the software from the debugger. This causes our software to not run through its normal termination (where the PCAN library is unitialized) leaving PCAN thinking there is still an active connection. Shutting down Visual Studio, disconnecting and reconnecting the PCAN USB connection does not resolve the issue. PCAN-View continues to show the warning about a connection with "another software". While I am now able to avoid this issue most of the time and have a way to recover from it, it doesn't seem right that PCAN-View displays this warning even after the USB connection is reset. One should not have to restart the computer to resolve this. It would be good to know what it is that PCAN USB uses to determine whether or not there is an active connection.

A coworker who develops using a different machine than mine (but also Windows 10), has also experienced similar issues.

I am going to be providing this information to the support team, along with other information, and I will post back here if we find anything else that would be helpful.
paulh3030
 
Posts: 5
Joined: Thu 7. Feb 2019, 16:22

Re: Reset PCAN-USB initialized state by software

Postby K.Wagner » Mon 11. Feb 2019, 12:00

Hello,

paulh3030 wrote:Even after resetting the computer, I would still see the warning.

What do you mean with resetting? you shut-off and shut-on the computer? or you goes over Windows menu and click "re start your PC"? Note that with any WIndows 10 installation, the option for fast startup is set to on. If this is so, the PCAN-Basic connections are kept in memory so that after shutting off and on your PC you will still have the problem. Check if this is your case and disable it. Here are some struction how to do this.

paulh3030 wrote:While I am now able to avoid this issue most of the time and have a way to recover from it, it doesn't seem right that PCAN-View displays this warning even after the USB connection is reset.

Please note that the architecture of our drivers allow to work even without having an adaptor attached (for instance our Virtual drivers). Disconnecting a device from the computer doesn't means an automatic "software disconnection".

paulh3030 wrote: I have found a way to reproduce this issue which involves running our software from the Visual Studio Debugger, and then pausing the software while it is running, and then stopping the software from the debugger. This causes our software to not run through its normal termination (where the PCAN library is unitialized) leaving PCAN thinking there is still an active connection.


As in other post commented, it was possible to solve this problem over the options in Visual Studio (CAN_Initialize failing after stop debugging). Starting with VS2017 this was no possible anymore. This behavior was enhanced as part of Windows and included in the Version 1803 of Windows 10. Tests with older versions (Windows 1709) shows that the problem was not there. Microsoft changed back this behavior again in the last update, 1809. Here, the PCAN-Basic connection is removed as expected. Please check which version of Windows 10 you are using and update your system if needed.


Nevertheless, we are preparing an update in our drivers to catch this problem and to enhance finalization of connections on environments like Visual Studio
Best regards,
Keneth
K.Wagner
Software Development
Software Development
 
Posts: 640
Joined: Wed 22. Sep 2010, 12:36
Location: Darmstadt, Germany

Re: Reset PCAN-USB initialized state by software

Postby paulh3030 » Mon 11. Feb 2019, 22:52

Thank you for the helpful feedback.

K.Wagner wrote:Note that with any WIndows 10 installation, the option for fast startup is set to on. If this is so, the PCAN-Basic connections are kept in memory so that after shutting off and on your PC you will still have the problem

Very good advice. I completely forgot about the fast start up option introduced in Windows 10. I always wondered what it was about exactly, and now I have a much better idea. Disabling the Fast Start-up option now allows the PCAN to drop its connection following power cycling the computer (by resetting, I did mean to shut-off the computer and then turn it back on). This explains the caching I was observing.


K.Wagner wrote:Please note that the architecture of our drivers allow to work even without having an adaptor attached (for instance our Virtual drivers). Disconnecting a device from the computer doesn't means an automatic "software disconnection".

Okay that's fair. It would be nice if there was a convenient utility allowing one to forcibly free up a connection from "another device". One could write a script to do this, but it would be nice if there was something readily available. Such a feature could be added to PCAN-View, for instance, to force a device to be released. A button could be added to the warning message titled something like "Release Connection".

If I understand everything correctly, my system is now working as expected. Thank you for your help.
paulh3030
 
Posts: 5
Joined: Thu 7. Feb 2019, 16:22

Next

Return to PCAN-Basic



cron

This website uses cookies for analytics, for logins to the online shop and the forum, and for the handling of an order. By browsing this website you agree to the use of cookies. Detailed information on their use can be found in our privacy policy.

OKPrivacy Policy