I am absolutely sure the port is Com13. It is the only serial port on my PC, verified with device manager.
I tried another emulator with the same result. When I say "stops", it is not the arduino itself that stops, it is the transmission of the data that stops.
Here is the output from port monitor.
[27/02/2019 16:17:13] - Open port COM13 (C:\Program Files (x86)\Arduino\java\bin\javaw.exe)
[27/02/2019 16:17:14] Read data (COM13)
48 65 6c 6c 6f 20 57 6f 72 6c 64 0d 0a 48 65 6c Hello World..Hel
6c 6f 20 57 6f 72 6c 64 0d 0a 48 65 6c 6c 6f 20 lo World..Hello
57 6f 72 6c 64 0d 0a World..
[27/02/2019 16:17:16] Read data (COM13)
48 65 6c 6c 6f 20 57 6f 72 6c 64 0d 0a Hello World..
[27/02/2019 16:17:18] Read data (COM13)
48 65 6c 6c 6f 20 57 6f 72 6c 64 0d 0a Hello World..
[27/02/2019 16:17:20] Read data (COM13)
48 65 6c 6c 6f 20 57 6f 72 6c 64 0d 0a Hello World..
[27/02/2019 16:17:22] - Close port COM13
[27/02/2019 16:17:32] - Open port COM13 (C:\Program Files (x86)\Termite\Termite.exe)
[27/02/2019 16:17:32] Read data (COM13)
48 65 6c 6c 6f 20 57 6f 72 6c 64 0d 0a 48 65 6c Hello World..Hel
6c 6f 20 57 6f 72 6c 64 0d 0a lo World..
The first OPEN at 16:17:13 is when I opened the Serial Monitor. Then you see the data 3 times before I close the serial monitor at 16:17:22. The next open is from the terminal emulator at 16:17:32. Hello world comes out 2 more times and then just stops.
So here is what I determine from this. The Serial Monitor uses open and close to read the data. The terminal emulator sends an open but only read a bit of data before it just stops. There is no port confusion and yes, I close the arduino IDE as quickly as I can after closing the serial monitor. In fact, after all that is closed, I press reset on the arduino to get a clean start. No difference in the result.
In another view in the port monitor, the terminal emulator gets timed out on all subsequent reads.
Can't figure out why the text stop sending when the PC tries to read the data via the terminal emulator. I even wrote a small VB.net program to read the serial data and it also times out on the read.
I also noticed that I can restart arduino's IDE and the serial monitor and it immediately starts receiving the text again. (without uploading the sketch again).
Can't quite figure out what is going on.
Other info: The PC has Windows 10. The Arduino is a Leonardo.
Here is the vb.net program if anyone is interested in that.
Imports System.IO.Ports
Public Class Form1
Dim SerialPort As New SerialPort ' The io serial port
Dim Incoming As String
Dim Count As Integer = 0
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
With SerialPort
.PortName = "COM13"
.BaudRate = 9600
.DataBits = 8
.Parity = Parity.None
.StopBits = StopBits.One
.Handshake = Handshake.None
.ReadTimeout = 1000
End With
SerialPort.Open()
End Sub
Function ReceiveSerialData() As String
Try
Incoming = SerialPort.ReadLine()
Catch Ex As Exception
Count += 1
Label1.Text = Ex.Message & " " & Count
'Application.Exit()
End Try
Return Incoming
End Function
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
ReceiveSerialData()
End Sub
End Class