Permalink
Browse files

Added in a gaurd to protect against calling processSignal within an i…

…nterrupt handler.
  • Loading branch information...
1 parent 21b58fc commit 9db84aac06c06d07f2f4b1d9ac14c7128eee98ef @ashgti committed Apr 1, 2011
Showing with 11 additions and 0 deletions.
  1. +1 −0 include/ardulator.h
  2. +10 −0 src/ardulator.cc
View
@@ -52,6 +52,7 @@ class Ardulator {
std::string _registered_identifers;
ardu_clock_t _timer;
ardu_clock_t _scenario_length;
+ bool _inside_interrupt_handler;
void updatePinState();
void updatePinMaps();
View
@@ -53,6 +53,7 @@ Ardulator::Ardulator() : _interrupts(false) {
_scenario_length._seconds = 0;
_scenario_length._ticks = 0;
_registered_identifers = "";
+ _inside_interrupt_handler = false;
}
Ardulator::~Ardulator() {
@@ -184,6 +185,7 @@ Ardulator::updatePinState() {
// Report Changes in State
map<int, Signal*>::iterator it;
int c = 0;
+ _inside_interrupt_handler = true;
for (it = _signals.begin(); it != _signals.end(); it++) {
c++;
// cout << "Updating " << it->first << endl;
@@ -194,6 +196,8 @@ Ardulator::updatePinState() {
for (vit = _unused_signals.begin(); vit != _unused_signals.end(); vit++) {
(*vit)->setState(_timer);
}
+
+ _inside_interrupt_handler = false;
}
void
@@ -245,6 +249,12 @@ Ardulator::setPin(uint8_t pin_id, uint8_t val) {
void
Ardulator::dispatchSignal(const char *signal_id) {
+ if (_inside_interrupt_handler) {
+ cout << "Error, processingSignal " << signal_id << " while within an interrupt"
+ << " handler is not allowed." << endl;
+ exit(12);
+ }
+
if (_mapping.find(signal_id) == _mapping.end()) {
return;
}

0 comments on commit 9db84aa

Please sign in to comment.