if you did not read it yet i sugest you had a look at
in your Transmit you shoud check that usb got connected basicaly that hUsbDevice_0 is not NULL.
also in between this 2 check and CDC_TransmitPacket use no CDC state change shoud hapen ie check and actions shall be atomic with respect to CDC events !
while executing CDC_TransmitPacket it’s best not new usb interrupt can occur or it may corrupt the internal USB controler state, i’m not sure if this happen how well the ST HAL and midleware behave
i remenber i could hangs terminal emulator (no more rx not tx) with simple loopback cdc f/w like yours why i suspect they are some races or tricky things going on the cdc class but i’m not to debug it .
I have a more complex cdc based app very stressing with free rtos i have critical section arround packet send and “shared critical” flag setup, This app brake or misbehave without the cirtical section so to me this where thing go wrongs.
status = CDC_Transmit_FS(pXFer->TxBuf, pXFer->TxLen);
vPortExitCritical(); //moving this before Tramsit cos races we get stuck
if you have 2 version one ok and not the 2nd is should be easy to spot where is the difference are no ?.