Closed larsgk closed 6 years ago
Hi again,
I did some more research on this issue (that more than me seem to have - according to some entries on mbed.org).
There are several issues (all tested on FRDM-KL25Z):
https://github.com/mbedmicro/mbed/blob/master/libraries/USBDevice/USBDevice/USBDevice.cpp#L711
https://github.com/mbedmicro/mbed/blob/master/libraries/USBDevice/USBDevice/USBDevice.cpp#L835
I am going to try to see if there is any way (maybe only for the FRDM-KL25Z board specifically) to detect if there is something connected to do a graceful startup/shutdown of the USB chain.
Also - if the code in USBDevice.cpp#L835 knows that it's pending for a long time (e.g. 20 checks..) then there should be a way to throw an exception (I know... not exception but C-style callbacks, etc.) up through the chain AS WELL as doing a graceful shutdown/reset of anything in the transfer buffer. The current mechanism leaves room for improvement at least :) - I am happy to contribute with my findings but please help me out a bit..we have to deliver 30 educational packages to a high-school soon.. based on this.
br Lars
I am wondering why the writable operation is not implemented to return something useful?
https://github.com/mbedmicro/mbed/blob/master/libraries/USBDevice/USBSerial/USBSerial.h#L99
ARM Internal Ref: IOTMORF-331
GitHib issue review: Closed due to inactivity. Please re-file if critical issues found.
Because of a blocking connect function in USBDevice ( https://github.com/mbedmicro/mbed/blob/master/libraries/USBDevice/USBDevice/USBDevice.cpp#L711 ) called from the USBCDC constructor ( https://github.com/mbedmicro/mbed/blob/master/libraries/USBDevice/USBSerial/USBCDC.cpp#L34 ), instatiating USB Serial with nothing connected on the actual port blocks execution.
I tried just commenting the while loop out and everything seems to run fine (connect/disconnect and CDC/serial communication with a host computer.
Maybe this should be solved in a different way - but especially when running on battery on KL25Z, this is a problem (the blocking).