Added support for old Daum devices before 2001 (#4303)

Old Daum Electronic device "Ergobike Cardio" (comparable to the 4008 series and many other bikes) from before 2001 uses a slightly different RS232 protocol in some of the cases, which can be found here: http://www.ergo-lyps.de/de/download/v01/schnitt.zip . Additionally, it uses a boud rate of 4800.

As the old devices can not be detected by the checkversion (was not implemented at that time) I used a _profile of "OLD_DAUM" to identify the device in the configuration setting.
This commit is contained in:
LateNightCoder0815
2024-04-21 13:45:54 +02:00
committed by GitHub
parent 71c72d665f
commit 02835e3eb5

View File

@@ -120,7 +120,11 @@ bool Daum::openPort(QString dev) {
}
serial_dev_->setPortName(dev);
serial_dev_->setBaudRate(QSerialPort::Baud9600);
if (profile_ == "OLD_DAUM") {
serial_dev_->setBaudRate(QSerialPort::Baud4800); // Old cockpits use 4800 Baud
} else {
serial_dev_->setBaudRate(QSerialPort::Baud9600);
}
serial_dev_->setStopBits(QSerialPort::OneStop);
serial_dev_->setDataBits(QSerialPort::Data8);
serial_dev_->setFlowControl(QSerialPort::NoFlowControl);
@@ -207,8 +211,14 @@ void Daum::initializeConnection() {
QThread::msleep(100);
// check version info for know devices
int dat = GetDeviceVersion();
int dat;
if (profile_ == "OLD_DAUM") {
qDebug() << "Daum cockpit: using old serial interface type";
dat = COCKPIT_8008; // Old cockpits do not have a version information. Use 8008 timing
} else {
// check version info for know devices
dat = GetDeviceVersion();
}
if (configureForCockpitType(dat)) {
qDebug() << "Daum cockpit type: " << Qt::hex << dat;
@@ -218,12 +228,14 @@ void Daum::initializeConnection() {
qWarning() << "unable to identify daum cockpit type" << Qt::hex << dat;
exit(-1);
}
if (!SetDate()) {
qWarning() << "set date failed";
}
if (!SetTime()) {
qWarning() << "set time failed";
if (profile_ != "OLD_DAUM") { // Function not available
if (!SetDate()) {
qWarning() << "set date failed";
}
if (!SetTime()) {
qWarning() << "set time failed";
}
}
if (!SetProgram(0)) {
@@ -299,8 +311,14 @@ void Daum::requestRealtimeData() {
data.clear();
data.append((char)0x40);
data.append(addr);
data = WriteDataAndGetAnswer(data, 19);
if (data.length() < 19) {
int answer_len = 19;
if (profile_ == "OLD_DAUM") {
answer_len = 17; // Old cockpits only send 17 bytes
}
data = WriteDataAndGetAnswer(data, answer_len);
if (data.length() < answer_len) {
return;
}
@@ -313,6 +331,9 @@ void Daum::requestRealtimeData() {
// sanity check
if (pwr >= 5 && pwr <= 160) {
int pedalling = data[4]; // either 0/1 or w/ offset of 128
if (profile_ == "OLD_DAUM") {
pedalling = (data[4] & 0x01); // Only use last bit for old cockpit
}
pwr = pwr * 5 * (pedalling != 0 ? 1 : 0);
} else {
pwr = 0;
@@ -369,11 +390,18 @@ void Daum::requestRealtimeData() {
bool Daum::ResetDevice() {
QByteArray dat;
dat.append((char)0x12).append(deviceAddress_);
return WriteDataAndGetAnswer(dat, 3).length() == 2; // device tells pedalling state too
int answer_len = 2;
if (profile_ == "OLD_DAUM") {
answer_len = 3; // Old cockpits send 3 bytes answer
}
return WriteDataAndGetAnswer(dat, 3).length() == answer_len; // device tells pedalling state too
}
int Daum::GetAddress() {
QByteArray dat;
dat.append((char)0x11);
if (profile_ == "OLD_DAUM") {
dat.append((char)0x00); // Old cockpits need additional 0 byte
}
dat = WriteDataAndGetAnswer(dat, 2);
if (dat.length() == 2 && (int)dat[0] == 0x11) {
return (int)dat[1];
@@ -404,7 +432,11 @@ bool Daum::SetProgram(unsigned int prog) {
QByteArray dat;
if (prog > 79) { prog = 79; } // clamp to max
dat.append((char)0x23).append(deviceAddress_).append((char)prog);
return WriteDataAndGetAnswer(dat, dat.length() + 1).length() == 4; // device tells pedalling state too
int answer_len = 4;
if (profile_ == "OLD_DAUM") {
answer_len = 3; // Old cockpits send 3 bytes answer
}
return WriteDataAndGetAnswer(dat, dat.length() + 1).length() == answer_len; // device tells pedalling state too
}
bool Daum::StartProgram(unsigned int prog) {
Q_UNUSED(prog);