MCPcopy Create free account
hub / github.com/brainflow-dev/brainflow / read_thread

Method read_thread

src/board_controller/openbci/ganglion.cpp:246–396  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

244}
245
246void Ganglion::read_thread ()
247{
248 // https://docs.openbci.com/Hardware/08-Ganglion_Data_Format
249 int num_attempts = 0;
250 int sleep_time = 10;
251 int max_attempts = params.timeout * 1000 / sleep_time;
252 float last_data[8] = {0};
253
254 double acceleration[3] = {0.};
255
256 double resist_ref = 0.0;
257 double resist_first = 0.0;
258 double resist_second = 0.0;
259 double resist_third = 0.0;
260 double resist_fourth = 0.0;
261
262 int (*func) (void *) = (int (*) (void *))dll_loader->get_address ("get_data");
263 if (func == NULL)
264 {
265 safe_logger (spdlog::level::err, "failed to get function address for get_data");
266 return;
267 }
268
269 int num_rows = board_descr["default"]["num_rows"];
270 double *package = new double[num_rows];
271
272 while (keep_alive)
273 {
274 for (int i = 0; i < num_rows; i++)
275 {
276 package[i] = 0.0;
277 }
278
279 struct GanglionLib::GanglionData data;
280 int res = func ((void *)&data);
281 if (res == (int)GanglionLib::CustomExitCodes::STATUS_OK)
282 {
283 if (state != (int)BrainFlowExitCodes::STATUS_OK)
284 {
285 {
286 std::lock_guard<std::mutex> lk (m);
287 state = (int)BrainFlowExitCodes::STATUS_OK;
288 }
289 cv.notify_one ();
290 safe_logger (spdlog::level::debug, "start streaming");
291 }
292
293 if (data.data[0] <= 200)
294 {
295 if (firmware == 3)
296 {
297 decompress_firmware_3 (&data, last_data, acceleration, package);
298 }
299 else if (firmware == 2)
300 {
301 decompress_firmware_2 (&data, last_data, acceleration, package);
302 }
303 }

Callers

nothing calls this directly

Calls 1

get_addressMethod · 0.45

Tested by

no test coverage detected