You are here

CCyUSBDevice::open() got exception | Cypress Semiconductor

CCyUSBDevice::open() got exception

Summary: 1 Reply, Latest post by guyingjie_1489886 on 05 Jan 2016 12:32 PM PST
Verified Answers: 0
Last post
Log in to post new comments.
guyingjie_1489886's picture
13 posts

Hi everyone,

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
    int devnum=0;
    devHandler = new CCyUSBDevice();   //exception happens here.
    devnum=devHandler->DeviceCount(); //if I set bOpen to False, I can get this line and get devnum=1.
        return FALSE;
    return TRUE;

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.

guyingjie_1489886's picture
13 posts

The following amazingly make Open(device) work. Call from python command line.

1. devHandler=CCyUSBDevice(NULL, Cyusb_guid, False) //don't open device while create new instance

2. add some printing

3. open(0)

Looks like the printing helped. But Why?

Log in to post new comments.