File tree 1 file changed +8
-2
lines changed
1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -99,7 +99,10 @@ def update(self):
99
99
"""
100
100
# Grab a sentence and check its data type to call the appropriate
101
101
# parsing function.
102
- sentence = self ._parse_sentence ()
102
+ try :
103
+ sentence = self ._parse_sentence ()
104
+ except UnicodeError :
105
+ return None
103
106
if sentence is None :
104
107
return False
105
108
if self .debug :
@@ -145,7 +148,10 @@ def _parse_sentence(self):
145
148
sentence = self ._uart .readline ()
146
149
if sentence is None or sentence == b'' or len (sentence ) < 1 :
147
150
return None
148
- sentence = str (sentence , 'ascii' ).strip ()
151
+ try :
152
+ sentence = str (sentence , 'ascii' ).strip ()
153
+ except UnicodeError :
154
+ return None
149
155
# Look for a checksum and validate it if present.
150
156
if len (sentence ) > 7 and sentence [- 3 ] == '*' :
151
157
# Get included checksum, then calculate it and compare.
You can’t perform that action at this time.
0 commit comments