In https://github.com/raffmont/pynextion/blob/master/pynextion/__init__.py
def nxRead(self, cmax=0, timeout=0):
s = []
done = False
def _reader():
count = 0
time_now = time.clock()
while timeout == 0 or (time.clock() - time_now) < timeout:
r = self.ser.read()
if r is None or r == "":
continue
c = ord(r)
if c == 0xff and len(s) == 0:
continue
if c != 0x00:
if self.debug is True:
print("\/ :" + str(c) + ":" + str(len(s)) + ":" +
str(count))
s.append(c)
if len(s) == cmax:
return
if c == 0xff:
count = count + 1
if count == 3:
if self.debug is True:
print("!!")
return
else:
count = 0
if self.debug is True:
print("/\ :" + str(c) + ":" + str(len(s)) + ":" +
str(count))
print("Timeout")
t = Thread(target=_reader)
t.start()
t.join()
return s
You're starting a separate thread to read from the com port, and then blocking until it completes.
Why is it even there? It's literally equivalent to just calling _reader() in the context of the main thread.
In https://github.com/raffmont/pynextion/blob/master/pynextion/__init__.py
You're starting a separate thread to read from the com port, and then blocking until it completes.
Why is it even there? It's literally equivalent to just calling _reader() in the context of the main thread.