How to auto open usb port after restart?

Hi

I am testing <InstallFolder>\examples\peripheral\usbd_cdc_acm project,   when I use serial tool of pc to open port, it can send or receive data.

but if I don't want to use serial tool of pc,   I  use app_usbd_cdc_acm_write() to send data out directly after restart,  and it runs here 

if (!dtr_state)
{
/*Port is not opened*/
return NRF_ERROR_INVALID_STATE;
}

, it shows port not opened.   Could somebody help me , please?

Parents
  • Hi,

    When you say "directy after restart", which restart are you referring to then? Did you reset the nRF52833, the PC with the serial tool, the serial tool itself, etc?

    Have you modified the example to call app_usbd_cdc_acm_write() somewhere else in the code? 

    You should be able to use the APP_USBD_CDC_ACM_USER_EVT_PORT_OPEN/APP_USBD_CDC_ACM_USER_EVT_PORT_CLOSE events in the event handler to determine when the port is open and ready to send data.

    Best regards,
    Jørgen

  • I see ,  when I use nRF52833 connect pc with the serial tool , fw will receive message " APP_USBD_CDC_ACM_USER_EVT_PORT_OPEN",    so  it can work,

    but   I mean that ,  if I don't  connect pc with serial tool,   how the fw get message " APP_USBD_CDC_ACM_USER_EVT_PORT_OPEN",   Is it possible to configure code to do this?

Reply Children
No Data
Related