This is what my devices print out on the terminal while waiting for commands(ser.write)
I am writing a simple PYQT5 terminal in python to display information on a terminal from a connected device using Qserial.
The output from the connected device always begins with a time stamp in a similar format which displays every second but on a newline each time thereby flooding the whole Qtextbrowser Terminal.
this makes it difficult to communicate with the device since this line prints every seconds even if I interrupt it with a command, the command executes successfully and hen the time loops continues again. Is there a way to overwrite this loop so that it prints only on the first line all the time without going to next line.
beneath is a snippet from my script. self.Terminal = QTextBrowser()
def read_serial(self):
b = bytes(self.serialport.readAll())
try:
read_all = b.decode("utf-8")
try:
lastline = self.Terminal.toPlainText().split("\n")[-1]
read_all_nodate = re.sub(r"\d{2}/\d{2}/\d{4} \d{2}:\d{2}:\d{2}", "", read_all)
last_line_nodate = re.sub(r"\d{2}/\d{2}/\d{4} \d{2}:\d{2}:\d{2}", "", lastline)
if read_all_nodate == last_line_nodate:
cursor = self.Terminal.textCursor()
cursor.movePosition(QTextCursor.End)
cursor.movePosition(QTextCursor.StartOfLine, QTextCursor.KeepAnchor)
cursor.removeSelectedText()
self.Terminal.setTextCursor(cursor)
except:
pass
#read_all = read_all.replace("\r", "")
self.Terminal.moveCursor(QTextCursor.End)
self.Terminal.insertPlainText(read_all)
except UnicodeDecodeError:
read_all = str(b)[2:-1]
Any help will be really appreciated. Thank you.
Using Terminals like Tera Term and Putty solves the problem because these Terminals prints only on the first line each second there is a time loop output from my device without moving to the next line.