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

Method read_thread

src/board_controller/ntl/ntl_wifi.cpp:29–137  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27}
28
29void NtlWifi::read_thread ()
30{
31 /*
32 Byte 1: 0xA0
33 Byte 2: Sample Number
34 Bytes 3-5: Data value for EEG channel 1
35 Bytes 6-8: Data value for EEG channel 2
36 Bytes 9-11: Data value for EEG channel 3
37 Bytes 12-14: Data value for EEG channel 4
38 Bytes 15-17: Data value for EEG channel 5
39 Bytes 18-20: Data value for EEG channel 6
40 Bytes 21-23: Data value for EEG channel 6
41 Bytes 24-26: Data value for EEG channel 8
42 Aux Data Bytes 27-32: 6 bytes of data
43 Byte 33: 0xCX where X is 0-F in hex
44 */
45 int res;
46 unsigned char b[OpenBCIWifiShieldBoard::package_size];
47 double accel[3] = {0.};
48 int num_rows = board_descr["default"]["num_rows"].get<int> ();
49 double *package = new double[num_rows];
50 for (int i = 0; i < num_rows; i++)
51 {
52 package[i] = 0.0;
53 }
54 std::vector<int> eeg_channels = board_descr["default"]["eeg_channels"];
55
56 while (keep_alive)
57 {
58 // check start byte
59 res = server_socket->recv (b, OpenBCIWifiShieldBoard::package_size);
60 if (res != OpenBCIWifiShieldBoard::package_size)
61 {
62 if (res < 0)
63 {
64#ifdef _WIN32
65 safe_logger (spdlog::level::warn, "WSAGetLastError is {}", WSAGetLastError ());
66#else
67 safe_logger (spdlog::level::warn, "errno {} message {}", errno, strerror (errno));
68#endif
69 }
70
71 continue;
72 }
73
74 if (b[0] != START_BYTE)
75 {
76 continue;
77 }
78 unsigned char *bytes = b + 1; // for better consistency between plain cyton and wifi, in
79 // plain cyton index is shifted by 1
80
81 if ((bytes[31] < END_BYTE_STANDARD) || (bytes[31] > END_BYTE_MAX))
82 {
83 safe_logger (spdlog::level::warn, "Wrong end byte {}", bytes[31]);
84 continue;
85 }
86

Callers

nothing calls this directly

Calls 4

cast_24bit_to_int32Function · 0.85
cast_16bit_to_int32Function · 0.85
get_timestampFunction · 0.85
recvMethod · 0.45

Tested by

no test coverage detected