I have implemented USB cdc on a SAM4S Xplained-Pro board and it seems that I am only receiving data one byte at a time. I have a hard time convincing myself that this is by-design.
My code goes something like:
if(udi_cdc_is_rx_ready()) // check to see if data is on the rx line
receivedsize = udi_cdc_get_nb_received_data(); // get the number of bytes received
printf("Bytes Received = %d\n\r", receivedsize); // print the number of bytes received
udi_cdc_read_buf((uint8_t *) RcvBuffer, receivedsize); // read in the data on the rx line to receive buffer
udi_cdc_multi_write_buf(0, RcvBuffer, receivedsize); // echo back to the USB CDC COM port
So, when I write a single byte to the USB COM port, I get a receivedsize value of 1 and it echoes back the same byte to the USB COM port, everything is as expected.
But when I send multiple bytes i.e. "123456" to the USB COM port, I get 6 different print statements saying the received bytes is 1.
This seems inefficient as I thought cdc is based on bulk transfer. I can set my RcvBuffer size to 1 and it would still work because it seems to be interrupting for every single byte.
Does this have to do with the fact that the COM port settings is set to 8 data bits?
Thanks for any explanation: