title: Powershell serial communication to teraterm
body: <p>I'm trying to create a powershell script that sends a string from 1 COM port to another one. The string should show up in a teraterm screen of the receiving port. But I can't get it to work, although it should be straight forward.
  The teraterm screen is just blank.</p>
  <p>Setup:
  I have 2 usb serial adapter (COM3, COM4), both connected with a physical serial cable.
  <a href="https://i.stack.imgur.com/MEaJu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MEaJu.png" alt="teraterm setup new-line" /></a>
  <a href="https://i.stack.imgur.com/xO2e1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xO2e1.png" alt="setup 2" /></a></p>
  <p>The powershell code:</p>
  <pre><code>[System.IO.Ports.SerialPort]::getportnames()
  #prints COM1 COM3 COM4
  
  $STX = [char] 2
  $ETX = [char] 3
  
  $port= new-Object System.IO.Ports.SerialPort COM4,9600,None,8,one
  $port.open()
  $port.Write(&quot;Hello world\r\n&quot;)
  $port.close()
  
  $port.open()
  $port.Write(&quot;Hello world\n&quot;)
  $port.close()
  
  $port.open()
  $port.Write(&quot;Hello world\r&quot;)
  $port.close()
  
  $port.open()
  $port.WriteLine(&quot;Hello world&quot;)
  $port.close()
  
  $port.open()
  $port.WriteLine($STX+&quot;Hello world&quot;+$ETX)
  $port.close()
  
  read-host
  </code></pre>
  <p>Anything I missed or any pointers?</p>
  <p>Extra info:
  Also tried sending strings with CMD and C#<br />
  <strong>We were able to send a string from an old handheld device (so cable is fine)</strong></p>