AnsweredAssumed Answered

VCP Read - Still unclear

Question asked by Syed.Hasasn on Jan 5, 2016
Latest reply on Jan 6, 2016 by Clive One

I am using the STM32F072B-Discovery board and used the CDC_Standalone example to communicate with the PC using a Virtual Serial Port. I am using the VCP driver from the website.

I can send data from the microcontroller to the hyperterminal/putty running on the PC using these commands. I can see the data on the console and it works perfectly.
    memcpy(UserBuffer, "123", sizeof(char) * 3);
   USBD_CDC_SetTxBuffer(&USBD_Device, UserBuffer, 3);

Unfortunately, I am still not clear on how to read data send from hyperterminal/putty to the microcontroller.
I know that I am receiving the data.

In the function CDC_Itf_Receive(), I added toggles to the LEDs and I can see the LED's toggling as I type in the putty console.

static int8_t CDC_Itf_Receive(uint8_t* Buf, uint32_t *Len)
  if (Buf[0] == '1')

  if (*Len == 1)

  HAL_UART_Transmit_DMA(&UartHandle, Buf, *Len);
  return (USBD_OK);

However, I am still unclear on how to read the data in the main() subroutine.
I know that Buf and *Len contain the information that I need in CDC_Itf_Receive() function. Should I copy those values to a global buffer and then use those values in main()

What I basically want is to monitor for any data from putty in main()



   if (LengthOfDataReceived != 0)
 if (!strcmp(BufferReceived, "ABCD"))