Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

USB Serial constructor blocking #53

Closed
larsgk opened this issue Sep 2, 2013 · 4 comments
Closed

USB Serial constructor blocking #53

larsgk opened this issue Sep 2, 2013 · 4 comments

Comments

@larsgk
Copy link

larsgk commented Sep 2, 2013

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).

@larsgk
Copy link
Author

larsgk commented Oct 25, 2013

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):

  1. if you try to construct USBSerial with nothing connected to the USB Comm port, the program hangs in a forever loop here (I commented it out to be able to do battery/wireless operation - and this seems to work quite nicely.. the device can be switched on while connected or not .. reconnects work just fine, etc.):

https://github.com/mbedmicro/mbed/blob/master/libraries/USBDevice/USBDevice/USBDevice.cpp#L711

  1. if you pull the plug while in a transfer, the program hangs in a forever "pending" loop here:

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

@larsgk
Copy link
Author

larsgk commented Feb 18, 2014

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

@ciarmcom
Copy link
Member

ciarmcom commented Aug 1, 2016

ARM Internal Ref: IOTMORF-331

@sg- sg- added enhancement and removed mirrored labels Aug 12, 2016
hasnainvirk pushed a commit to hasnainvirk/mbed-os that referenced this issue Feb 12, 2017
… from a1982c1..e125164

e125164 Check secure session pointer in timer callback (ARMmbed#61)
f49e596 Update unit tests (ARMmbed#59)
6a5634a Support for multiple virtual services (ARMmbed#58)
7fe6b98 Remove yotta files (ARMmbed#57)
5c5c8fe Fix socket send return value overflow (ARMmbed#56)
0870d05 Update unit test stubs to match latest socket api (ARMmbed#55)
e687be8 Merge pull request ARMmbed#54 from ARMmbed/warn_fixes
b8fe613 updated unittests
8640d05 Compilation warnings fixed
eea83e5 Flag out entropy source addition (ARMmbed#53)
7d72eb4 Fix unittests (ARMmbed#52)
4a6991e Avoid referencing ns_msghdr_t::flags

git-subtree-dir: features/nanostack/FEATURE_NANOSTACK/coap-service
git-subtree-split: e125164
SeppoTakalo pushed a commit that referenced this issue Mar 16, 2017
…8c23..af5f59cd2

af5f59cd2 Add CMakeLists.txt to support PAL Tools (#61)
24e16e766 Fix header documentation (#58)
23ea8f51c Update README.md (#57)
99aaa6eef Provide environment-agnostic configuration macros. (#54)
da9eb9f3a Merge pull request #53 from ARMmbed/max_trace_level
0a51dcae8 Flash size can be limited by defining MBED_TRACE_MAX_LEVEL

git-subtree-dir: features/FEATURE_COMMON_PAL/mbed-trace
git-subtree-split: af5f59cd2cbac4064875be0c339da114d88fd5e1
@ghost
Copy link

ghost commented Oct 27, 2017

GitHib issue review: Closed due to inactivity. Please re-file if critical issues found.

@ghost ghost closed this as completed Oct 27, 2017
geky added a commit to geky/mbed that referenced this issue Aug 25, 2018
Checking for version, for OS master support
yossi2le pushed a commit to yossi2le/mbed-os that referenced this issue Jan 2, 2019
geky pushed a commit to geky/mbed that referenced this issue Jan 17, 2019
linlingao added a commit to linlingao/mbed-os that referenced this issue Jul 12, 2019
Changed LP ticker count to 32 because the effective bitcount in Mbed …
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants