Added dummy can driver.

This commit is contained in:
2025-12-30 14:42:49 +01:00
parent f170b3835d
commit fbeb4fb3c0
6 changed files with 73 additions and 16 deletions

View File

@@ -31,6 +31,7 @@
#include <QDebug>
#include <QRandomGenerator>
#include <bcdriver.h>
@@ -93,4 +94,45 @@ void BCDriver::onStartDriver()
}
/// -----------------------------------------------------------------------------------
/// -----------------------------------------------------------------------------------
/**
* @brief BCDriverDummy::BCDriverDummy
* @param parent
*/
BCDriverDummy::BCDriverDummy( QObject* parent )
: BCDriver(parent)
{
}
BCDriver::DriverState BCDriverDummy::loadDriver()
{
return BCDriver::DriverState::Ready;
}
BCDriver::DriverState BCDriverDummy::initDriver()
{
return DriverState::Ready;
}
uint32_t BCDriverDummy::readRawByte( uint32_t deviceID, uint8_t registerID ) const
{
//if( getState() != DriverState::Ready)
// throw BCException( "readRawValue error: driver not loaded." );
uint32_t myRandomByte = static_cast<uint32_t>(QRandomGenerator::global()->bounded(256));
return myRandomByte;
}
void BCDriverDummy::writeRawByte( uint32_t deviceID, uint8_t registerID, uint8_t value ) const
{
if( getState() != DriverState::Ready)
throw BCException( "readRawValue error: driver not loaded." );
qDebug() << " --- BCDriverTinyCan writeRawValue: " << value;
return;
}