I'm desperate so thought I'd ask here, if anyone is also familiar with python. Using a PI to read data from a pic.

Everything works fine as long as I have the serial port in this loop --

def CC(self):
ser = serial.Serial("/dev/serial0",baudrate=2400) #it's in the loop

self.qone = ser.read(1)
while self.qone != b'\xaa':
self.qone = ser.read(1) # keep reading one byte at a time until 170 is found

self.picdata = ser.read(4) # read remaining 4 bytes

self.qtwo = (self.picdata[0]) #213 11010101
self.lower = (self.picdata[1]) #255 11111111
self.higher = (self.picdata[2]) #255 11111111
self.qend = (self.picdata[3]) #0 00000000

if self.qtwo == 213 and self.qend == 0:
self.ch1 = bool(self.lower & 128)
self.ch2 = bool(self.lower & 64)
etc
tkinter stuff here
root.after(150,self.CC)

BUT -- someone said I shouldn't be opening the serial port over and over again and to just do it once. So if I simply initialize the port, I can't get it to read data at all. Lower and Higher stay at 255,255 (switches normally high, low trigger).

def __init__(self):
self.ser = serial.Serial("/dev/serial0",baudrate=2400)

and then use self.ser.read etc -- no go. Any ideas? Always worked perfectly 24/7 with ser being in the loop. Thanks.