CubeMX USB CDC VCP - Transmission problem
hello,
i am trying to send data to pc over the otg used as a virtual com port. The data is received with a terminal program (HTerm). In order to send data i am using the function CDC_Transmit_FS. For a basic test the string 'start' is sent to the pc. Therefor i use the following code. The code is implemented in the while loop of the int main function:
while(1)
{
if(((USBD_CDC_HandleTypeDef*)(hUsbDeviceFS.pClassData))->TxState==0)
{
while(CDC_Transmit_FS(((uint8_t*)&'start'),sizeof('start')) != USBD_OK);
}
}
This works and i can receive the data on the terminal program on my pc.
What doesn't work: If i try to send 'stop' after the 'start' string.
while(1)
{
if(((USBD_CDC_HandleTypeDef*)(hUsbDeviceFS.pClassData))->TxState==0)
{
while(CDC_Transmit_FS(((uint8_t*)&'start'),sizeof('start')) != USBD_OK);
}
if(((USBD_CDC_HandleTypeDef*)(hUsbDeviceFS.pClassData))->TxState==0)
{
while(CDC_Transmit_FS(((uint8_t*)&'stop'),sizeof('stop')) != USBD_OK);
}
}
what i hoped to receive is: start stop start stop start stop.... in an alternating order
but what i get is somehow confusing because now there is no order of the received data. I get start start stop start stop stop ... start and stop are in different orders
Thank you for your help!
#transmit #cubemx #cdc #vcp #cubehal