@@ -172,7 +172,7 @@ def analogRead(self, pin):
172172 self .sr .flush ()
173173 except :
174174 pass
175- rd = self .sr .readline ().replace ("\r \n " , "" )
175+ rd = self .sr .readline ().decode ( "utf-8" ). replace ("\r \n " , "" )
176176 try :
177177 return int (rd )
178178 except :
@@ -215,7 +215,7 @@ def pulseIn(self, pin, val):
215215 self .sr .flush ()
216216 except :
217217 pass
218- rd = self .sr .readline ().replace ("\r \n " , "" )
218+ rd = self .sr .readline ().decode ( "utf-8" ). replace ("\r \n " , "" )
219219 try :
220220 return float (rd )
221221 except :
@@ -262,7 +262,7 @@ def pulseIn_set(self, pin, val, numTrials=5):
262262 self .sr .flush ()
263263 except :
264264 pass
265- rd = self .sr .readline ().replace ("\r \n " , "" )
265+ rd = self .sr .readline ().decode ( "utf-8" ). replace ("\r \n " , "" )
266266 if rd .isdigit ():
267267 if (int (rd ) > 1 ):
268268 durations .append (int (rd ))
@@ -296,7 +296,7 @@ def digitalRead(self, pin):
296296 self .sr .flush ()
297297 except :
298298 pass
299- rd = self .sr .readline ().replace ("\r \n " , "" )
299+ rd = self .sr .readline ().decode ( "utf-8" ). replace ("\r \n " , "" )
300300 try :
301301 return int (rd )
302302 except :
@@ -372,7 +372,7 @@ def capacitivePin(self, pin):
372372 '''
373373 cmd_str = build_cmd_str ("cap" , (pin ,))
374374 self .sr .write (str .encode (cmd_str ))
375- rd = self .sr .readline ().replace ("\r \n " , "" )
375+ rd = self .sr .readline ().decode ( "utf-8" ). replace ("\r \n " , "" )
376376 if rd .isdigit ():
377377 return int (rd )
378378
@@ -405,7 +405,7 @@ def shiftIn(self, dataPin, clockPin, pinOrder):
405405 cmd_str = build_cmd_str ("si" , (dataPin , clockPin , pinOrder ))
406406 self .sr .write (str .encode (cmd_str ))
407407 self .sr .flush ()
408- rd = self .sr .readline ().replace ("\r \n " , "" )
408+ rd = self .sr .readline ().decode ( "utf-8" ). replace ("\r \n " , "" )
409409 if rd .isdigit ():
410410 return int (rd )
411411
@@ -446,7 +446,7 @@ def attach(self, pin, min=544, max=2400):
446446 self .sr .write (str .encode (cmd_str ))
447447 self .sr .flush ()
448448
449- rd = self .sr .readline ().replace ("\r \n " , "" )
449+ rd = self .sr .readline ().decode ( "utf-8" ). replace ("\r \n " , "" )
450450 if rd :
451451 break
452452 else :
@@ -489,7 +489,7 @@ def read(self, pin):
489489 self .sr .flush ()
490490 except :
491491 pass
492- rd = self .sr .readline ().replace ("\r \n " , "" )
492+ rd = self .sr .readline ().decode ( "utf-8" ). replace ("\r \n " , "" )
493493 try :
494494 angle = int (rd )
495495 return angle
0 commit comments