check for unreasonable speeds, and patches from Aldy

This commit is contained in:
Sean C. Rhea
2007-02-11 18:40:14 +00:00
parent 4283c5b408
commit 491ef5c639
2 changed files with 13 additions and 7 deletions

View File

@@ -141,10 +141,10 @@ DownloadRideDialog::time_cb(struct tm *time)
QMessageBox::critical(this, tr("Read error"),
tr("Can't find ride time"));
reject();
}
sprintf(outname, "%04d_%02d_%02d_%02d_%02d_%02d.raw",
time->tm_year + 1900, time->tm_mon + 1, time->tm_mday,
time->tm_hour, time->tm_min, time->tm_sec);
} else
sprintf(outname, "%04d_%02d_%02d_%02d_%02d_%02d.raw",
time->tm_year + 1900, time->tm_mon + 1, time->tm_mday,
time->tm_hour, time->tm_min, time->tm_sec);
assert(strlen(outname) == sizeof(outname) - 1);
label->setText(label->text() + tr("done.\nWriting to ")
+ outname + ".");

View File

@@ -60,7 +60,7 @@ pt_find_device(char *result[], int capacity)
struct dirent *dp;
int count = 0;
if (regcomp(&reg,
"^(cu\\.(usbserial-[0-9A-F]+|KeySerial[0-9])|ttyUSB[0-9])$",
"^(cu\\.(usbserial-[0-9A-F]+|KeySerial[0-9])|ttyUSB[0-9]|ttyS[0-2])$",
REG_EXTENDED|REG_NOSUB)) {
assert(0);
}
@@ -76,10 +76,12 @@ pt_find_device(char *result[], int capacity)
}
#define KSDEVSTR "/dev/cu.KeySerial"
#define LINUXSERIALSTR "/dev/ttyS"
int
pt_hwecho(const char *device)
{
return strncmp(device, KSDEVSTR, strlen(KSDEVSTR)) == 0;
return (strncmp(device, KSDEVSTR, strlen(KSDEVSTR)) == 0
|| strncmp(device, LINUXSERIALSTR, strlen(LINUXSERIALSTR)) == 0);
}
void
@@ -434,7 +436,11 @@ pt_unpack_data(unsigned char *buf, int compat, unsigned rec_int,
if (torque_inlbs == 0xfff)
torque_inlbs = 0;
speed = ((buf[1] & 0x0f) << 8) | buf[3];
if ((speed == 0) || (speed == 0xfff)) {
if ((speed < 100) || (speed == 0xfff)) {
if ((speed != 0) && (speed < 1000)) {
fprintf(stderr, "possible error: speed=%.1f; ignoring it\n",
MAGIC_CONSTANT / speed / 10.0);
}
*mph = -1.0;
*watts = -1.0;
}