summaryrefslogtreecommitdiffstats
path: root/heimdall
diff options
context:
space:
mode:
authorBenjamin Dobell <benjamin.dobell+git@glassechidna.com.au>2014-06-01 05:12:07 +0200
committerBenjamin Dobell <benjamin.dobell+git@glassechidna.com.au>2014-06-01 05:12:07 +0200
commit46d9a51e18d260e416479432fec50c6e601eb3ce (patch)
treecefc1d72db4568715dfdcd737eba46ae289d1d52 /heimdall
parentGive devices some leeway to handle empty bulk transfers. (diff)
downloadHeimdall-46d9a51e18d260e416479432fec50c6e601eb3ce.tar
Heimdall-46d9a51e18d260e416479432fec50c6e601eb3ce.tar.gz
Heimdall-46d9a51e18d260e416479432fec50c6e601eb3ce.tar.bz2
Heimdall-46d9a51e18d260e416479432fec50c6e601eb3ce.tar.lz
Heimdall-46d9a51e18d260e416479432fec50c6e601eb3ce.tar.xz
Heimdall-46d9a51e18d260e416479432fec50c6e601eb3ce.tar.zst
Heimdall-46d9a51e18d260e416479432fec50c6e601eb3ce.zip
Diffstat (limited to 'heimdall')
-rw-r--r--heimdall/source/BridgeManager.cpp16
-rw-r--r--heimdall/source/SendFilePartPacket.h8
2 files changed, 11 insertions, 13 deletions
diff --git a/heimdall/source/BridgeManager.cpp b/heimdall/source/BridgeManager.cpp
index 96c22fb..32807ca 100644
--- a/heimdall/source/BridgeManager.cpp
+++ b/heimdall/source/BridgeManager.cpp
@@ -1040,14 +1040,9 @@ bool BridgeManager::SendFile(FILE *file, unsigned int destination, unsigned int
{
bool isLastSequence = (sequenceIndex == sequenceCount - 1);
unsigned int sequenceSize = (isLastSequence) ? lastSequenceSize : fileTransferSequenceMaxLength;
- unsigned int sequenceByteCount;
+ unsigned int sequenceTotalByteCount = sequenceSize * fileTransferPacketSize;
- if (isLastSequence)
- sequenceByteCount = ((partialPacketByteCount) ? lastSequenceSize - 1 : lastSequenceSize) * fileTransferPacketSize + partialPacketByteCount;
- else
- sequenceByteCount = fileTransferSequenceMaxLength * fileTransferPacketSize;
-
- FlashPartFileTransferPacket *beginFileTransferPacket = new FlashPartFileTransferPacket(sequenceByteCount);
+ FlashPartFileTransferPacket *beginFileTransferPacket = new FlashPartFileTransferPacket(sequenceTotalByteCount);
success = SendPacket(beginFileTransferPacket);
delete beginFileTransferPacket;
@@ -1169,9 +1164,12 @@ bool BridgeManager::SendFile(FILE *file, unsigned int destination, unsigned int
previousPercent = currentPercent;
}
+ unsigned int sequenceEffectiveByteCount = (isLastSequence && partialPacketByteCount != 0) ?
+ fileTransferPacketSize * (lastSequenceSize - 1) + partialPacketByteCount : sequenceTotalByteCount;
+
if (destination == EndFileTransferPacket::kDestinationPhone)
{
- EndPhoneFileTransferPacket *endPhoneFileTransferPacket = new EndPhoneFileTransferPacket(sequenceByteCount, 0, deviceType, fileIdentifier, isLastSequence);
+ EndPhoneFileTransferPacket *endPhoneFileTransferPacket = new EndPhoneFileTransferPacket(sequenceEffectiveByteCount, 0, deviceType, fileIdentifier, isLastSequence);
success = SendPacket(endPhoneFileTransferPacket, kDefaultTimeoutSend, kSendEmptyTransferBeforeAndAfter);
delete endPhoneFileTransferPacket;
@@ -1185,7 +1183,7 @@ bool BridgeManager::SendFile(FILE *file, unsigned int destination, unsigned int
}
else // destination == EndFileTransferPacket::kDestinationModem
{
- EndModemFileTransferPacket *endModemFileTransferPacket = new EndModemFileTransferPacket(sequenceByteCount, 0, deviceType, isLastSequence);
+ EndModemFileTransferPacket *endModemFileTransferPacket = new EndModemFileTransferPacket(sequenceEffectiveByteCount, 0, deviceType, isLastSequence);
success = SendPacket(endModemFileTransferPacket, kDefaultTimeoutSend, kSendEmptyTransferBeforeAndAfter);
delete endModemFileTransferPacket;
diff --git a/heimdall/source/SendFilePartPacket.h b/heimdall/source/SendFilePartPacket.h
index 6bbc086..3ecaa89 100644
--- a/heimdall/source/SendFilePartPacket.h
+++ b/heimdall/source/SendFilePartPacket.h
@@ -34,7 +34,7 @@ namespace Heimdall
{
public:
- SendFilePartPacket(FILE *file, int size) : OutboundPacket(size)
+ SendFilePartPacket(FILE *file, unsigned int size) : OutboundPacket(size)
{
memset(data, 0, size);
@@ -45,13 +45,13 @@ namespace Heimdall
fseek(file, position, SEEK_SET);
// min(fileSize, size)
- int bytesToRead = (fileSize < size) ? fileSize - position : size;
+ unsigned int bytesToRead = (fileSize < size) ? fileSize - position : size;
// bytesRead is discarded (it's just there to stop GCC warnings)
- int bytesRead = fread(data, 1, bytesToRead, file);
+ unsigned int bytesRead = fread(data, 1, bytesToRead, file);
}
- SendFilePartPacket(unsigned char *buffer, int size) : OutboundPacket(size)
+ SendFilePartPacket(unsigned char *buffer, unsigned int size) : OutboundPacket(size)
{
memcpy(data, buffer, size);
}