File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -99,7 +99,10 @@ def update(self):
9999 """
100100 # Grab a sentence and check its data type to call the appropriate
101101 # parsing function.
102- sentence = self ._parse_sentence ()
102+ try :
103+ sentence = self ._parse_sentence ()
104+ except UnicodeError :
105+ return None
103106 if sentence is None :
104107 return False
105108 if self .debug :
@@ -145,7 +148,10 @@ def _parse_sentence(self):
145148 sentence = self ._uart .readline ()
146149 if sentence is None or sentence == b'' or len (sentence ) < 1 :
147150 return None
148- sentence = str (sentence , 'ascii' ).strip ()
151+ try :
152+ sentence = str (sentence , 'ascii' ).strip ()
153+ except UnicodeError :
154+ return None
149155 # Look for a checksum and validate it if present.
150156 if len (sentence ) > 7 and sentence [- 3 ] == '*' :
151157 # Get included checksum, then calculate it and compare.
You can’t perform that action at this time.
0 commit comments