title: Reading from a serial port in UWP
body: <p>Using <code>Windows.Devices.SerialCommunication</code>, how could I read data from a serial port? </p>
  
  <p>I initialize the <code>SerialDevice</code> class, instantiate <code>DataReader</code> and <code>DataWriter</code> classes using the adequate streams of the device. I can write to the device (device does what it is intended) as </p>
  
  <pre><code>        byte[] vs = {'b','t'};
          _dataWriter.WriteBytes(vs);
          await _dataWriter.StoreAsync();
  </code></pre>
  
  <p>But I can't read the response of the device. The device definitely responds, it is specified in the device protocol (<code>CashCode</code> protocol). I communicated with the device using a.NET Framework app perfectly. </p>
  
  <p>I try to read in multiple ways, for instance I tried this: </p>
  
  <pre><code>            uint i = await _dataReader.LoadAsync(BufferSize);
              if (i &gt; 0)
                  await _dataReader.LoadAsync(i);
              _dataReader.ReadBytes(res);
  </code></pre>
  
  <p>The problem is also that I don't know the exact <code>BufferSize</code>. This never reads anything. </p>
  
  <p>I am making a <code>UWP</code> (, it has to be) app. I made a .NET framework app which works as intended, but it turns out that I can't use it in this project. The serial device is <code>Suzo Happ Bill-to-Bill unit</code>. Maybe this issue is connected with <a href="https://stackoverflow.com/questions/49256707/problems-with-serial-device-communication-in-uwp">this one</a>.</p>