/* Reads data from the serial port in a blocking manner.  */
bool SerialPortRead(uint8_t *data, uint32_t length)
/* Reads data from the serial port in a blocking manner.  */
bool SerialPortRead(uint8_t *data, uint32_t length)
{
  bool result = false;
  DWORD dwRead = 0;
  assert(data != NULL);
  assert(length > 0);
  if ( (data != NULL) && (length > 0) )
  {
    if (ReadFile(hUart, data, length, &dwRead, NULL))
    {
      if (dwRead == length)
      {
        result = true;
      }
    }
  }
  return result;
}