title: Send 'int' instead of ASCII characters when using C++ for serial communication
body: <p>I tried <a href="http://www.arduino.cc/playground/Interfacing/CPPWindows" rel="nofollow">the <code>Serial.cpp</code> code from Arduino's website</a>.</p>
  
  <p>I just made a couple of changes and got the code working properly. However, the issue is, the C++ code serially sends in ASCII values and not integers. For example, if I send in "5" I receive 53 at the receiver side.</p>
  
  <p>I tried changing the buffer type to an int instead of a char, but it returned an error saying:</p>
  
  <blockquote>
    <p>error C2664: 'ReadFile' : cannot convert parameter 2 from 'int' to 'LPVOID'</p>
  </blockquote>
  
  <p>Is there a way to send integers instead of ASCII values serially?</p>
  
  <p>Below is a snippet of the code.</p>
  
  <pre><code>bool Serial::WriteData(char *buffer, unsigned int nbChar)
  {
      DWORD bytesSend;
  
      //Try to write the buffer on the Serial port
      if (!WriteFile(this-&gt;hSerial, (void *)buffer, nbChar, &amp;bytesSend, 0))
      {
          //In case it don't work get comm error and return false
          ClearCommError(this-&gt;hSerial, &amp;this-&gt;errors, &amp;this-&gt;status);
  
          return false;
      }
      else
          return true;
  }
  
  
  int main() {
      // Convert from char* to wchar*
  
      char *name_ser="COM7";
      cout &lt;&lt; name_ser &lt;&lt; "(char*)" &lt;&lt; endl;
      size_t origsize=strlen(name_ser)+1;
      const size_t newsize=100;
      size_t convertedChars=0;
      wchar_t wcstring[newsize];
      mbstowcs_s(&amp;convertedChars, wcstring, origsize, name_ser, _TRUNCATE);
      wcscat_s(wcstring, L"(wchar_t*)");
      wcout&lt;&lt;wcstring&lt;&lt;endl;
  
      Serial serial(wcstring);
  
      if (serial.IsConnected()){
          while (1){
              char *chr0 = "5";
              serial.WriteData(chr0,1);
              cout&lt;&lt;chr0&lt;&lt;endl;
          }
      }
      system("pause");
      return 0;
  }
  </code></pre>