Correct error in the erase function for Joule GPS

This commit is contained in:
Damien
2012-11-17 16:52:37 +01:00
parent fc0c555bfd
commit 122b8d59ba
2 changed files with 19 additions and 17 deletions

View File

@@ -259,12 +259,12 @@ struct Bin2FileReaderState
char header1 = read_bytes(1, &bytes_read, &sum); // Always 0x10
char header2 = read_bytes(1, &bytes_read, &sum); // Always 0x02
uint16_t command = read_bytes(2, &bytes_read, &sum); // Always 0x10
uint16_t command = read_bytes(2, &bytes_read, &sum);
if (header1 == 0x10 && header2 == 0x02 && command == 0x2022)
{
uint16_t length = read_bytes(2, &bytes_read, &sum); // Always 4098 for Joule GPS
uint16_t length = read_bytes(2, &bytes_read, &sum);
uint16_t page_number = read_bytes(2, &bytes_read, &sum); // Page #
if (page_number == 0) {
@@ -281,7 +281,7 @@ struct Bin2FileReaderState
read_bytes(1, &bytes_read, &sum); // to finish
}
char checksum = read_bytes(1, &bytes_read, &sum); // Always 0x10
char checksum = read_bytes(1, &bytes_read, &sum);
} else {
// not a summary page !
@@ -300,12 +300,11 @@ struct Bin2FileReaderState
char header1 = read_bytes(1, &bytes_read, &sum); // Always 0x10
char header2 = read_bytes(1, &bytes_read, &sum); // Always 0x02
uint16_t command = read_bytes(2, &bytes_read, &sum); // Always 0x10
uint16_t command = read_bytes(2, &bytes_read, &sum);
if (header1 == 0x10 && header2 == 0x02 && command == 0x2022)
{
uint16_t length = read_bytes(2, &bytes_read, &sum); // Always 4098
uint16_t length = read_bytes(2, &bytes_read, &sum);
uint16_t page_number = read_bytes(2, &bytes_read, &sum); // Page #
if (page_number > 0) {
@@ -343,7 +342,7 @@ struct Bin2FileReaderState
}
}
char checksum = read_bytes(1, &bytes_read, &sum); // Always 0x10
char checksum = read_bytes(1, &bytes_read, &sum);
}
@@ -359,11 +358,11 @@ struct Bin2FileReaderState
int bytes_read = 0;
uint16_t header = read_bytes(2, &bytes_read, &sum); // Always 0x210 (0x10-0x02)
uint16_t command = read_bytes(2, &bytes_read, &sum); // Always 0x10
uint16_t command = read_bytes(2, &bytes_read, &sum);
if (header == START && command == UNIT_VERSION)
{
uint16_t length = read_bytes(2, &bytes_read, &sum); // Always 4098 for Joule GPS
uint16_t length = read_bytes(2, &bytes_read, &sum);
int major_version = read_bytes(1, &bytes_read, &sum);
int minor_version = read_bytes(2, &bytes_read, &sum);
@@ -372,7 +371,7 @@ struct Bin2FileReaderState
QString version = QString(minor_version<100?"%1.0%2 (%3)":"%1.%2 (%3)").arg(major_version).arg(minor_version).arg(data_version);
deviceInfo += rideFile->deviceType()+QString(" Version %1\n").arg(version);
char checksum = read_bytes(1, &bytes_read, &sum); // Always 4098 for Joule GPS
char checksum = read_bytes(1, &bytes_read, &sum);
}
return bytes_read;
}
@@ -383,18 +382,18 @@ struct Bin2FileReaderState
int bytes_read = 0;
uint16_t header = read_bytes(2, &bytes_read, &sum); // Always (0x10-0x02)
uint16_t command = read_bytes(2, &bytes_read, &sum); // Always 0x10
uint16_t command = read_bytes(2, &bytes_read, &sum);
if (header == START && command == SYSTEM_INFO)
{
uint16_t length = read_bytes(2, &bytes_read, &sum); // Always 4098 for Joule GPS
uint16_t length = read_bytes(2, &bytes_read, &sum);
read_bytes(52, &bytes_read, &sum);
uint16_t odometer = read_bytes(8, &bytes_read, &sum); // Always 4098 for Joule GPS
uint16_t odometer = read_bytes(8, &bytes_read, &sum);
deviceInfo += QString("Odometer %1km\n").arg(odometer/1000.0);
char checksum = read_bytes(1, &bytes_read, &sum); // Always 4098 for Joule GPS
char checksum = read_bytes(1, &bytes_read, &sum);
}
return bytes_read;
}

View File

@@ -137,7 +137,8 @@ JouleDevice::download( const QDir &tmpdir,
getSystemInfo(serial, systemInfoArray, err);
QList<DeviceStoredRideItem> trainings;
getDownloadableRides(trainings, err);
if (getDownloadableRides(trainings, err))
return false;
for (int i=0; i<trainings.count(); i++) {
statusCallback(QString("Read ride detail for ride %1/%2").arg(i+1).arg(trainings.count()));
@@ -379,9 +380,11 @@ JouleDevice::cleanup( QString &err ) {
if (!dev->open(err)) {
err = "ERROR: open failed: " + err;
}
dev->setBaudRate(57600, err);
QList<DeviceStoredRideItem> trainings;
getDownloadableRides(trainings, err);
if (!getDownloadableRides(trainings, err))
return false;
for (int i=0; i<trainings.count(); i++) {
statusCallback(QString("Delete ride detail for ride %1/%2").arg(i+1).arg(trainings.count()));
@@ -395,7 +398,7 @@ JouleDevice::cleanup( QString &err ) {
if (!request.write(dev, err)) return false;
JoulePacket response = JoulePacket(READ_SYSTEM_INFO);
JoulePacket response = JoulePacket(ERASE_RIDE_DETAIL);
if (!response.read(dev, err))
return false;
}