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;
}
}
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.