title: c++ sending ascii 254 through serial communication
body: <p>I'm using the Serial.cpp code from Arduino's website.</p>
  
  <p>What I'm doing right now is using the R220HPRS Relay Switch. The problem is that the sample codes are in VB and I'm using c++. So, I read through the manual and found that by sending ASCII 254 and ASCII 1 will turn Relay 1 switch to on</p>
  
  <p>VB Example</p>
  
  <pre><code>  MSComm1.Output = Chr$(254) 'Enter Command Mode 
    MSComm1.Output = Chr$(1) 'Turn On Relay 1 
  </code></pre>
  
  <p>Then I found the Serial.cpp from Arduino's website and decided to try using it.
  And when I did, I got connect with the device (or it said it did when I ran the program), but I don't know as to how to send ASCII 254 and ASCII 1</p>
  
  <p>Here's the code
  From Serial.cpp</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;
  }
  </code></pre>
  
  <p>Main</p>
  
  <pre><code> int _tmain(int argc, _TCHAR* argv[])
  {
      printf("Welcome to the serial test app!\n\n");
  
  Serial* SP = new Serial("\\\\.\\COM3");    // adjust as needed
  
  if (SP-&gt;IsConnected())
      printf("We're connected");
  
  while(SP-&gt;IsConnected())
  {
      char *chr0 = "254";
      SP-&gt;WriteData(chr0, 1); 
      SP-&gt;WriteData(chr0, 1);
      Sleep(500);
  }
  return 0;
  }
  </code></pre>
  
  <p>I know chr0 = "254" is not ASCII, but I don't have any idea how to send ASCII 254 and ASCII 1. </p>