Check if usb console is active

Hi all.

I am using the console on usb. The problem is that I would like to know when the PC is connected to be able to send messages only when it is connected (even better when the virtual serial port is open).

I have tried using this feature, but it doesn't seem to work as I hoped (try to send message without usb cable)

bool check_usb_connect()
{
    return (((sf_el_ux_comms_instance_ctrl_t *) g_sf_comms0.p_ctrl)->p_cdc != UX_NULL) ? true : false;
}

Best regards

Paolo