Error Handling

Forum for software developers to discuss BCI2000 software development
Locked
timo.veldt
Posts: 23
Joined: 12 Feb 2010, 04:08

Error Handling

Post by timo.veldt » 08 Mar 2010, 06:20

Another question... :oops:

As said, I'm working on my own application to present stimuli.

I've noticed that when I run the "gUSBampSource.exe" module with my amplifier turned off, the preflight gives me an error about this, resulting in a disabled start button.
However, when looking at the code that is responsible, I cannot find the section that is responsible for this. Since I'm using custom hardware, it would be nice to be able offer the same kind of functionality.

So when an error occurs during preflight, how do I make sure the user cannot start the experiment?

mellinger
Posts: 1341
Joined: 12 Feb 2003, 11:06

Post by mellinger » 08 Mar 2010, 07:41

So when an error occurs during preflight, how do I make sure the user cannot start the experiment?
Just write an error message into the bcierr stream, and flush the stream using an endl manipulator, e.g.

Code: Select all

bcierr << "An error occurred." << std::endl;
O return from Preflight(), the bcierr stream is checked for messages, and the start button is disabled if there are any.

The respective code is located at
http://www.bci2000.org/tracproj/browser ... e.cpp#L434
The operator module does not enable the Start button unless it received "initialized" messages from all modules.

For more information about BCI2000 error handling, see
http://www.bci2000.org/wiki/index.php/P ... r_Handling.
Last edited by mellinger on 08 Mar 2010, 13:36, edited 1 time in total.

timo.veldt
Posts: 23
Joined: 12 Feb 2010, 04:08

Post by timo.veldt » 08 Mar 2010, 09:04

Writing an std::endl character to the buffer does not necessarily flush it, however by calling the following code at the end of the preflight method, you can make sure the buffer gets flushed:

Code: Select all

void Application::Preflight(const SignalProperties& Input, SignalProperties& Output) const{
//Check parameters here

bcierr.flush();
}
So just before the function returns, call the flush method on the bcierr-channel.

mellinger
Posts: 1341
Joined: 12 Feb 2003, 11:06

Post by mellinger » 08 Mar 2010, 12:24

std::endl is not a newline character but a so-called manipulator that inserts a newline operator and then calls flush() on the buffer:
http://www.dinkumware.com/manuals/?manu ... .html#endl

So there is no need to call flush() at the end of Preflight().

Locked

Who is online

Users browsing this forum: No registered users and 0 guests