NCS 2.3.0 USB CDC ACM / UART: Is there a way to get a callback on DTR changes?

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?

Parents
  • Hi,

    I can only find (as you) that you need to manually call for intance the status by uart_line_ctrl_get(dev, UART_LINE_CTRL_DTR, &dtr).

    I can see that there is a callbak in cdc_acm.c where the cdc_acm_class_handle_req() handle the SET_CONTROL_LINE_STATE, but unfortunately I can't find any way to forward that other than to modify the cdc_acm class.

    Kenneth

Reply
  • Hi,

    I can only find (as you) that you need to manually call for intance the status by uart_line_ctrl_get(dev, UART_LINE_CTRL_DTR, &dtr).

    I can see that there is a callbak in cdc_acm.c where the cdc_acm_class_handle_req() handle the SET_CONTROL_LINE_STATE, but unfortunately I can't find any way to forward that other than to modify the cdc_acm class.

    Kenneth

Children
No Data
Related