2014-02-05 02:37 AM
Hi all,
I a using an STM32F407 device with ST standard library and USB lib.In Handle_USBAsynchXfer() function in usbd_cdc_core.c file:There is a potential bug when roll-back occurs.Two pointers are used:APP_Rx_ptr_in: is incremented when data received over UARTAPP_Rx_ptr_out: is incremented when received data over UART are sent over USBLet's have an example:if APP_Rx_ptr_in = 3 and APP_Rx_ptr_out = 2047==> this means that I have received 4 data over UART (I have to send them over USB)But as states the code below if APP_Rx_ptr_out > APP_Rx_ptr_in, the size isAPP_RX_DATA_SIZE - APP_Rx_ptr_out => 2048 - 2047 = 1 !!I think it should be (APP_RX_DATA_SIZE - APP_Rx_ptr_out) + APP_Rx_ptr_inWhat do you think? #usb-cdc-vcp2014-02-05 04:38 PM
The way I've understood it from spending hours trying to understand it fully (a brief comment describing the data structures and program would sure have helped) is that APP_Rx_length is not supposed to indicate the total amount of data waiting to be sent but rather the max amount of data that can be sent without wrapping around the end of the buffer (since the code actually copying the data to the USB peripheral does not handle that case). USB_Tx_length is then calculated as the minimum of APP_Rx_length and CDC_DATA_IN_PACKET_SIZE so it may not even end up handling all bytes to the end of the buffer in one ''cycle''.
So your remaining 3 bytes will be handled once the first one at the end of the buffer is sent. This could of course hurt transfer speed by using two USB packets for data that could fit in one but it's insignificant in practice since there will be no stray bytes at the end of the buffer if you use the full bandwidth (there will always be > CDC_DATA_IN_PACKET_SIZE data in the buffer when this code is executed).2014-05-29 02:27 PM
anyone know how to send even 1 byte over usb to the pc? their application only sends over uart
2014-05-29 03:51 PM
Isn't it all pretty much encapsulate around the USART functions/interrupts that currently map to a physical serial port rather than the true virtualization you seek?
Create some input/output FIFO buffering, and map that to the DataRx / DataTx type functions.