The complete C++ BCI code
This is the documentation for the Windows C++ code - the Linux documentation will be available soon.
In this chapter, you can find the functions of the C++ code, whose usage is not possible in the BCI module.
They are called by the externally used functions documented in the last chapter.
Here, they are documented in case you want to help developing these ‘foundations’. The C++ code is also explained in-code (f.i., the various variables),
so that hopefully you should not have problems trying to understand it.
class tcp(int argc, char** argv, unsigned int mode, unsigned int channum, signed int level)
The class constructor is started externally by start_bci (see also for parameters). Starts the connection to the server,
preparing, and the reading and signing (if specified) threads.
void connect_tcp(int argc, char** argv)
- The connection to the TCP/IP-Port is established, socket is initialized. ‘Localhost’ is assumed if no argument is specified (this part of the script has been inherited from Brain Vision). Called by class constructor.
void init_returning_speed(signed int level)
- Sets the initial speed level value. See set_returning_speed for the level explanations
- The block size and the number of samples in one block is detected, data arrays with required size are allocated. Returns after first data message.
int GetServerMessage(SOCKET socket, RDA_MessageHeader** ppHeader)
- The TCP/IP-Port is accessed to check incoming messages from Brain Vision Recorder software (this part of the script has been inherited from Brain Vision).
The number that is returned indicates either start or stop of the Recorder or incoming data. The detailed structure of the message is defined in RDARecorder.h.
The socket has been declared in connect_tcp.
DWORD WINAPI reading_thread(LPVOID param)
- Separate thread for starting the data process - starts receiving data by calling get_data.
- Receives message types in an infinite loop until reading is set false (end_bci). If a data message is available, read_data is called to read the data.
void read_data(RDA_MessageData* pMsg)
- Called by get_data if data is available. Data is stored in the data arrays until they are filled, then an event (triggers the waiting function in
demanding_access) is raised to sign data available for returning.
DWORD WINAPI sign(LPVOID param)
- If the mode is SIGNS_AVAILABLE, this function is called by bci_source to create a parallel thread to give signs as blinking shapes
(triangles or squares) for a specified time by give_sign.
- The OpenGL Glut library with the necessary parameters is initialized.
- This function draws the specified shape. It is called each time when the window is redisplayed - this is triggered by give_sign.
AUX_RGBImageRec *LoadBMP(char *Filename)
- Used internally to load BMP image files.
int LoadGLTextures(char *Filename, unsigned int numof_texture)
- Loads BMP image files and converts them to textures .
- Loads inpout32.dll und gets port adresses.
short Inp32(short portaddr)
- Reads the parallel port.
void Out32(short portaddr, short trigger)
- Sends a signal via parallel port. Arguments are port adress and signal.