Skip to content

Commit

Permalink
fixed stream shutdown bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Flydroid committed Jul 14, 2017
1 parent a1a7409 commit 0e13689
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 29 deletions.
8 changes: 4 additions & 4 deletions src/ak_logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ void AKLogger::addOutputStream(OutputStream *ostream) {
} else {
Serial.println("Failed to open '" + ostream->getName() + "': " + String(err));
}
writeHeader();
}

void AKLogger::addInputStream(InputStream* istream) {
Expand Down Expand Up @@ -122,16 +121,17 @@ void AKLogger::closeAndDeleteOutputStreams() {
(*it)->close();
Serial.println("Successully closed '"+ (*it)->getName()+"'");
delete &(*it);
it = ostreams.erase(it);
}
ostreams.clear();
}

void AKLogger::closeAndDeleteInputStreams() {
for(SimpleList<InputStream*>::iterator it = istreams.begin(); it != istreams.end(); it++) {
for(SimpleList<InputStream*>::iterator it = istreams.begin(); it != istreams.end();it++ ) {
(*it)->close();
Serial.println("Successully closed '"+ (*it)->getName()+"'");
delete &(*it);
it = istreams.erase(it);


}
istreams.clear();
}
24 changes: 1 addition & 23 deletions src/main.ino
Original file line number Diff line number Diff line change
Expand Up @@ -26,29 +26,6 @@ TinyGPSPlus gps;

elapsedMillis log_timer;
elapsedMillis gps_timer;
/*
bool millisElapsed(int milliseconds) {
static elapsedMillis timer;
if(timer>milliseconds) {
timer = 0;
return true;
}
return false;
}
*/

/*
void setupOutputStreams() {
logger.addOutputStream(new ConsoleStream);
logger.addOutputStream(new SDCardStream("flug","log"));
}
void setupInputStreams() {
logger.addInputStream(new TimeStream);
logger.addInputStream(new SensirionStream);
}
*/

void setupSerialPort() {
Serial.begin(115200);
Expand Down Expand Up @@ -134,6 +111,7 @@ void loop() {
logger.addOutputStream(new ConsoleStream);
logger.addInputStream(new TimeStream);
logger.addInputStream(new SensirionStream);
logger.writeHeader();
}
if (velocity ==0 && logger.isActive) {
Serial.println("Logger is off");
Expand Down
2 changes: 1 addition & 1 deletion src/sdcard_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ int SDCardStream::open() {
}

fullName = filename + "." + fileextension;
Serial.println(fullName);

if(!logFile.open(fullName.c_str(), O_CREAT | O_WRITE | O_EXCL)){
sd.errorHalt("open file failed");
}
Expand Down
1 change: 0 additions & 1 deletion src/sensirion_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ int SensirionStream::open() {

int SensirionStream::close() {
sensor.reset();

return AKSTREAM_SUCC;
}

Expand Down
1 change: 1 addition & 0 deletions src/time_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ int TimeStream::open() {
}

int TimeStream::close() {

return AKSTREAM_SUCC;
}

Expand Down

0 comments on commit 0e13689

Please sign in to comment.