title: c# send command via serial port
body: <p>I have to handle a chain of four motors using a serial port.
  The user manual indicates that during initialization I need to send (for example) the strings</p>
  
  <pre><code>Z
  1ECHO
  2ECHO
  3ECHO
  4ECHO
  </code></pre>
  
  <p>And tells me to do that, in a code I do not recognize, with commands</p>
  
  <pre><code>PRINT(#128, "Z", #13)
  PRINT(#129, "ECHO", #13)
  PRINT(#130, "ECHO", #13)
  PRINT(#131, "ECHO", #13)
  PRINT(#132, "ECHO", #13)
  </code></pre>
  
  <p>To explain this, the manual also adds a sentence I do not understand: </p>
  
  <blockquote>
    <p>with the strings above you can initialize the motors via the motors
    software but a host program have to send the same commands with different
    prefix: 0, 1, 2, 3 and 4 are in fact 0x80, 0x81, 0x82, 0x83 and 0x84,
    respectively. The decimal equivalents of hexadecimal values ​​are 128,
    129, 130, 131 and 132.</p>
  </blockquote>
  
  <p>A colleague wrote a working code in Visual Basic as follows:</p>
  
  <pre><code>SerialPort.Output(chr(128) &amp; "Z" &amp; chr(13))
  SerialPort.Output(chr(129) &amp; "ECHO" &amp; chr(13))
  SerialPort.Output(chr(130) &amp; "ECHO" &amp; chr(13))
  SerialPort.Output(chr(131) &amp; "ECHO" &amp; chr(13))
  SerialPort.Output(chr(132) &amp; "ECHO" &amp; chr(13))
  </code></pre>
  
  <p>I've translated into .NET with:</p>
  
  <pre><code>SerialPort.Write((char)128 + "Z" + (char)13);
  SerialPort.Write((char)129 + "ECHO" + (char)13);
  SerialPort.Write((char)130 + "ECHO" + (char)13);
  SerialPort.Write((char)131 + "ECHO" + (char)13);
  SerialPort.Write((char)132 + "ECHO" + (char)13);
  </code></pre>
  
  <p>But it does not work.</p>
  
  <p>Now I can not try but I wonder if it can work to rewrite my code like this:</p>
  
  <pre><code>SerialPort.Write("Z" + (char)13);
  SerialPort.Write("1ECHO" + (char)13);
  SerialPort.Write("2ECHO" + (char)13);
  SerialPort.Write("3ECHO" + (char)13);
  SerialPort.Write("4ECHO" + (char)13);
  </code></pre>
  
  <p>If it will work, why does it work?
  And if it does not work, how do I correctly translate my colleague's code?</p>