title: Porting a C# SerialPort application to Python and PySerial with equivelant calls
body: <p>I currently have some older test application that was written in C# that I want to extend with other functionality, but utilize Python/PySerial to do it.</p>
  <p>Overall, I have found a few other helpful SO threads (example: <a href="https://stackoverflow.com/questions/26637414/c-sharp-net-serial-port-connects-doesnt-read-or-write">C# .NET serial port connects, doesn&#39;t read or write</a>), as well as the PySerial docs helpful, yet I am facing some issues with the communication. Below is an abbreviated example of how things are being passed (with some changes in the messages for IP):</p>
  <pre><code>_serialPort = new SerialPort(&quot;COM1&quot;, 115200, Parity.None, 8, StopBits.One);
  _serialPort.Handshake = Handshake.None;
  _serialPort.DtrEnable = true;
                          
  _serialPort.WriteLine(&quot;login_string&quot;);
  _serialPort.WriteLine(&quot;debug_string&quot;);
  
  _serialPort.WriteLine(&quot;a message&quot;);
  
  </code></pre>
  <p>In Python, I have:</p>
  <pre><code>import serial
  
  port = serial.Serial(
              port=&quot;COM1&quot;,
              baudrate=115200,
              bytesize=serial.EIGHTBITS,
              parity=serial.PARITY_NONE,
              stopbits=serial.STOPBITS_ONE,
              dsrdtr=True,
          )
  
  port.write(b'login_string\n')
  port.write(b'debug_string\n')
  
  port.write(b'a message\n')
  </code></pre>
  <p>I believe this is correct because I have to add the <code>\n</code> newline character at the end and convert to bytes using the prepended <code>b</code> on the string.</p>
  <p>I did try to research, and I thought I saw that strings are represented as UTF-16 in C#? Does it get converted to UTF-8? It would make sense since the bytesize is set to 8 bits.</p>
  <p>I also believe that the <code>dsrdtr</code> flag is required since <code>_serialPort.DtrEnable = true;</code> is used.</p>
  <p>I feel like this should work, but I'm not sure, and I feel like I'm just spinning my wheels at this point in an echo chamber. Thanks for all the help!</p>