Article 4QWPS send the output from a print command to another window

send the output from a print command to another window

by
RonHof
from LinuxQuestions.org on (#4QWPS)
I have the following Python code that reads a serial string and decodes it. I would like to send the output to a window and display it in a large high contrast format. In this case I want it to display 0.92. I've had no luck finding any tutorials on this.

Code:#!/usr/bin/env python
import time
import serial
import string

ser = serial.Serial(

port='/dev/ttyUSB0',

baudrate = 4800,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.EIGHTBITS,
timeout=1
)
while 1:
Str = ser.readline(8)
print ("encoded string: ")
print (Str)
Str = Str.decode('cp1252','strict')
print ("decoded string: ")
print (Str)

time.sleep(10)the output looks like this

encoded string:
b' 0.92\r'
decoded string:
0.92latest?d=yIl2AUoC8zA latest?i=hHnw9pOEvZc:7ezXTabuyvU:F7zBnMy latest?i=hHnw9pOEvZc:7ezXTabuyvU:V_sGLiP latest?d=qj6IDK7rITs latest?i=hHnw9pOEvZc:7ezXTabuyvU:gIN9vFwhHnw9pOEvZc
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments