Driver SDK  1.6
Modules | Functions | Variables
Recording Management

Modules

 Battery level constants
 Possible values for the output parameter battery of function bbt_driver_read().
 
 Record flags constants
 

Functions

BBT_SDK_API int bbt_driver_start (bbt_driver_t *driver)
 Stars a new recording. More...
 
BBT_SDK_API int bbt_driver_stop (bbt_driver_t *driver)
 Stops the current recording. More...
 
BBT_SDK_API int bbt_driver_is_running (const bbt_driver_t *driver)
 Checks if the recording is active. More...
 
BBT_SDK_API unsigned long bbt_driver_read_data_size (const bbt_driver_t *driver)
 Gets the size of the data vector read on each block depending on the configuration of the driver. More...
 
BBT_SDK_API double * bbt_driver_read (bbt_driver_t *driver, unsigned short *sequence, short *battery, unsigned short *flags)
 Reads one data message from the device. More...
 
BBT_SDK_API unsigned short bbt_driver_get_eeg_impedance (const bbt_driver_t *driver, unsigned short index)
 Reads the impedance value for the index channel of the EEG signal (if any) More...
 

Variables

BBT_SDK_API const unsigned short bbt_driver_impedance_unknown
 bbt_driver_impedance_unknown
 
BBT_SDK_API const unsigned short bbt_driver_impedance_saturated
 bbt_driver_impedance_saturated
 
BBT_SDK_API const unsigned short bbt_driver_impedance_bad
 bbt_driver_impedance_bad
 
BBT_SDK_API const unsigned short bbt_driver_impedance_fair
 bbt_driver_impedance_fair
 
BBT_SDK_API const unsigned short bbt_driver_impedance_good
 bbt_driver_impedance_good
 

Detailed Description

Functions manage the recording of data

if (bbt_driver_start(driver))
{
std::cout << "recording started\n";
auto count = 0;
while (count < time * bbt_driver_get_frequency(driver)) { //reads for some seconds (of correct data)
{
std::cout << "reconnect\n";
continue;
}
//restart if not running (the device has been reset)
if (!bbt_driver_is_running(driver))
{
std::cout << "restart\n";
//CAUTION HERE: If sd is configured, the
/*
std::ostringstream filename;
filename << "a_file_name_" << count << ".sdf";
bbt_driver_set_file(driver, filename.str().c_str());
*/
}
if (!read(driver))
continue;
count++;
}
if (bbt_driver_stop(driver)) {
std::cout << "recording stopped\n";
} else
std::cout << "Unable to stop recording\n";
} else
{
std::cout << "Unable to start recording\n";
}
BBT_SDK_API int bbt_driver_is_connected(const bbt_driver_t *driver)
Checks if the driver is connected to the device.
BBT_SDK_API void bbt_driver_reconnect(bbt_driver_t *driver)
Reconnects to the device associated.
BBT_SDK_API unsigned short bbt_driver_get_frequency(const bbt_driver_t *driver)
Gets the number of data messages sent by the device each second.
BBT_SDK_API int bbt_driver_start(bbt_driver_t *driver)
Stars a new recording.
BBT_SDK_API int bbt_driver_is_running(const bbt_driver_t *driver)
Checks if the recording is active.
BBT_SDK_API int bbt_driver_stop(bbt_driver_t *driver)
Stops the current recording.

Function Documentation

◆ bbt_driver_start()

BBT_SDK_API int bbt_driver_start ( bbt_driver_t driver)

Stars a new recording.

The device is commanded to start registering the signals configured and sending them to the driver. If the sd card is enabled, the data will also be recorded internally in the device. Take care that any file in the sd card with the same path will be overwriten at this point. You can change the path with bbt_driver_set_folder and bbt_driver_set_file

Parameters
[in]driver
Precondition
The object driver must be not NULL
Returns
True on success
Examples
example/main.cpp.

◆ bbt_driver_stop()

BBT_SDK_API int bbt_driver_stop ( bbt_driver_t driver)

Stops the current recording.

The device is commanded to stop registering.

Parameters
[in]driver
Precondition
The object driver must be not NULL
Returns
True on success
Examples
example/main.cpp.

◆ bbt_driver_is_running()

BBT_SDK_API int bbt_driver_is_running ( const bbt_driver_t driver)

Checks if the recording is active.

Parameters
[in]driverThe driver object
Precondition
The object driver must be not NULL
Returns
TRue if a recording is taking place
Examples
example/main.cpp.

◆ bbt_driver_read_data_size()

BBT_SDK_API unsigned long bbt_driver_read_data_size ( const bbt_driver_t driver)

Gets the size of the data vector read on each block depending on the configuration of the driver.

Parameters
driver
Returns
The length of the data vector returned by function bbt_driver_read
Examples
example/main.cpp.

◆ bbt_driver_read()

BBT_SDK_API double* bbt_driver_read ( bbt_driver_t driver,
unsigned short *  sequence,
short *  battery,
unsigned short *  flags 
)

Reads one data message from the device.

Parameters
[in]driverThe driver object
[out]sequenceThe number of the sequence of the message. The memory is managed by the user.
[out]batteryThe level of the battery of the device. See Battery level constants for more info. The memory is managed by the user.
[out]flagsError flags that alerts about internal problems of the device. See Record flags constants for more info. The memory is managed by the user.
Precondition
All the parameters must be not NULL
Returns
A pointer to the vector of data on success. NULL on read timeout or error. The length of the vector is determined by bbt_driver_read_data_size

This function tries to read a data message from the device. The device must be connected and running. The fields data, sequence, battery and flags are filled up with the last data received. No internal buffering is performed. Every time the read function is called, the data stored is overwritten. Extra buffering must be done externally by the user.

Data vector format

The data vector is a list of data_size doubles with all the data from the signals recorded in the device. It is composed by the concatenation of the signal data blocks as specified by the configuration (see Device Configuration). Only signals enabled (mode > 0) will provide data. The order of the indexes in bbt_driver_get_signal is kept for the data read from different signals. Inside each signal data block, the values are arranged in a channels x samples matrix, as returned by bbt_signal_get_channels and bbt_signal_get_samples, respectively.

As returned in a 1d vector, the matrix is rearranged in channels, i.e. all the samples of one channel are provided before moving to the next channel.

Example

Let's supose we have a 16 channel EEG device. Using the functions from Device Configuration, we can configure the device as follows:

signal channels samples mode
EEG 16 8 1
IMU 9 1 0
Photodiode 1 8 0
D in 1 8 1

This means that the bbt_driver_read function will set the parameter data_size value to 16 * 8 + 1 * 8 = 136.

Also, the data parameter will contain 136 doubles with the following organization:

  • 8 samples of the 1st EEG channel
  • 8 samples of the 2nd EEG channel
  • 8 samples of the 3rd EEG channel
  • ...
  • 8 samples of the 16th EEG channel
  • 8 samples of the unique Digital input channel
Examples
example/main.cpp.

◆ bbt_driver_get_eeg_impedance()

BBT_SDK_API unsigned short bbt_driver_get_eeg_impedance ( const bbt_driver_t driver,
unsigned short  index 
)

Reads the impedance value for the index channel of the EEG signal (if any)

Parameters
driverThe driver object
indexThe number of EEG channel
Returns
The impedance level of the EEG channel or bbt_driver_impedance_unknown if not a valid EEG channel
Examples
example/main.cpp.