message: Modify the _write lock to wait on resource instead of xfer
diff: @@ -26,25 +26,24 @@ int _write(int file, char* data, int len) {
  int written = 0;
  switch (serial_printf_select) {
  case SERIAL_PRINTF_IS_USB: {
  - // transmit over CDC
  - uint8_t status = CDC_Transmit_FS((uint8_t*)data, len);
  + // Wait for the interface to be available
  + osStatus sem_stat = osSemaphoreWait(sem_usb_tx, osWaitForever);
  + if (sem_stat == osOK) {
  + uint8_t status = CDC_Transmit_FS((uint8_t*)data, len); // transmit over CDC
  written = (status == USBD_OK) ? len : 0;
  -
  - // Wait for transmission to complete
  - osSemaphoreWait(sem_usb_tx, osWaitForever);
  + }
  } break;
  case SERIAL_PRINTF_IS_UART: {
  //Check length
  if (len > UART_TX_BUFFER_SIZE)
  return 0;
  - // memcpy data into uart_tx_buf
  - memcpy(uart_tx_buf, data, len);
  - // Start DMA background trasnfer
  - HAL_UART_Transmit_DMA(&huart4, uart_tx_buf, len);
  -
  - // Wait for the transmission to complete
  - osSemaphoreWait(sem_uart_dma, osWaitForever);
  + // Wait for the interface to be available
  + osStatus sem_stat = osSemaphoreWait(sem_uart_dma, osWaitForever);
  + if (sem_stat == osOK) {
  + memcpy(uart_tx_buf, data, len); // memcpy data into uart_tx_buf
  + HAL_UART_Transmit_DMA(&huart4, uart_tx_buf, len); // Start DMA background transfer
  + }
  } break;
  default: {
  