I am trying to connect to a terminal emulator using a library in android, this will connect to a serial device and should show me sent/received data. I should be able to send data over the connection via a text box below the terminal or by typing in the terminal itself and hitting enter on the keyboard in both cases.
When I was sending data via textbox I had to append \r\n to the data to get to a new line when I pressed the enter key like so:
And the write method:
With this I got the prompt back twice from the terminal, which is wrong. When I was hitting enter after typing in the terminal session itself no new line was occurring at all. So I had to
test the data for \r and replace it with \r\n
So that worked fine, now when I type in the terminal session itself and hit enter i got the newline I wanted. However now every time I send data from the text box with with \r\n there is an extra space between every new line as well as getting the extra newline. I assume \r\n is getting translated to \r\n\n and I'm not sure why I am getting the extra space between every line, so how do i change the code so that both ways of entering text generate the correct result?
Issues here are that as well as after I send data and am getting the terminal prompt back twice in all cases, for some reason I also get a space between every line. If I go back to the original write function I don't get the erroneous spaces but I get the prompt twice and typing in the terminal session itself does not work, no new line.
Original terminal getting prompt twice sending data from a text box, and when I write via terminal itself I don't get any new line.
Here is what the badly formatted terminal with the new write looks like, extra spaces, getting prompt twice when data is sent:
