oozie / pyhumod

Using Huawei Modems in Python
Other
33 stars 15 forks source link

UnicodeDecodeError when MMS is received #10

Open fmalina opened 8 years ago

fmalina commented 8 years ago

Happens if self.readline() returns byte data in humodem.py, line 172.

             input_line = self.readline().decode().rstrip()

Maybe we should catch the exception like so.

     while 1:
         # Read in one line of input.
         coded_input_line = self.readline()
         try:
            # input_line = self.readline().decode().rstrip()
            input_line = coded_input_line.decode().rstrip()
         except serial.serialutil.SerialException:
             time.sleep(.2)
             continue
        except UnicodeDecodeError:
            """ b'\x00\x06&application/vnd.wap.mms-message
            \x00\xaf\x84\x8d\xff\xb4\x81\x8c\x82\x98nw\x00\x8d\x90\x89\x19\x80
            +447736000000/TYPE=PLMN
            \x00\x8a\x80\x8e\x03\x08\xb5/\x88\x05\x81\x03\t:\x80\x83
            http://mmsc-ac1.mms.o\r\n'
            """
            print(coded_input_line)
            continue