Reworked driver code, again.

This commit is contained in:
2026-01-03 20:10:30 +01:00
parent 68680db6b4
commit 3a132bb584
22 changed files with 228 additions and 184 deletions

View File

@@ -35,37 +35,61 @@
#include <bctransmitter.h>
/**
* @brief Kosntruktion. Aktiviert erstmal den Dummy-Driver.
*/
BCTransmitter::BCTransmitter(QObject *parent)
: QObject(parent), _isBusy(false)
{
//_canDriver = new BCDriverTinyCan{this};
_canDriver = new BCDriverDummy{this};
// forward driver state
connect( _canDriver, &BCDriver::driverStateChanged, this, &BCTransmitter::driverStateChanged );
_canDriver = &_dummyDriver;
}
/**
* @brief Steuert die Verbindung mit dem 'echten' CAN-Bus Treiber.
* @param connect true: Vesuche den CAN-Bus Treiber zu laden und zu verbinden
* false: Disconnect & Cleanup
*/
void BCTransmitter::onToggleConnectionState( bool connect )
void BCTransmitter::onToggleDriverConnection( bool connect )
{
if( connect )
qDebug() << " --- onToggleDriverConnection: " << connect;
// FIX! Ende der current op abwarten!
// weitere operation stoppen
_isBusy = true;
connect ? connectCanDriver() : disconnectCanDriver();
}
void BCTransmitter::connectCanDriver()
{
// hier gehts nur um den echten Treiber
// Treiber laden und/oder starten:
if( _tinyCanDriver.getDriverState() != BCDriver::DriverState::DeviceReady )
_tinyCanDriver.loadAndStartDriver();
// hat geklappt
if( _tinyCanDriver.getDriverState() == BCDriver::DriverState::DeviceReady )
{
if( _canDriver->getDriverState() != BCDriver::DriverState::DeviceReady )
_canDriver->onStartDriver();
uint32_t console = static_cast<uint32_t>(BCDevice::ID::Console);
uint8_t hwRev = static_cast<uint8_t> (BC::ID::Cons_Rev_Hw);
// __fix!
TransmitResult hwVersion = _canDriver->readRawByte( (uint32_t)BCDevice::ID::Console, (uint8_t)BC::ID::Cons_Rev_Hw);
if(!hwVersion)
{
qDebug() << "Console not responding";
}
TransmitResult hwVersion = _tinyCanDriver.readRawByte( console, hwRev);
if( hwVersion.has_value() )
qDebug() << " ---- HAIL to the king!";
else
{
}
qDebug() << " ---HAIL to the kings: " << hwVersion.value();
qDebug() << "Console not responding";
}
}
void BCTransmitter::disconnectCanDriver()
{
}