diff --git a/bc.h b/bc.h index 3b92bc3..0ada14a 100644 --- a/bc.h +++ b/bc.h @@ -49,6 +49,7 @@ public: BCException( const QString& what, const QString& param="" ); BCException( const QString& what, int errCode ); + }; namespace bc diff --git a/bccandrivertinycan.cpp b/bccandrivertinycan.cpp index 8a4b137..7105250 100644 --- a/bccandrivertinycan.cpp +++ b/bccandrivertinycan.cpp @@ -29,12 +29,12 @@ BCCanDriver::DriverState BCCanDriverTinyCan::loadDriver() struct ::TDeviceStatus status; if( ::LoadDriver( NULL ) < 0 ) - throw std::runtime_error( "Driver Error: 'LoadDriver'" ); + throw BCException( "Driver Error: 'LoadDriver'" ); setState(BCCanDriver::DriverState::Loaded); if( ::CanInitDriver( NULL ) < 0 ) - throw std::runtime_error( "Driver Error: 'InitDriver'" ); + throw BCException( "Driver Error: 'InitDriver'" ); if( ::CanDeviceOpen( 0, NULL ) < 0 ) throw std::runtime_error( "Driver Error: 'DeviceOpen'" ); @@ -46,12 +46,12 @@ BCCanDriver::DriverState BCCanDriverTinyCan::loadDriver() setState(BCCanDriver::DriverState::Initialized); if( status.DrvStatus < DRV_STATUS_CAN_OPEN ) - throw std::runtime_error( "Driver Error: could not open device." ); + throw BCException( "Driver Error: could not open device." ); if( status.CanStatus == CAN_STATUS_BUS_OFF ) { ::CanSetMode( 0, OP_CAN_RESET, CAN_CMD_NONE ); - throw std::runtime_error( "Driver Error: CAN Status 'BusOff'" ); + throw BCException( "Driver Error: CAN Status 'BusOff'" ); } setState(BCCanDriver::DriverState::Ready); @@ -74,7 +74,7 @@ BCCanDriver::DriverState BCCanDriverTinyCan::loadDriver() ::UnloadDriver(); // re-throw - throw std::runtime_error( except.what() ); + throw BCException( except.what() ); } */ @@ -156,14 +156,14 @@ retry: bc::delay_millis( cTIMEOUT_MS ); if( timeOuts == -1 ) - throw std::runtime_error( "getValue error: no response from node" ); + throw BCException( "getValue error: no response from node" ); // message empfangen int err = ::CanReceive( 0, &msg, 1 ); qDebug() << "HÄÄ ?" << err << "reg: "<< reg <<" timeOuts: " << timeOuts; if( err < 0 ) - //throw std::runtime_error( "getValue error: could not receive value" ); + //throw BCException( "getValue error: could not receive value" ); qDebug( "getValue error: could not receive value" ); qDebug() << "HÄÄ 2" <; BCValueQueue _valueQueue; diff --git a/bcvalue.cpp b/bcvalue.cpp index 2a25ea4..6d86767 100644 --- a/bcvalue.cpp +++ b/bcvalue.cpp @@ -28,6 +28,7 @@ ***************************************************************************/ #include +#include #include @@ -60,8 +61,9 @@ BCValue::BCValue(const BCValueType& valueType_, BCDevice::ID deviceID_, BC::ID r void BCValue::readRawValue( const BCAbstractTransmitter& transmitter ) const { - bcdata_t result = transmitter.readRawValue( deviceID, registerID ); - + //bcdata_t result = transmitter.readRawValue( deviceID, registerID ); + bcdata_t myRandomByte = static_cast(QRandomGenerator::global()->bounded(256)); + value.fromValue( myRandomByte ); } void BCValue::writeRawValue( const BCAbstractTransmitter& transmitter ) const