How to handle host application crash on CDC-ACM endpoint? #1426
-
IssueWhen the CDC device is connected DTR=true to start the device sending data. Normal host pc exit will set DTR=false. When a host pc application crashes the DTR remains true and usb is still mounted . OutcomeResult is the usb is assumed to be active so the CDC tx buffer will fill up. Then eventually we get a deadlock waiting for the host pc to reopen and clear out the tx buffer as it gets full. not viable solution
Ideas for solutions1- watchdog timers can reset the MCU
2- check for free space in tx fifo assume host is dead if full
3- start a timer and assume host is dead based on some activity or event in tinyusb?
4- does CDC have some sort of keep-alive message on the control endpoint that could be configured?
I am most interested in options 3 or 4 if - either are viable... Suggestions very welcome, maybe there already exists something I missed! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
CDC does not have any keep alive message that I am aware of. Worse an terminal can be left opened without sending any message for hours, though host usually received and stored all data as soon as we send it. To detect app hanging, we probably need to have an timer here. Though to make sure it is actually app hanging and not “host is just busy with other task” we can make use of notification endpoint. Notification endpoint is often used to inform host that there is new data (DSR #1417). Since notification endpoint is an interrupt one, and host guarantees (by USB spec) to check it out by defined interval 1-255 ms. If host does not, or does but not retrieve data anyway, it is probably the indication that host rx buffer is full and there is no app consuming it —> app is probably hanged and we can do self-recovery like detach/re-attach. It is still a guess work and depend on the host driver, but it better than an blindly guess one. DSE is easy enough, just a bit of tweaking and responding according to cdc acm specs and a bit of testing. Though I am behind all the schedule |
Beta Was this translation helpful? Give feedback.
CDC does not have any keep alive message that I am aware of. Worse an terminal can be left opened without sending any message for hours, though host usually received and stored all data as soon as we send it. To detect app hanging, we probably need to have an timer here. Though to make sure it is actually app hanging and not “host is just busy with other task” we can make use of notification endpoint.
Notification endpoint is often used to inform host that there is new data (DSR #1417). Since notification endpoint is an interrupt one, and host guarantees (by USB spec) to check it out by defined interval 1-255 ms. If host does not, or does but not retrieve data anyway, it is probably the i…