This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

USBD write

Hi,

I read data from FDS and output it to nRF USB. The output is implemented by

app_usbd_cdc_acm_write(&m_app_cdc_acm, m_tx_buffer, (sizeof(m_tx_buffer));

But I only see the last item on the output. Please, what is the problem so that I can see

the whole list on the terminals. The output via NRF_LOG_HEXDUMP_INFO is OK.

Best regards

Regio

  • It is a bit difficult to say without knowing anything about your implementation of the fds or the usb. Perhaps you can share something?

    Typical pitfalls:

    FDS not done reading/writing before you use it. Wait for the callbacks.

    How do you pass it to the usb?

  • HI Edvin,

    Thank you for your response

    The data in the FDS is read and displayed correctly.

    NRF_LOG_INFO("Start searching... \r\n");
    	
    	while (fds_record_find(read_file_id, relevant_record_key, &record_desc, &ftok) == NRF_SUCCESS)
    	{
    		err_code = fds_record_open(&record_desc, &flash_record);
    		if ( err_code != NRF_SUCCESS)
    		{
    			return err_code;		
    		}
    	
    	  memcpy(read_data, flash_record.p_data, flash_record.p_header->length_words * sizeof(uint32_t));
    	  NRF_LOG_HEXDUMP_INFO(read_data, sizeof(read_data));	
    
                   for (int i = 0; i < 6 ; i++)       
                   {
             
                    sprintf(&m_tx_buffer[i*2], "%02x", read_data[i]);
            
                   }
    
              sprintf(&m_tx_buffer[12], "\r\n");   
    
              app_usbd_cdc_acm_write(&m_app_cdc_acm,
                                        m_tx_buffer,      
                           (sizeof(read_data)*2)+2);     
                
          	  err_code = fds_record_close(&record_desc);
    	      if (err_code != NRF_SUCCESS)
    	      {
    		return err_code;	
    	      }
    	}

  • Hi

    app_usbd_cdc_acm_write from the sent code lists only the last item in the list. How to edit the code to list all items from the list?

  • Hi,

    app_usbd_cdc_acm_write() has no internal buffering, you should wait for APP_USBD_CDC_ACM_USER_EVT_TX_DONE event after sending an item. 

  •           app_usbd_cdc_acm_write(&m_app_cdc_acm,
                                        m_tx_buffer,      
                           (sizeof(read_data)*2)+2);  

    what is sizeof(read_data) ini this case? Try printing it to the log. Is it the length that you expect it to be? What do you expect it to be, and what was it?

    Also, you may want to look into the sprintf() call. Try debugging and see if m_tx_buffer[] is what you expect it to be after line 21 is executed (set a breakpoint on line 23).

    Best regards,

    Edvin

Related