0

I'm having trouble using the port interfaces in the PP_COM_Wrapper dll that Cypress' PSOC Programmer provides. I am using a CY8CKIT-0529 PSOC 5LP prototyping kit. I am able to successfully open the port to the board and have verified that I can write to it using the USB-I2C bridge that PSOC provides. However, when I go to close the port or check if the port is open the commands returns that the port is closed. for the closeport() command it returns -1 and "Port is not opened!" For the IsPortOpen() command, it returns a 0, which means the port is closed, and no error message. I can still write to the board via I2C after running both commands. I have attached the code I am running for connecting, disconnecting, and checking the status below. Any feedback on why I am unable to close the port and why the program thinks the port is closed would be appreciated. Am I missing a use of the command?

PP_COM_Wrapper Api: Api Documentation from Cypress

Use of PP_COM_Wrapper:
PP_COM_Wrapper.PSoCProgrammerCOM_ObjectClass pp = new PSoCProgrammerCOM_ObjectClass();

Open Port:

private void dbgConnect_Click(object sender, EventArgs e)
{
    string err;
    string[] array = i2c.GetPorts();
    int hr = i2c.OpenPort(array[0]);
    err = i2c.GetLastError();
    if (!err.Equals(""))
    {
        MessageBox.Show(err, "Connection Error", MessageBoxButtons.OK);
    }

    pp.IsPortOpen(out hr, out err);
    if (!err.Equals(""))
    {
        MessageBox.Show(err, "Connection Error", MessageBoxButtons.OK);
    }
}

Is Port Open:

private void button2_Click(object sender, EventArgs e)
{
    int hr;
    string err;
    pp.IsPortOpen(out hr, out err);
    if (!err.Equals(""))
    {
        MessageBox.Show(err, "Connection Status", MessageBoxButtons.OK);
    }
    else
    {
        MessageBox.Show("Connected", "Connection Status", MessageBoxButtons.OK);
    }
}

Disconnect Port:

private void dbgDisconnect_Click(object sender, EventArgs e)
{
    string err;
    int hr = pp.ClosePort(out err);
    if (!err.Equals(""))
    {
        MessageBox.Show(err, "Connection Status", MessageBoxButtons.OK);
    }
    if (hr >= 0)
    {
        dbgStatus.BackColor = Color.Red;
    }
}
Richard Matsen
  • 20,671
  • 3
  • 43
  • 77
Parker
  • 1
  • 3
  • Check Device Manager and Make sure you are using Cypress Driver and not the standard Microsoft Driver. The Microsoft Driver may connect and send data but may not work in all modes of operation (like close). – jdweng Aug 03 '20 at 15:09
  • I checked Device Manager and am using the Cypress Drivers. I'm using the PP_COM_Wrapper dll provided by Cypress to initiate the connection. – Parker Aug 03 '20 at 15:25
  • Is dll version 3.12? http://www.appquantify.com/p93702-cypress-psoc-programmer-production.aspx and driver latest (https://www.cypress.com/documentation/software-and-drivers). You may have bugs or driver and dll may not be the same version. – jdweng Aug 03 '20 at 15:35
  • I don't see where you made the connection between `array[0]` and `pp`. It seems likely that `pp` does not have an open port, not because it has a closed port, but because it has no port at all. – Ben Voigt Aug 03 '20 at 15:39
  • I have the PSOC Programmer 3.28.7 which is the most recent release they have listed on their website. I am using the dll version that came with that download. – Parker Aug 03 '20 at 15:46
  • Ben, I didn't see that before. I changed all of the calls to only use the pp version and they all worked thank you. I will go ahead and answer my question. – Parker Aug 03 '20 at 15:55

1 Answers1

0

In my code I was using a mixture of pp calls and calls to my i2c file. My above code was opening the port in the i2c instance and using it to read/write. My disconnect and check open calls were being used by the pp instance and didn't see the open port because it was being used by the i2c call.

Parker
  • 1
  • 3