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

Method init_streamer

src/board_controller/plotjuggler_udp_streamer.cpp:42–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40}
41
42int PlotJugglerUDPStreamer::init_streamer ()
43{
44 if ((is_streaming) || (socket != NULL) || (db != NULL))
45 {
46 Board::board_logger->error ("plotjuggler streamer is running");
47 return (int)BrainFlowExitCodes::GENERAL_ERROR;
48 }
49
50 socket = new SocketClientUDP (ip, port);
51 int res = socket->connect ();
52 if (res != (int)SocketClientUDPReturnCodes::STATUS_OK)
53 {
54 delete socket;
55 socket = NULL;
56 Board::board_logger->error ("failed to init udp socket {}", res);
57 return (int)BrainFlowExitCodes::GENERAL_ERROR;
58 }
59
60 db = new DataBuffer (len, 1000);
61 if (!db->is_ready ())
62 {
63 Board::board_logger->error ("unable to prepare buffer for streaming");
64 delete db;
65 db = NULL;
66 delete socket;
67 socket = NULL;
68 return (int)BrainFlowExitCodes::INVALID_BUFFER_SIZE_ERROR;
69 }
70
71 is_streaming = true;
72 streaming_thread = std::thread ([this] { this->thread_worker (); });
73 return (int)BrainFlowExitCodes::STATUS_OK;
74}
75
76void PlotJugglerUDPStreamer::stream_data (double *data)
77{

Callers

nothing calls this directly

Calls 3

thread_workerMethod · 0.95
is_readyMethod · 0.80
connectMethod · 0.45

Tested by

no test coverage detected