Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comport and unpluged USB #1

Open
RobertZawadzki opened this issue Jun 1, 2020 · 5 comments
Open

Comport and unpluged USB #1

RobertZawadzki opened this issue Jun 1, 2020 · 5 comments
Labels
help wanted Extra attention is needed

Comments

@RobertZawadzki
Copy link

Hi, folks.

Do you have an effective way to disconnect the USB cable?

Unfortunately, all solutions from internet do not work.

Regards
Robert

@CWBudde
Copy link
Owner

CWBudde commented Jun 4, 2020

The library was written when USB was not invented, so probably - if there is a way - it would require some extra work on top of this library.

Eventually it also depends on the manufacturer of the USB to serial port bridge. In my experiments with a cable like that (with a build-in converter) the disconnect was not the most critical problem. It was rather the connection itself. Eventually it was caused by an improper disconnection. I solved it by adding some timing delays (it seems to work after some delay).

This said, I would be too interested in further information on this topic.

@CWBudde CWBudde added the help wanted Extra attention is needed label Jun 4, 2020
@RobertZawadzki
Copy link
Author

Thank you for your answer,
I know that this software was developed a long time ago, but it works very well until today (except for this unfortunate USB).
I made a special LCD display based on Arduino and unfortunately sometimes someone takes out the USB plug and there is a problem.
I was making changes in CPort.pas code (exactly in AbortAllAsync procedure) to help, but it still doesn't work as it should.
After generating an exception the application is no longer stable.

If you were looking for a solution, a lot of people who use comport would be grateful.

@unreal79
Copy link

I patched AbortAllAsync in CPort.pas. I see no other way to get rid of the "Purgecomm Function Failed" error after reconnect. I replaced
raise EComPort.Create(CError_PurgeFailed, GetLastError);
instead of:
CallException(CError_PurgeFailed, GetLastError);
as stated here: https://sourceforge.net/p/comport/discussion/261327/thread/8605e2ac/ back in 2009.

@unreal79
Copy link

Looks like issue fixed more or less: https://github.com/raccoon-dev/ComPort-Library

@CWBudde
Copy link
Owner

CWBudde commented Feb 28, 2021

I have just merged the changes from raccoon-dev. Yet untested as I currently do not have a project that uses USB for ComPort emulation.

@RobertZawadzki please close if this solves your issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants