Problem with USBDevice and mbed libraries.

25 Oct 2016

I'm debugging an aquisition program on a FRDM-KL25Z. It works pretty good with revisions 121 (25 May 2016) of the mbed library and revision 63 (03 May 2016) of the USBDevice library. When I switch to any newer mbed library (from 122 to the last one available: 127) it compiles with 2 warnings and the program on the PC side stops receiving data (using pyusb on linux). Do you know how to solve this?

The warning are:

Warning: Function "mbed::FunctionPointerArg1<R, void>::FunctionPointerArg1(R (*)()) [with R=void]" (declared at <a href="#" onmousedown="mbed_doc_goto('/adq-mbed-fluorextras/mbed_2241e3a39974/FunctionPointer.h', '53'); return false;">/extras/mbed_2241e3a39974/FunctionPointer.h:53</a>) was declared deprecated ("FunctionPointer has been replaced by Callback<void()> [since mbed-os-5.1]") in "USBDevice/USBSerial/USBSerial.h", Line: 59, Col: 205

Warning: Function "mbed::FunctionPointerArg1<R, void>::FunctionPointerArg1(R (*)()) [with R=void]" (declared at <a href="#" onmousedown="mbed_doc_goto('/adq-mbed-fluorextras/mbed_2241e3a39974/FunctionPointer.h', '53'); return false;">/extras/mbed_2241e3a39974/FunctionPointer.h:53</a>) was declared deprecated ("FunctionPointer has been replaced by Callback<void()> [since mbed-os-5.1]") in "USBDevice/USBAudio/USBAudio.cpp", Line: 25, Col: 233

The second time the program is compiled using the same mbed library revision, it compiles without the above exceptions, nor any errors.

The Python program on the PC side raises an usb.core.USBError after this:

    self.hid_device.read(self.endpoint.bEndpointAddress, self.packetSizeDatos)

There's no exception and the USB buffer is read when using mbed library revision 121. I'm using the classic compiler online (not the mbed-os-5.1 as stated on the warnings).

Thank you!

26 Oct 2016

I switched from hid_device.read() to hid_device.readNB() and it worked flawlessly with all latest mbed library revisions.