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

Upload characteristics working modifications #94

Open
wants to merge 2 commits into
base: Development
Choose a base branch
from
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