2020-08-21 11:20 AM
I am trying to send data to the console using the "echo" method.
static int8_t CDC_Receive_FS(uint8_t* Buf, uint32_t *Len)
{
CDC_Transmit_FS(Buf,*Len);
USBD_CDC_SetRxBuffer(&hUsbDeviceFS, &Buf[0]);
USBD_CDC_ReceivePacket(&hUsbDeviceFS);
return (USBD_OK);
}
I pass a random value but I see a doubled value in the terminal.
How can I fix it?
2020-08-21 04:00 PM
Another terminal program works correctly.
Apparently the problem is in the program settings, but in which ones?
I kind of tried all the settings.
2020-08-22 08:08 AM
If I transfer to the port in this way
uint8_t str[11] = "Hello STM32";
void StartDefaultTask(void *argument)
{
MX_USB_DEVICE_Init();
for(;;)
{
CDC_Transmit_FS(str,11);
osDelay(5000);
}
}
it's ok.
I don’t understand anything. Where to look for a problem in the terminal program or in the microcontroller code?
2020-08-22 02:40 PM
Double text is shown because the particular terminal has "local echo" turned on. Typically it should be turned off and only received text should be displayed. Tera Term and Putty are the industry standard and probably the best terminals.
Also Telnet protocol has an ability to negotiate echoing on remote side:
2020-08-22 03:43 PM
That is, if I transmit data in this way
uint8_t str[11] = "Hello STM32";
void StartDefaultTask(void *argument)
{
MX_USB_DEVICE_Init();
for(;;)
{
CDC_Transmit_FS(str,11);
osDelay(5000);
}
}
then there is no echo in all programs. And if I send data immediately in the receive function (callback)
static int8_t CDC_Receive_FS(uint8_t* Buf, uint32_t *Len)
{
CDC_Transmit_FS(Buf,*Len);
USBD_CDC_SetRxBuffer(&hUsbDeviceFS, &Buf[0]);
USBD_CDC_ReceivePacket(&hUsbDeviceFS);
return (USBD_OK);
}
then the echo turns on?
There is no logic in this.
2020-08-22 03:59 PM
"Local echo" means that the application just printed out the text you sent from the application. And after that it also printed the text it received from the remote device, which in this case is just a mirror.
2020-08-22 04:46 PM
Got it.
But that wasn't the problem.
The point is that I am writing a program to transfer data from a controller to a computer via USB. And by chance I wrote the write() function twice in the data transfer procedure. My fault.
But I was misled by the fact that the Terminal program for some reason printed a single value instead of a double one.
The problem has been resolved.
The question is closed