From 22d04f85247fffa36646d10b5f5a21612bcfc86b Mon Sep 17 00:00:00 2001 From: Mark Liversedge Date: Mon, 14 Mar 2011 21:57:35 +0000 Subject: [PATCH] Native ANT+ Part 2 - antlog.bin dignostics A patch to create an 'antlog.bin' in the current working directory when working with ANT+ devices. This is to enable users to test the ANT+ support and share the received messages to diagnose issues related to parsing messages and displaying telemetry. This 'antlog.bin' will ultimately become a native ant file format and have an associated extension (.ant) and a ridefile reader. For now it just writes a stream of fixed length messages (12 bytes) of all received messages. --- src/ANT.cpp | 11 +++++++++++ src/ANT.h | 3 +++ src/ANTChannel.cpp | 3 ++- src/ANTMessage.cpp | 9 ++++++++- 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/ANT.cpp b/src/ANT.cpp index 80367e508..973c90475 100644 --- a/src/ANT.cpp +++ b/src/ANT.cpp @@ -123,6 +123,9 @@ void ANT::run() if (openPort() == 0) { + antlog.setFileName("antlog.bin"); + antlog.open(QIODevice::WriteOnly | QIODevice::Truncate); + isPortOpen = true; sendMessage(ANTMessage::resetSystem()); sendMessage(ANTMessage::setNetworkKey(1, key)); @@ -242,6 +245,9 @@ ANT::stop() pvars.lock(); Status = 0; // Terminate it! pvars.unlock(); + + // close debug file + antlog.close(); return 0; } @@ -516,6 +522,11 @@ ANT::processMessage(void) { //qDebug()<<"processing ant message"< #include #include +#include // // Time @@ -329,6 +330,8 @@ private: int bytes; int checksum; + // antlog.bin ant message stream + QFile antlog; }; #endif diff --git a/src/ANTChannel.cpp b/src/ANTChannel.cpp index 4ed7e088c..d58c3dd07 100755 --- a/src/ANTChannel.cpp +++ b/src/ANTChannel.cpp @@ -278,6 +278,7 @@ qDebug()<<"who are you? sent"; // // We got some telemetry on this channel // +qDebug()<<"broadcast datapage="< 0 && power < 2501 && cadence >0 && cadence < 256) { + if (power >= 0 && power < 2501 && cadence >=0 && cadence < 256) { parent->setWatts(power); parent->setCadence(cadence); } diff --git a/src/ANTMessage.cpp b/src/ANTMessage.cpp index 4159cc0c5..ffb4eabbf 100755 --- a/src/ANTMessage.cpp +++ b/src/ANTMessage.cpp @@ -339,6 +339,8 @@ qDebug()<<"request message"; // HEARTRATE (high bit is used to indicate data changed) // (every 65th message is a background data message) // (get page # with mask 0x7F) + // ** Note older devices (e.g. GARMIN) do not support + // ** multiple data pages (listed below) // 0x00 - Heartrate data // 0x01 - Background data page (cumulative data) // 0x02 - manufacturer ID and Serial Number @@ -377,7 +379,12 @@ qDebug()<<"broadcast data, channel="<antChannel[message[3]]->channel_type) { - // Heartrate is fairly simple + // Heartrate is fairly simple. Although + // many older heart rate devices do not support + // multiple data pages, and provide random values + // for the data page itself. (E.g. 1st Gen GARMIN) + // since we do not care hugely about operating time + // and serial numbers etc, we don't even try case ANTChannel::CHANNEL_TYPE_HR: channel = message[3]; measurementTime = message[8] + (message[9]<<8);