Skip to content

Commit

Permalink
checksum calculation no longer depends on imageType (PROPMAN-36)
Browse files Browse the repository at this point in the history
  • Loading branch information
bweir committed Feb 4, 2016
1 parent dc444cb commit e20faef
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 7 additions & 3 deletions src/image/propellerimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "../util/logging.h"

PropellerImage::PropellerImage(QByteArray image, QString filename)
PropellerImage::PropellerImage(const QByteArray & image, const QString & filename)
{
_image = image;
_filename = filename;
Expand Down Expand Up @@ -31,9 +31,11 @@ quint8 PropellerImage::checksum()
{
quint8 sum = 0;
foreach (quint8 c, _image)
{
sum += c;
}

if (_type == Binary)
if (imageSize() <= programSize())
sum += 2 * (0xff + 0xff + 0xff + 0xf9);

return sum;
Expand Down Expand Up @@ -75,8 +77,10 @@ QByteArray PropellerImage::data()
Sets the raw binary data of the image.
*/

void PropellerImage::setData(QByteArray data) {
void PropellerImage::setData(QByteArray data)
{
_image = data;
_image.detach();
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/image/propellerimage.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ class PropellerImage

public:

PropellerImage( QByteArray image = QByteArray(),
QString filename = "");
PropellerImage( const QByteArray & image = QByteArray(),
const QString & filename = "");

/**
@name Image Validation
Expand Down

0 comments on commit e20faef

Please sign in to comment.