Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions src/files/pyfingerprint/pyfingerprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import serial
from PIL import Image
import struct
import math


## Baotou start byte
Expand Down Expand Up @@ -1387,6 +1388,10 @@ def uploadCharacteristics(self, charBufferNumber = FINGERPRINT_CHARBUFFER1, char
raise ValueError('The characteristics data is required!')

maxPacketSize = self.getMaxPacketSize()
maxDataPacketSize = 32

## not sure about this if maxPacketSize == maxDataPacketSize
# maxDataPacketSize = maxPacketSize - 2 (checksum length is 2 and it is also calculated in packet size? )

## Upload command

Expand Down Expand Up @@ -1420,20 +1425,20 @@ def uploadCharacteristics(self, charBufferNumber = FINGERPRINT_CHARBUFFER1, char
raise Exception('Unknown error '+ hex(receivedPacketPayload[0]))

## Upload data packets
packetNbr = len(characteristicsData) / maxPacketSize
packetNbr = math.ceil(len(characteristicsData) / float(maxDataPacketSize))

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

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

## Verify uploaded characteristics
Expand Down