Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed writing data packets whose length is not multiple of 32 #106

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/debian/changelog
Expand Up @@ -3,6 +3,7 @@ python-fingerprint (1.6) UNRELEASED; urgency=medium
* Fixed "The received packet do not begin with a valid header" error
* Fixed "port could not be found" on Windows
* Fixed image issues with downloadImage()
* Fixed writing data packets whose length is not multiple of 32
* Introduced methods for getting and setting the baudrate, security level and
max packet size
* Added optional arguments charBufferNumber, positionStart and count to
Expand Down
8 changes: 4 additions & 4 deletions src/files/pyfingerprint/pyfingerprint.py
Expand Up @@ -1422,20 +1422,20 @@ def uploadCharacteristics(self, charBufferNumber = FINGERPRINT_CHARBUFFER1, char
raise Exception('Unknown error '+ hex(receivedPacketPayload[0]))

## Upload data packets
packetNbr = len(characteristicsData) / maxPacketSize
packetNumber = int(len(characteristicsData) / maxPacketSize)

if ( packetNbr <= 1 ):
if ( packetNumber <= 1 ):
self.__writePacket(FINGERPRINT_ENDDATAPACKET, characteristicsData)
else:
i = 1
while ( i < packetNbr ):
while ( i < packetNumber ):
lfrom = (i-1) * maxPacketSize
lto = lfrom + maxPacketSize
self.__writePacket(FINGERPRINT_DATAPACKET, characteristicsData[lfrom:lto])
i += 1

lfrom = (i-1) * maxPacketSize
lto = lfrom + maxPacketSize
lto = len(characteristicsData)
self.__writePacket(FINGERPRINT_ENDDATAPACKET, characteristicsData[lfrom:lto])

## Verify uploaded characteristics
Expand Down