CCyUSBDevice::open() got exception | Cypress Semiconductor
CCyUSBDevice::open() got exception
I wrote a python wrap for CyAPI.h and build the wrap on VC++. (not sure whether this is related to my problem.) And I am using Fx3 streamer example device as well as bootloader device.
I create a new cyusb device instance by calling new CCyUSBDevice() from Python command line, I got an exception and forced to quit python. After some debugging I found out that the exception happened when constructor function tried to open the device. If I choose not to open the device, the instance is created successfully, and I can get the device number by DeviceCount().
I am running this on winxp virtual machine and windows 7 laptop. And I tried vc++ example codes, which have no problem creating and opening instances. So I assume this must be something related to my python wrap. But the calling codes are really simple. Please take a look at the following codes.
In wrap file:
static PyObject *
do_createInstance(PyObject *self, PyObject *args)
bool ret = False;
return Py_BuildValue("O", ret?Py_True: Py_False);
In CPP file:
extern "C" bool
devHandler = new CCyUSBDevice(); //exception happens here.
devnum=devHandler->DeviceCount(); //if I set bOpen to False, I can get this line and get devnum=1.
Why VC++ can open device correctly but my python wrap can not? They are eventually calling the same function.
Can someone help me to find the cause of the error? Thank you very much.