Skip to content

Commit

Permalink
Added pure virtual function definitions and error handler to make com…
Browse files Browse the repository at this point in the history
…mandline compile not complain
  • Loading branch information
lokling committed Dec 1, 2010
1 parent 423d260 commit 1f42cb1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 4 additions & 0 deletions AeroQuad.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -367,4 +367,8 @@ float findMode(float *data, int arraySize); // defined in Sensors.pde
int findMode(int *data, int arraySize); // defined in Sensors.pde int findMode(int *data, int arraySize); // defined in Sensors.pde
#endif #endif


// Error handling of virtual functions of Receiver and Motors base classes
extern "C" void __cxa_pure_virtual() { Serial.print("ERROR: Virtual function called! "); }




6 changes: 3 additions & 3 deletions Motors.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ class Motors {
}; };


// The following function calls must be defined in any new subclasses // The following function calls must be defined in any new subclasses
virtual void initialize(void); virtual void initialize(void) = 0;
virtual void write (void); virtual void write (void) = 0;
virtual void commandAllMotors(int motorCommand); virtual void commandAllMotors(int motorCommand) = 0;


//Any number of optional methods can be configured as needed by the SubSystem to expose functionality externally //Any number of optional methods can be configured as needed by the SubSystem to expose functionality externally
void pulseMotors(byte quantity) { void pulseMotors(byte quantity) {
Expand Down
6 changes: 3 additions & 3 deletions Receiver.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Receiver {
float bTransmitter[6]; float bTransmitter[6];
unsigned long currentTime, previousTime; unsigned long currentTime, previousTime;


Receiver(void) { Receiver(void) {
transmitterCommand[ROLL] = 1500; transmitterCommand[ROLL] = 1500;
transmitterCommand[PITCH] = 1500; transmitterCommand[PITCH] = 1500;
transmitterCommand[YAW] = 1500; transmitterCommand[YAW] = 1500;
Expand All @@ -50,8 +50,8 @@ class Receiver {
// ****************************************************************** // ******************************************************************
// The following function calls must be defined in any new subclasses // The following function calls must be defined in any new subclasses
// ****************************************************************** // ******************************************************************
virtual void initialize(void); virtual void initialize(void) = 0;
virtual void read(void); virtual void read(void) = 0;


// ************************************************************** // **************************************************************
// The following functions are common between all Gyro subclasses // The following functions are common between all Gyro subclasses
Expand Down

0 comments on commit 1f42cb1

Please sign in to comment.