I'm working USB CDC on SAM D21 Xplained Pro. My application is to read the string of data send by the host to the device and send back the same data to the host.
-I'm working using atmel studio 7.0, the code which i'm using is USB Communication Device Class (CDC) for ATSAMD21.
Here i'm using udi_cdc_read_buf(buf,size) to read the data. The problem which i'm facing is here in this call we need to set the size of data to read.
If the received data length is less or greater than the size which i set. The data loss will occur.
In my application the host send data with variable length every time. How can i fix this issue.
I was tracking down the read call iram_size_t udi_cdc_multi_read_buf(uint8_t port, void* buf, iram_size_t size) in this function i'm getting complete string from the host in "udi_cdc_rx_buf[port][buf_sel][pos] " in this call--> memcpy(ptr_buf, &udi_cdc_rx_buf[port][buf_sel][pos], copy_nb);
-->It will only copy the allocate size in the udi_cdc_read_buf(buf,size) to the "ptr_buf".
->Here i need to read entire string received in the "udi_cdc_rx_buf" in the read call without set the size in read call how can i do this?
->How can i read the entire data received from the host ?
Any help will be appreciated ,
Thanks in advance.