Skip to main content
2 of 2
added 18 characters in body

After reading the comments, my decision has been to just discard any received string from the serial port that has this '\x00' sequence inside of it.

This is the function I have used in the code and works nicely:

def verify_string(self,texto_var): flag = 0 if '\x00' in texto_var: flag = 1 print("Invalid string received:", repr(texto_var)) self.tiempo_valor = 0 elif texto_var == "" or texto_var =='\n': print("do nothing") else: print("Valid string:", repr(texto_var)) # Do the convertion to int self.tiempo_valor = int(self.tiempo_texto.get()) return flag