The samples/subsys/usb/cdc_acm sample polls for DTR to be set then sets DCD and DSR before data can be received. On macOS sending data to the CDC ACM tty will block until this sequence is completed.
In an application where the device may be plugged and unplugged and different processes open and close the tty, a method is needed to know when DTR is set so that the application can set DCD & DSR so that data can be received. When DTR is cleared DCD & DSR must be cleared so that the process can start over.
Currently, I've implemented a timer that periodically polls the value of DTR. This seems bad for two reasons:
1) DTR may change multiple times between the polling period, complicating things.
2) Polling wastes CPU resources.
Question 1: How can an application detect DTR changes? Is there a callback that can be registered to be called on DTR change?
Question 2: Is there a configuration where DCD & DSR are automatically managed based on DTR changes?