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

Parents
  • 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;	
    	      }
    	}

  •           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

Reply
  •           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

Children
  • Hi Edvin, thanks for the reply,

    Edvin's side:

    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?

    Yes it is exactly the length i expect.

    Edvin side:

    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).

    Yes in m_tx_buffer [] is the expected value.

    In another part of the code, I continuously read the values via BLE, app_usbd_cdc_acm_write works OK. Lists all values.

    For FDS, only the last value. NRF_ERROR_BUSY reports when reading data from FDS.

  • Hi Edvin,

    I am grateful for your time.

    The problem i solved was in iterruptions.

    Best regards,

    Regio

Related