Code Cleaning: ANT+ sources

Removing and fixing 'XXX' code markers across the ANT+
code. Largely this was to confirm against specs and mark
for future support (e.g. burst data, further refactoring
of the quarqd sources).
This commit is contained in:
Mark Liversedge
2013-02-07 12:20:40 +00:00
parent 2290b194e3
commit e9cabc116f
4 changed files with 30 additions and 69 deletions

View File

@@ -361,7 +361,6 @@ ANT::addDevice(int device_number, int device_type, int channel_number)
if (((antChannel[i]->channel_type & 0xf ) == device_type) &&
(antChannel[i]->device_number == device_number)) {
// send the channel found...
//XXX antChannel[i]->channelInfo();
return 1;
}
}
@@ -459,14 +458,6 @@ ANT::startWaitingSearch()
return 0;
}
void
ANT::report()
{
for (int i=0; i<channels; i++)
//XXX antChannel[i]->channelInfo();
;
}
void
ANT::associateControlChannels() {
@@ -529,9 +520,9 @@ ANT::discover(QString name)
// All we can do for USB1 sticks is see if the cp210x driver module
// is loaded for this device, and if it is, we will use the device
// XXX need a better way of probing this device, but USB1 sticks
// are getting rarer, so maybe we can just make do with this
// until we deprecate them altogether
// they are getting rarer and rarer these days (no longer sold by
// Garmin anyway) so no need to expend to much energy extending this
// especially since the Linux user community is relatively small.
struct stat s;
if (stat(name.toLatin1(), &s) == -1) return false;
int maj = major(s.st_rdev);
@@ -613,7 +604,8 @@ ANT::sendMessage(ANTMessage m) {
rawWrite((uint8_t*)m.data, m.length);
// this padding is important, for some reason XXX find out why?
// this padding is important - do not remove it
// we need to be sure the message is at least 12 bytes
rawWrite((uint8_t*)padding, 5);
}
@@ -704,7 +696,6 @@ ANT::processMessage(void) {
case ANT_CHANNEL_EVENT:
switch (rxMessage[ANT_OFFSET_MESSAGE_CODE]) {
case EVENT_TRANSFER_TX_FAILED:
//XXX remember last message ... ANT_SendAckMessage();
break;
case EVENT_TRANSFER_TX_COMPLETED:
// fall through
@@ -946,7 +937,7 @@ int ANT::interpretSuffix(char c)
return -1;
}
// convert ANT value to 'p' 'c' values // XXX this and below are named wrong, legacy from quarqd code.
// convert ANT value to 'p' 'c' values
char ANT::deviceIdCode(int type)
{
const ant_sensor_type_t *st=ant_sensor_types;

View File

@@ -65,7 +65,7 @@
#include <termios.h> // unix!!
#include <unistd.h> // unix!!
#include <sys/ioctl.h>
#ifndef N_TTY // for OpenBSD, this is a hack XXX
#ifndef N_TTY // for OpenBSD
#define N_TTY 0
#endif
#endif
@@ -293,9 +293,9 @@ public slots:
public:
static int interpretSuffix(char c); // utility to convert e.g. 'c' to CHANNEL_TYPE_CADENCE
static const char *deviceTypeDescription(int type); // utility to convert CHANNEL_TYPE_XXX to human string
static char deviceTypeCode(int type); // utility to convert CHANNEL_TYPE_XXX to 'c', 'p' et al
static char deviceIdCode(int type); // utility to convert CHANNEL_TYPE_XXX to 'c', 'p' et al
static const char *deviceTypeDescription(int type); // utility to convert CHANNEL_TYPE_X to human string
static char deviceTypeCode(int type); // utility to convert CHANNEL_TYPE_X to 'c', 'p' et al
static char deviceIdCode(int type); // utility to convert CHANNEL_TYPE_X to 'c', 'p' et al
// debug enums
enum { DEBUG_LEVEL_ERRORS=1,
@@ -313,7 +313,6 @@ public:
int removeDevice(int device_number, int channel_type);
ANTChannel *findDevice(int device_number, int channel_type);
int startWaitingSearch();
void report();
void associateControlChannels();
// transmission

View File

@@ -117,9 +117,6 @@ void ANTChannel::close()
//
// The main read loop is in ANT.cpp, it will pass us
// the inbound message received for our channel.
// XXX fix this up to re-use ANTMessage for decoding
// all the inbound messages
//
void ANTChannel::receiveMessage(unsigned char *ant_message)
{
switch (ant_message[2]) {
@@ -139,7 +136,7 @@ void ANTChannel::receiveMessage(unsigned char *ant_message)
burstData(ant_message);
break;
default:
break; //XXX should trap error here, but silently ignored for now
break; //errors silently ignored for now, would indicate hardware fault.
}
if (get_timestamp() > blanking_timestamp + timeout_blanking) {
@@ -153,8 +150,9 @@ void ANTChannel::receiveMessage(unsigned char *ant_message)
// process a channel event message
// XXX should re-use ANTMessage rather than
// raw message data
// would be good to refactor to use ANTMessage at some point
// but not compelling reason to do so at this point and might
// break existing code.
void ANTChannel::channelEvent(unsigned char *ant_message) {
unsigned char *message=ant_message+2;
@@ -192,8 +190,6 @@ void ANTChannel::channelEvent(unsigned char *ant_message) {
parent->sendMessage(ANTMessage::unassignChannel(number));
}
//XXX channel_manager_start_waiting_search(self->parent);
} else if (MESSAGE_IS_EVENT_RX_FAIL(message)) {
messages_dropped++;
@@ -210,13 +206,8 @@ void ANTChannel::channelEvent(unsigned char *ant_message) {
exit(-10);
} else if (MESSAGE_IS_EVENT_TRANSFER_TX_COMPLETED(message)) {
if (tx_ack_disposition) {} //XXX tx_ack_disposition();
} else {
// XXX not handled!
}
// do nothing
}
}
// if this is a quarq cinqo then record that fact
@@ -235,7 +226,6 @@ void ANTChannel::checkCinqo()
// are we an old-version or new-version cinqo?
is_old_cinqo = ((version_hi <= 17) && (version_lo==10));
//XXX channel_manager_associate_control_channels(self->parent);
}
}
}
@@ -247,7 +237,7 @@ void ANTChannel::sendCinqoSuccess() {}
// We got a broadcast event -- this is where inbound
// telemetry gets processed, and for many message types
// we need to remember previous messages to look at the
// deltas during the period XXX this needs fixing!
// deltas during the period
//
void ANTChannel::broadcastEvent(unsigned char *ant_message)
{
@@ -351,7 +341,7 @@ void ANTChannel::broadcastEvent(unsigned char *ant_message)
}
break;
default: //XXX need to support Powertap/Quarq too!!
default:
break;
}
@@ -376,7 +366,7 @@ void ANTChannel::broadcastEvent(unsigned char *ant_message)
float cadence = 2000.0 * 60 * (antMessage.eventCount - lastMessage.eventCount) / period;
float power = 3.14159 * nm_torque * cadence / 30;
// ignore the occassional spikes XXX is this a boundary error on event count ?
// ignore the occassional spikes (reed switch)
if (power >= 0 && power < 2501 && cadence >=0 && cadence < 256) {
value2 = value = power;
is_alt ? parent->setAltWatts(power) : parent->setWatts(power);
@@ -386,8 +376,6 @@ void ANTChannel::broadcastEvent(unsigned char *ant_message)
} else {
nullCount++;
//antMessage.type = 0; // we need a new data pair XXX bad!!!
if (nullCount >= 4) { // 4 messages on an SRM
value2 = value = 0;
is_alt ? parent->setAltWatts(0) : parent->setWatts(0);
@@ -421,7 +409,7 @@ void ANTChannel::broadcastEvent(unsigned char *ant_message)
} else {
nullCount++;
if (nullCount >= 4) { // 4 messages on Powertap ? XXX validate this
if (nullCount >= 4) { // 4 messages on Powertap according to specs
parent->setWheelRpm(0);
value2 = value = 0;
is_alt ? parent->setAltWatts(0) : parent->setWatts(0);
@@ -448,7 +436,7 @@ void ANTChannel::broadcastEvent(unsigned char *ant_message)
parent->setCadence(antMessage.instantCadence); // cadence
} else {
stdNullCount++;
if (stdNullCount >= 6) { //XXX 6 for standard power?
if (stdNullCount >= 6) { //6 for standard power according to specs
parent->setCadence(0);
is_alt ? parent->setAltWatts(0) : parent->setWatts(0);
value2 = value = 0;
@@ -482,7 +470,7 @@ void ANTChannel::broadcastEvent(unsigned char *ant_message)
} else {
nullCount++;
if (nullCount >= 4) { //XXX 4 on a quarq??? validate this
if (nullCount >= 4) { // 4 on a quarq according to specs
parent->setCadence(0);
is_alt ? parent->setAltWatts(0) : parent->setWatts(0);
value2 = value = 0;
@@ -491,7 +479,7 @@ void ANTChannel::broadcastEvent(unsigned char *ant_message)
}
break;
default: // UNKNOWN POWER DEVICE? XXX Garmin (Metrigear) Vector????
default: // UNKNOWN
break;
}
break;
@@ -622,10 +610,6 @@ void ANTChannel::channelId(unsigned char *ant_message) {
parent->sendMessage(ANTMessage::setSearchTimeout(number, (int)(timeout_lost/2.5)));
}
channel_type_flags &= ~CHANNEL_TYPE_QUICK_SEARCH;
//XXX channel_manager_start_waiting_search(self->parent);
// if we are quarq channel, hook up with the ant+ channel we are connected to
//XXX channel_manager_associate_control_channels(self->parent);
}
// get ready to burst
@@ -650,7 +634,7 @@ void ANTChannel::burstData(unsigned char *ant_message) {
const unsigned char next_sequence[4]={1,2,3,1};
if (seq!=rx_burst_next_sequence) {
// XXX handle errors
// we don't handle burst data at present.
} else {
int len=ant_message[ANT_OFFSET_LENGTH]-3;
@@ -666,7 +650,7 @@ void ANTChannel::burstData(unsigned char *ant_message) {
if (last) {
if (rx_burst_disposition) {
//XXX what does this do? rx_burst_disposition();
// we don't handle burst data at present.
}
burstInit();
}
@@ -761,20 +745,7 @@ void ANTChannel::setTimeout(int seconds)
parent->sendMessage(ANTMessage::setSearchTimeout(number, seconds/2.5));
}
#if 0 // ARE NOW SIGNALS
// These should emit signals to notify the channel manager
// but for now we just ignore XXX fix this
void ANTChannel::searchComplete() {}
void ANTChannel::searchTimeout() {}
void ANTChannel::staleInfo() {}
void ANTChannel::lostInfo() {}
void ANTChannel::dropInfo() {}
void ANTChannel::channelInfo() {}
#endif
//
// Calibrate... XXX not used at present
//
// Calibrate... needs fixing in version 3.1
// request the device on this channel calibrates itselt
void ANTChannel::requestCalibrate() {
parent->sendMessage(ANTMessage::requestCalibrate(number));

View File

@@ -313,9 +313,9 @@ ANTMessage::ANTMessage(ANT *parent, const unsigned char *message) {
// the data page identifier tells us what to
// expect, but USAGE DIFFERS BY DEVICE TYPE:
//
// XXX at present we just extract the basic telemetry
// at present we just extract the basic telemetry
// based upon device type, these pages need to be
// supported in the next update
// supported in the next update (possibly v3.1)
//
// HEARTRATE (high bit is used to indicate data changed)
// (every 65th message is a background data message)
@@ -372,7 +372,7 @@ ANTMessage::ANTMessage(ANT *parent, const unsigned char *message) {
break;
/*
* these are not supported at present! XXX
* these are not supported at present:
* power calibration_request None,channel,0x01,0xAA,None,None,None,None,None,None
* power srm_zero_response None,channel,0x01,0x10,0x01,None,None,None,uint16_be:offset
* power calibration_pass None,channel,0x01,0xAC,uint8:autozero_status,None,None,None,uint16_le:calibration_data
@@ -465,7 +465,7 @@ ANTMessage::ANTMessage(ANT *parent, const unsigned char *message) {
autoZeroStatus = message[6] & 0x02;
break;
default: // XXX calib support for Quarq/PT
default:
break;
}