mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-13 16:18:42 +00:00
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.
This commit is contained in:
11
src/ANT.cpp
11
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"<<rxMessage[ANT_OFFSET_ID];
|
||||
ANTMessage(this, rxMessage); // for debug!
|
||||
|
||||
QDataStream out(&antlog);
|
||||
for (int i=0; i<ANT_MAX_MESSAGE_SIZE; i++)
|
||||
out<<rxMessage[i];
|
||||
|
||||
|
||||
switch (rxMessage[ANT_OFFSET_ID]) {
|
||||
case ANT_ACK_DATA:
|
||||
case ANT_BROADCAST_DATA:
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include <QStringList>
|
||||
#include <QTime>
|
||||
#include <QProgressDialog>
|
||||
#include <QFile>
|
||||
|
||||
//
|
||||
// Time
|
||||
@@ -329,6 +330,8 @@ private:
|
||||
int bytes;
|
||||
int checksum;
|
||||
|
||||
// antlog.bin ant message stream
|
||||
QFile antlog;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -278,6 +278,7 @@ qDebug()<<"who are you? sent";
|
||||
//
|
||||
// We got some telemetry on this channel
|
||||
//
|
||||
qDebug()<<"broadcast datapage="<<antMessage.data_page;
|
||||
if (lastMessage.type != 0) {
|
||||
|
||||
switch (channel_type) {
|
||||
@@ -355,7 +356,7 @@ qDebug()<<"got new offset!"<<srm_offset;
|
||||
float power = 3.14159 * nm_torque * cadence / 30;
|
||||
|
||||
// ignore the occassional spikes XXX is this a boundary error on event count ?
|
||||
if (power > 0 && power < 2501 && cadence >0 && cadence < 256) {
|
||||
if (power >= 0 && power < 2501 && cadence >=0 && cadence < 256) {
|
||||
parent->setWatts(power);
|
||||
parent->setCadence(cadence);
|
||||
}
|
||||
|
||||
@@ -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="<<message[3]<<"type="<<message[4]<<"calid?"<
|
||||
// we need to handle ant sport messages here
|
||||
switch(parent->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);
|
||||
|
||||
Reference in New Issue
Block a user