message: Make _write wait for CDC transmission to finish
diff: */
  #include <sys/unistd.h>
  +#include <cmsis_os.h>
  +#include <freertos_vars.h>
  #include <usbd_cdc_if.h>
  #include <usart.h>
  #include <commands.h>
  #define UART_TX_BUFFER_SIZE 64
  static uint8_t uart_tx_buf[UART_TX_BUFFER_SIZE];
  +extern PCD_HandleTypeDef hpcd_USB_OTG_FS;
  +extern USBD_HandleTypeDef hUsbDeviceFS;
  int _write(int file, char *data, int len) {
  //number of bytes written
  @@ -49,5 +53,15 @@ int _write(int file, char *data, int len) {
  } break;
  }
  + // Wait for transmission to complete
  + USBD_CDC_HandleTypeDef* hcdc = (USBD_CDC_HandleTypeDef*)hUsbDeviceFS.pClassData;
  + while (hcdc->TxState != 0) {
  + osSemaphoreWait(sem_usb_irq, 0);
  + // We have a new incoming USB transmission: handle it
  + HAL_PCD_IRQHandler(&hpcd_USB_OTG_FS);
  + // Let the irq (OTG_FS_IRQHandler) fire again.
  + HAL_NVIC_EnableIRQ(OTG_FS_IRQn);
  + }
  +
  return written;
  }
  