Added dummy can driver.
This commit is contained in:
42
bcdriver.cpp
42
bcdriver.cpp
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user