bastianraschke / pyfingerprint

Python library for ZhianTec fingerprint sensors (e.g. ZFM-20, ZFM-60)
Other
190 stars 115 forks source link

readPacket function does not handle case were no byte is read #96

Closed chrisb2 closed 4 years ago

chrisb2 commented 4 years ago

At L315 in the __readPacket() function a check is made that a byte has been received, but the case where it not received is not handled. I believe the code should look like this:

            if ( len(receivedFragment) != 0 ):
                receivedFragment = self.__stringToByte(receivedFragment)
                ## print 'Received packet fragment = ' + hex(receivedFragment)
            else:
                continue

With the current code, if no byte is read an exception with the following message is raise:

The received packet do not begin with a valid header!

Happy to raise a PR for this is you like.

regards, Chris

philippmeisberger commented 4 years ago

Hi @chrisb2 , this could may fix a really annoying bug which we are struggling for years ;) I will create a fix for that!

philippmeisberger commented 4 years ago

Should be fixed. Therefore I close this issue.