I am using the C# API given for the CySamart dongle to send some data to the device from my PC.
Using example: CySmart API C# example
I noticed that occasionally I can't connect to the dongle port.
I get multiple errors from the API such as The port 'COM#' does not exist or port device does not exist. (In both cases, Windows show me that the port does exist and is not used by any process)
I try to disconnect using : public CyApiErr CloseCommunicator(ICySmartDongleCommunicator communicator);
and connect back, still does not work. The port is stuck.
The only solution I came up with is to disconnect the dongle physically from the port and re-plug it back.
Unfortunately, This is not a valid solution for my team.
Is there another solution for that? Some sore of API flow that will acquire the port and make it work?
Can you please tell which API you used to obtain the COM port and received the error "Com# port doesn't exist"? From what I see in the API reference guide, you need to provide the COM port in the code and then call "CyDongleInfo (string comPortName, CySmartDongleType type)".
Are you running the Notification or Scanner application examples or have you created your own custom application? If its the latter, please attach the project so that I can have a look.
If you tried to debug, please let me know which line of code is throwing the error.
The code i am using:
public bool ConnectDongle(string COMPort)
Dongle_ = new CyDongleInfo(COMPort, CyDongleInfo.CySmartDongleType.CY5677);
DongleManager_ = CySmartDongleMgr.GetInstance();
CyApiErr err = DongleManager_.TryGetCySmartDongleCommunicator(Dongle_, out Comm_);
Console.WriteLine("Dongle connect " + err.Message);
Console.WriteLine("Dongle connect err "+ err.Message);
I will try to debug again later and provide more info.
Are you saying that the function new CyDongleInfo(COMPort, CyDongleInfo.CySmartDongleType.CY5677) fails? Please attach your stack trace information when the failure occurs.