| 40 | } |
| 41 | |
| 42 | int 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 | |
| 76 | void PlotJugglerUDPStreamer::stream_data (double *data) |
| 77 | { |
nothing calls this directly
no test coverage detected