This commit is contained in:
2026-01-01 23:01:31 +01:00
parent a3dac8e4f8
commit dce792e00d
7 changed files with 49 additions and 86 deletions

View File

@@ -127,14 +127,14 @@ BCDriver::DriverState BCDriverTinyCan::connectDriver()
unsigned int retry = cTimeOuts;
emit driverStateChanged( _driverState, "Driver Init: putting Console in slave mode ... " );
TransmitResult isSlave = 0;
TransmitResult isSlave = 0;
do
{
writeRawByte( console, slaveFlag, 1 );
isSlave = readRawByte( console, slaveFlag );
bc::delay_millis( 200 );
{
writeRawByte( console, slaveFlag, 1 );
isSlave = readRawByte( console, slaveFlag );
bc::delay_millis( 200 );
} while( retry-- && !(*isSlave) );
} while( retry-- && !(*isSlave) );
bc::delay_millis( 500 ); // give the Console some time to settle
//if( !isSlave )
@@ -156,9 +156,6 @@ BCDriver::DriverState BCDriverTinyCan::connectDriver()
{
::CanDownDriver();
::UnloadDriver();
// re-throw
throw BCException( except.what() );
}
*/
@@ -168,14 +165,11 @@ BCDriver::TransmitResult BCDriverTinyCan::readRawByte( uint32_t deviceID, uint8_
{
//TransmitResult
qDebug() << " --- DriverState: " << _driverState;
qDebug() << " --- BCDriverTinyCan::readRawByte DriverState: " << getDriverState();
if( getDriverState() != DriverState::DeviceReady)
return std::unexpected(QString("readRawValue error: driver not loaded." ) );
/*
Nicht hier!
if( getState() != DriverState::DeviceReady)
//throw BCException( "readRawValue error: driver not loaded." );
return std::nullopt;
*/
::TCanMsg msg;
// msg verpacken
@@ -197,7 +191,7 @@ BCDriver::TransmitResult BCDriverTinyCan::readRawByte( uint32_t deviceID, uint8_
bc::delay_millis( cTIMEOUT_MS );
if( timeOuts == -1 )
return std::unexpected(QString("readRawValue error: could not send value" ));
return std::unexpected(QString("readRawValue error: could not send value" ));
retry:
@@ -238,11 +232,9 @@ retry:
BCDriver::TransmitResult BCDriverTinyCan::writeRawByte( uint32_t deviceID, uint8_t registerID ,uint8_t value ) const
{
/*
Nicht hier!
if( getState() != DriverState::DeviceReady)
throw BCException( "writeRawValue error: driver not loaded." );
*/
if( getDriverState() != DriverState::DeviceReady)
return std::unexpected(QString("writeRawValue error: driver not loaded." ) );
qDebug() << " --- BCDriverTinyCan writeRawValue: " << value;
::TCanMsg msg;