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

Method prepare_session

src/board_controller/pieeg/pieeg_board.cpp:26–70  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24}
25
26int PIEEGBoard::prepare_session ()
27{
28 if (initialized)
29 {
30 safe_logger (spdlog::level::info, "Session already prepared");
31 return (int)BrainFlowExitCodes::STATUS_OK;
32 }
33 if (params.serial_port.empty ())
34 {
35 params.serial_port = "/dev/spidev0.0";
36 safe_logger (spdlog::level::info, "Use serial port {}", params.serial_port.c_str ());
37 }
38
39 gpio_in = gpio_new ();
40 if (gpio_open (gpio_in, "/dev/gpiochip0", 26, GPIO_DIR_IN) < 0)
41 {
42 safe_logger (spdlog::level::err, "failed to open gpio");
43 gpio_free (gpio_in);
44 gpio_in = NULL;
45 return (int)BrainFlowExitCodes::UNABLE_TO_OPEN_PORT_ERROR;
46 }
47 spi = spi_new ();
48 if (spi_open_advanced (spi, params.serial_port.c_str (), 0b01, 1000000, MSB_FIRST, 8, 1) < 0)
49 {
50 safe_logger (spdlog::level::err, "failed to open spi dev");
51 spi_free (spi);
52 spi = NULL;
53 gpio_free (gpio_in);
54 gpio_in = NULL;
55 return (int)BrainFlowExitCodes::UNABLE_TO_OPEN_PORT_ERROR;
56 }
57 int gpio_res = gpio_set_edge (gpio_in, GPIO_EDGE_FALLING);
58 if (gpio_res != 0)
59 {
60 safe_logger (spdlog::level::err, "failed to set gpio edge event handler: {}", gpio_res);
61 spi_free (spi);
62 spi = NULL;
63 gpio_free (gpio_in);
64 gpio_in = NULL;
65 return (int)BrainFlowExitCodes::UNABLE_TO_OPEN_PORT_ERROR;
66 }
67
68 initialized = true;
69 return (int)BrainFlowExitCodes::STATUS_OK;
70}
71
72int PIEEGBoard::start_stream (int buffer_size, const char *streamer_params)
73{

Callers

nothing calls this directly

Calls 1

emptyMethod · 0.80

Tested by

no test coverage detected