int read_detail_page() { int sum = 0; int bytes_read = 0; 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); if (header1 == 0x10 && header2 == 0x02 && command == 0x2022) { read_bytes(2, &bytes_read, &sum); // length uint16_t page_number = read_bytes(2, &bytes_read, &sum); // Page # if (page_number > 0) { // Page # >0 // 128 x 32k QDateTime t; for (int i = 0; i < 128; i++) { int flag = read_bytes(1, &bytes_read, &sum); //b0..b1: "00" Detail Record //b0..b1: "01" RTC Mark Record //b0..b1: "00" Interval Record //b2: reserved //b3: Power was calculated //b4: HPR packet missing //b5: CAD packet missing //b6: PWR packet missing //b7: Power data = old (No new power calculated) if (flag == 0xff) { // means invalid entry read_bytes(31, &bytes_read, &sum); } else if ((flag & 0x03) == 0x01){ t= read_RTC_mark(&secs, &bytes_read, &sum); } else if ((flag & 0x03) == 0x03){ int t = read_interval_mark(&secs, &bytes_read, &sum); interval = t; } else if ((flag & 0x03) == 0x00 ){ read_detail_record(&secs, &bytes_read, &sum); } } read_bytes(1, &bytes_read, &sum); // checksum } } return bytes_read; }
int read_detail_page() { int sum = 0; int bytes_read = 0; 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); if (header1 == 0x10 && header2 == 0x02 && command == 0x2022) { read_bytes(2, &bytes_read, &sum); // length uint16_t page_number = read_bytes(2, &bytes_read, &sum); // Page # if (page_number == 2 && !jouleGPS) { //page still contains 5 interval_summary in 2 blocks of 256k read_bytes(512, &bytes_read, &sum); } if (page_number > 0) { if (BIN2_DEBUG) qDebug() << "page_number" << page_number; int nb_record = 128; // Page # >0 // Joule GPS : 128 x record (32k) if (!jouleGPS) { // Page # = 2 // Joule : 168 x record (20k) // Page # > 1 // Joule : 192 x record (20k) if (page_number == 2) nb_record = 168; else nb_record = 192; } QDateTime t; for (int i = 0; i < nb_record; i++) { int flag = read_bytes(1, &bytes_read, &sum); //b0..b1: "00" Detail Record //b0..b1: "01" RTC Mark Record //b0..b1: "10" Session Mark (Joule GPS) //b0..b1: "10" Interval Record (Joule 1.0) //b0..b1: "11" Interval Record (Joule GPS) //b0..b1: "11" Invalid ( 0xFF) //b3: Power was calculated //b4: HR packet missing //b5: CAD packet missing //b6: PWR packet missing //b7: Power data = old (No new power calculated) if (BIN2_DEBUG && (flag & 0x03) != 0) { qDebug() << "flag B0..B1" << (flag & 0x03) << "flag" << flag; if (flag == 0xff) { qDebug() << "Invalid record"; } else { if ((flag & 0x08) == 0x08) { qDebug() << "Power was calculated"; } if ((flag & 0x10) == 0x10) { qDebug() << "HPR packet missing"; } if ((flag & 0x20) == 0x20) { qDebug() << "CAD packet missing"; } if ((flag & 0x40) == 0x40) { qDebug() << "PWR packet missing"; } if ((flag & 0x80) == 0x80) { qDebug() << "Power data = old"; } } } if (flag == 0xff) { // means invalid entry if (BIN2_DEBUG) qDebug() << "invalid at" << secs << "secs"; if (jouleGPS) read_bytes(31, &bytes_read, &sum); // dummy else read_bytes(19, &bytes_read, &sum); // dummy //increase seconds (secs)++; } else if ((flag & 0x03) == 0x01){ // The RTC Mark is written when there is a gap in the ride data, // or when the internal Real Time Clock is adjusted. t= read_RTC_mark(&secs, &bytes_read, &sum); } else if ((jouleGPS && (flag & 0x03) == 0x03) || (!jouleGPS && (flag & 0x03) == 0x02)) { // The Interval Mark immediately precedes a Detail Record at the same RTC time. int t = read_interval_mark(&secs, &bytes_read, &sum); interval = t; } else if ((flag & 0x03) == 0x00 ){ // The detail record contains current telemetry data. read_detail_record(&secs, &bytes_read, &sum); } else { if (BIN2_DEBUG) qDebug() << "UNKNOW: flag" << flag << "at" << secs << "secs"; if (jouleGPS) read_bytes(31, &bytes_read, &sum); // dummy else read_bytes(19, &bytes_read, &sum); // dummy } if (!jouleGPS && (i+1)%12 == 0) read_bytes(16, &bytes_read, &sum); // unused } read_bytes(1, &bytes_read, &sum); // checksum } } return bytes_read; }
int read_detail_page() { int sum = 0; int bytes_read = 0; 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); if (header1 == 0x10 && header2 == 0x02 && command == 0x2022) { read_bytes(2, &bytes_read, &sum); // length uint16_t page_number = read_bytes(2, &bytes_read, &sum); // Page # if (page_number == 2 && !jouleGPS) { //page still contains 5 interval_summary in 2 blocks of 256k read_bytes(512, &bytes_read, &sum); } if (page_number > 0) { //qDebug() << "page_number" << page_number; int nb_record = 128; // Page # >0 // Joule GPS : 128 x record (32k) if (!jouleGPS) { // Page # = 2 // Joule : 168 x record (20k) // Page # > 1 // Joule : 192 x record (20k) if (page_number == 2) nb_record = 168; else nb_record = 192; } QDateTime t; for (int i = 0; i < nb_record; i++) { int flag = read_bytes(1, &bytes_read, &sum); //b0..b1: "00" Detail Record //b0..b1: "01" RTC Mark Record //b0..b1: "00" Interval Record //b2: reserved //b3: Power was calculated //b4: HPR packet missing //b5: CAD packet missing //b6: PWR packet missing //b7: Power data = old (No new power calculated) if (flag == 0xff) { // means invalid entry //qDebug() << "invalid" << secs; if (jouleGPS) read_bytes(31, &bytes_read, &sum); // dummy else read_bytes(19, &bytes_read, &sum); // dummy //increase seconds (secs)++; } else if ((flag & 0x03) == 0x01){ t= read_RTC_mark(&secs, &bytes_read, &sum); } else if ((jouleGPS && (flag & 0x03) == 0x03) || (!jouleGPS && (flag & 0x03) == 0x02)) { int t = read_interval_mark(&secs, &bytes_read, &sum); interval = t; } else if ((flag & 0x03) == 0x00 ){ read_detail_record(&secs, &bytes_read, &sum); } else { //qDebug() << "unknow" << secs; if (jouleGPS) read_bytes(31, &bytes_read, &sum); // dummy else read_bytes(19, &bytes_read, &sum); // dummy } if (!jouleGPS && (i+1)%12 == 0) read_bytes(16, &bytes_read, &sum); // unused } read_bytes(1, &bytes_read, &sum); // checksum } } return bytes_read; }