Driver fixes.
This commit is contained in:
@@ -56,33 +56,23 @@ BCTransmitter::BCTransmitter(QObject *parent)
|
||||
|
||||
void BCTransmitter::onToggleDriverConnection( bool connect )
|
||||
{
|
||||
//qDebug() << " --- onToggleDriverConnection: " << connect;
|
||||
emit driverStateChanged(BCDriver::DriverState::Initialized, "BUSY!");
|
||||
bc::delay_millis(350);
|
||||
// kill all pending stuff
|
||||
QCoreApplication::removePostedEvents(this, QEvent::MetaCall);
|
||||
// FIX! Ende der current op abwarten!
|
||||
if( connect )
|
||||
emit driverStateChanged(BCDriver::DriverState::NotPresent, "Native Treiber wird geladen.");
|
||||
|
||||
/*
|
||||
// kill all pending stuff
|
||||
//QCoreApplication::removePostedEvents(this, QEvent::MetaCall);
|
||||
BCDriver::DriverState state = connect ? BCDriver::DriverState::DeviceReady : BCDriver::DriverState::NotPresent;
|
||||
const QString& message = connect ? "Trying to connect" : " FAILED";
|
||||
emit driverStateChanged(state, message);
|
||||
return;
|
||||
|
||||
/*
|
||||
// Hier sind wir noch in GUI Thread
|
||||
QMutexLocker locker(&_mutex);
|
||||
// weitere operation stoppen
|
||||
_isBusy = true;
|
||||
connect ? connectCanDriver() : disconnectCanDriver();
|
||||
_isBusy = false;
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
void BCTransmitter::onStartNativeDriver()
|
||||
{
|
||||
connect ? connectCanDriver() : disconnectCanDriver();
|
||||
|
||||
}
|
||||
|
||||
|
||||
void BCTransmitter::connectCanDriver()
|
||||
{
|
||||
// hier gehts nur um den echten Treiber
|
||||
@@ -92,38 +82,49 @@ void BCTransmitter::connectCanDriver()
|
||||
if( _tinyCanDriver.getDriverState() != BCDriver::DriverState::DeviceReady )
|
||||
result = _tinyCanDriver.loadAndStartDriver();
|
||||
|
||||
QString message("FitzeFatze!");
|
||||
// hat geklappt
|
||||
if( _tinyCanDriver.getDriverState() >= BCDriver::DriverState::Opened )
|
||||
{
|
||||
uint32_t console = static_cast<uint32_t>(BCDevice::ID::Console);
|
||||
uint8_t hwRev = static_cast<uint8_t> (BC::ID::Cons_Rev_Hw);
|
||||
|
||||
TransmitResult hwVersion = _tinyCanDriver.readRawByte( console, hwRev);
|
||||
if( hwVersion.has_value() )
|
||||
QString message("Treiber geladen (nicht verbunden)");
|
||||
|
||||
// Der result-Wert im ERfolgsfall ist der driver state.
|
||||
if(result.has_value() )
|
||||
{
|
||||
switch( result.value() )
|
||||
{
|
||||
message = " ---- HAIL to the king!";
|
||||
//qDebug() << message;
|
||||
// swap driver
|
||||
_canDriver = &_tinyCanDriver;
|
||||
}
|
||||
else
|
||||
{
|
||||
//qDebug() << "Console not responding";
|
||||
case BCDriver::DriverState::Opened:
|
||||
|
||||
message = "Treiber geladen (Device antwortet nicht)";
|
||||
break;
|
||||
|
||||
case BCDriver::DriverState::DeviceReady:
|
||||
|
||||
message = "Treiber geladen und Device verbunden.";
|
||||
// swap driver
|
||||
_canDriver = &_tinyCanDriver;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
else // Fehlerfall, wir holen die Fehlermeldung
|
||||
{
|
||||
message = result.error();
|
||||
}
|
||||
|
||||
emit driverStateChanged( _tinyCanDriver.getDriverState(), message );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Native-Treiber zurücksetzen, Dummy-Treiber wieder aktivieren.
|
||||
*/
|
||||
|
||||
void BCTransmitter::disconnectCanDriver()
|
||||
{
|
||||
_tinyCanDriver.resetDriver();
|
||||
_canDriver = &_dummyDriver;
|
||||
emit driverStateChanged( _tinyCanDriver.getDriverState(), "Disconnected" );
|
||||
emit driverStateChanged( _tinyCanDriver.getDriverState(), "Disconnected, Dummy Treiber aktiviert." );
|
||||
}
|
||||
|
||||
|
||||
@@ -143,8 +144,6 @@ void BCTransmitter::onUpdateValue( BCValuePtrConst valuePtr)
|
||||
// Kosmetik
|
||||
const BCValue& value = *(valuePtr.get());
|
||||
|
||||
//qDebug() << "------- DE.-.QUEUE: " << QThread::currentThreadId() << ": " << value.label;
|
||||
|
||||
uint32_t devID = static_cast<uint32_t>(value.deviceID);
|
||||
uint8_t regID = static_cast<uint8_t> (value.registerID);
|
||||
|
||||
@@ -167,6 +166,7 @@ void BCTransmitter::onUpdateValue( BCValuePtrConst valuePtr)
|
||||
{
|
||||
newState = BCValue::Flag::InSync;
|
||||
newValue = result.value();
|
||||
qDebug() << " ---- Wert empfangen: " << newValue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,7 +174,7 @@ void BCTransmitter::onUpdateValue( BCValuePtrConst valuePtr)
|
||||
|
||||
// __fix
|
||||
//bc::processEventsFor(150);
|
||||
bc::delay_millis(250);
|
||||
//bc::delay_millis(150);
|
||||
|
||||
}
|
||||
|
||||
@@ -186,14 +186,12 @@ void BCTransmitter::onUpdateValue( BCValuePtrConst valuePtr)
|
||||
|
||||
void BCTransmitter::onEndOfTransmission()
|
||||
{
|
||||
qDebug() << " --- sending BACK EOT";
|
||||
emit endOfProcessing();
|
||||
}
|
||||
|
||||
|
||||
TransmitResult BCTransmitter::readByteValue( uint32_t deviceID, uint8_t registerID )
|
||||
{
|
||||
////qDebug() << " --- YES: Read ByteValue: " << registerID;
|
||||
// Wir lesen nur ein Byte und gut.
|
||||
return _canDriver->readRawByte( deviceID, registerID );
|
||||
}
|
||||
@@ -201,8 +199,6 @@ TransmitResult BCTransmitter::readByteValue( uint32_t deviceID, uint8_t register
|
||||
|
||||
TransmitResult BCTransmitter::readWordValue( uint32_t deviceID, uint8_t registerID )
|
||||
{
|
||||
////qDebug() << " --- YES: Read WordValue: " << registerID;
|
||||
|
||||
uint32_t result{};
|
||||
// hi byte Leseversuch.
|
||||
TransmitResult value = _canDriver->readRawByte( deviceID, registerID );
|
||||
|
||||
Reference in New Issue
Block a user