how to reconnect to a FX2LP device when plugged again?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

hi, i have a CY1306A in my board. i am coding in C++(Qt platform) in windows 10. i want to resist my code on re-plugging usb.

this is my code:

void MainWindow::new_Data(){// run every 40 ms with a timer trig

CCyUSBDevice USBDevice;

short int numDevices = USBDevice.DeviceCount();

    if(numDevices==1){

             if(USBDevice.IsOpen()){

        LONG length = PACKET_SIZE;

        is_ok=USBDevice.BulkInEndPt->XferData((PUCHAR)xferBuffer_in[0], length , (CCyIsoPktInfo*)0,false);

      }
}

}

but sometime it works good and some times it crashes. 

0 Likes
2 Replies
Hemanth
Moderator
Moderator
Moderator
First like given First question asked 750 replies posted

Hi,

- Is the device being used  CY7C68013A?

- I understand that new_Data() is being executed every 40mS right?

- Every time this function is run, you need to send data in xferBuffer_in of length PACKET_SIZE over the Bulk endpoint right?

- When you say "it crashes", do you mean the XferData() is returning false OR is the application crashes?

Regards,

Hemanth

Hemanth
0 Likes
Anonymous
Not applicable

yes, the device is CY7C68013A. and every 40 ms new_Data() is executed. i need to read data in xferBuffer_in of length PACKET_SIZE over the Bulk endpoint.
it crashes means application crashes.

is it possible that when the code check true the conditions and waiting for receive data, usb disconnected and it crashes.is there  any solution for this?

0 Likes