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

Method config_board

src/board_controller/ant_neuro/ant_neuro.cpp:392–547  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

390}
391
392int AntNeuroBoard::config_board (std::string config, std::string &response)
393{
394 if (amp == NULL)
395 {
396 safe_logger (spdlog::level::err, "Amplifier is not created");
397 return (int)BrainFlowExitCodes::BOARD_NOT_READY_ERROR;
398 }
399
400 std::string prefix = "sampling_rate:";
401 std::string rv_prefix = "reference_range:";
402 std::string bv_prefix = "bipolar_range:";
403 std::string mode_prefix = "impedance_mode:";
404 std::string get_info = "get_info";
405
406 if (config.find (prefix) != std::string::npos)
407 {
408 int new_sampling_rate = 0;
409 std::string value = config.substr (prefix.size ());
410 try
411 {
412 new_sampling_rate = std::stoi (value);
413 }
414 catch (...)
415 {
416 safe_logger (spdlog::level::err, "format is '{}value'", prefix.c_str ());
417 return (int)BrainFlowExitCodes::INVALID_ARGUMENTS_ERROR;
418 }
419 // check that provided value is correct
420 std::vector<int> allowed_values = amp->getSamplingRatesAvailable ();
421 if (std::find (allowed_values.begin (), allowed_values.end (), new_sampling_rate) !=
422 allowed_values.end ())
423 {
424 sampling_rate = new_sampling_rate;
425 return (int)BrainFlowExitCodes::STATUS_OK;
426 }
427 else
428 {
429 safe_logger (spdlog::level::err, "not supported value provided");
430 for (int i = 0; i < (int)allowed_values.size (); i++)
431 {
432 safe_logger (spdlog::level::debug, "supported value: {}", allowed_values[i]);
433 }
434 return (int)BrainFlowExitCodes::INVALID_ARGUMENTS_ERROR;
435 }
436 }
437 else if (config.find (rv_prefix) != std::string::npos)
438 {
439 double new_reference_range = 0.0;
440 std::string value = config.substr (rv_prefix.size ());
441 try
442 {
443 new_reference_range = std::stod (value);
444 }
445 catch (...)
446 {
447 safe_logger (spdlog::level::err, "format is '{}value'", rv_prefix.c_str ());
448 return (int)BrainFlowExitCodes::INVALID_ARGUMENTS_ERROR;
449 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected