title: Reading Byte Data through the serial port in C++/CLI
body: <p><strong>I am trying to make an interface with another program so I have to use C++.</strong></p>
  
  <p>It's been years since I have programmed in C++ and I have been at this problem for about a week so I'm slowly starting to see how everything works.</p>
  
  <p><strong>I want to read byte data coming from a serial port device.</strong></p>
  
  <p>I have verified that I can get text through the serial port using the readline command:</p>
  
  <p>For example:</p>
  
  <pre><code>String^ message = _serialPort-&gt;Readline();
  </code></pre>
  
  <p>Is how the data is read in an example from MSDN that I got to work successfully.</p>
  
  <p>However I have tried to modify it several times and I'm having no luck coming up with something that reads the data as bytes.  (I already have conversion of byte data to string so I can actually see the bytes such as the number 15 equaling 0f in bytes.)</p>
  
  <p>Modifying the code to</p>
  
  <pre><code>wchar_t message = _serialPort-&gt;Readline();
  </code></pre>
  
  <p>gives me </p>
  
  <pre><code>error c2440: 'initializing' : cannot convert from System::String ^' to 'wchar_t'.
  </code></pre>
  
  <p>I'm not familiar with <code>Readline</code>. Is it only for strings?  I have verified that it does work with strings and if I use a serial device that sends a string the first set of code does work.</p>
  
  <p>Can someone explain what method I could use to read byte data?  Thanks.</p>