| 27 | } |
| 28 | |
| 29 | void Cyton::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[32]; |
| 47 | double accel[3] = {0.}; |
| 48 | int num_rows = board_descr["default"]["num_rows"]; |
| 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 | double accel_scale = (double)(0.002 / (pow (2, 4))); |
| 56 | |
| 57 | while (keep_alive) |
| 58 | { |
| 59 | // check start byte |
| 60 | res = serial->read_from_serial_port (b, 1); |
| 61 | if (res != 1) |
| 62 | { |
| 63 | safe_logger (spdlog::level::debug, "unable to read 1 byte"); |
| 64 | continue; |
| 65 | } |
| 66 | if (b[0] != START_BYTE) |
| 67 | { |
| 68 | continue; |
| 69 | } |
| 70 | |
| 71 | int remaining_bytes = 32; |
| 72 | int pos = 0; |
| 73 | while ((remaining_bytes > 0) && (keep_alive)) |
| 74 | { |
| 75 | res = serial->read_from_serial_port (b + pos, remaining_bytes); |
| 76 | remaining_bytes -= res; |
| 77 | pos += res; |
| 78 | } |
| 79 | if (!keep_alive) |
| 80 | { |
| 81 | break; |
| 82 | } |
| 83 | |
| 84 | if ((b[31] < END_BYTE_STANDARD) || (b[31] > END_BYTE_MAX)) |
| 85 | { |
| 86 | safe_logger (spdlog::level::warn, "Wrong end byte {}", b[31]); |
nothing calls this directly
no test coverage detected