@@ -127,47 +127,29 @@ int OpenBCISerialBoard::set_port_settings ()
127
127
return (int )BrainFlowExitCodes::SET_PORT_ERROR;
128
128
}
129
129
safe_logger (spdlog::level::trace, " set port settings" );
130
- return send_to_board ( " v " ) ;
130
+ return ( int )BrainFlowExitCodes::STATUS_OK ;
131
131
}
132
132
133
133
int OpenBCISerialBoard::status_check ()
134
134
{
135
- unsigned char buf[ 1 ];
136
- int count = 0 ;
137
- int max_empty_seq = 5 ;
138
- int num_empty_attempts = 0 ;
135
+ if (is_streaming)
136
+ {
137
+ return ( int )BrainFlowExitCodes::STREAM_ALREADY_RUN_ERROR ;
138
+ }
139
139
140
- for (int i = 0 ; i < 500 ; i++)
140
+ std::string response = " " ;
141
+ int res = send_to_board (" v" , response);
142
+ if (res != (int )BrainFlowExitCodes::STATUS_OK)
141
143
{
142
- int res = serial->read_from_serial_port (buf, 1 );
143
- if (res > 0 )
144
- {
145
- num_empty_attempts = 0 ;
146
- // board is ready if there are '$$$'
147
- if (buf[0 ] == ' $' )
148
- {
149
- count++;
150
- }
151
- else
152
- {
153
- count = 0 ;
154
- }
155
- if (count == 3 )
156
- {
157
- return (int )BrainFlowExitCodes::STATUS_OK;
158
- }
159
- }
160
- else
161
- {
162
- num_empty_attempts++;
163
- if (num_empty_attempts > max_empty_seq)
164
- {
165
- safe_logger (spdlog::level::err, " board doesnt send welcome characters!" );
166
- return (int )BrainFlowExitCodes::BOARD_NOT_READY_ERROR;
167
- }
168
- }
144
+ return res;
169
145
}
170
- return (int )BrainFlowExitCodes::BOARD_NOT_READY_ERROR;
146
+ safe_logger (spdlog::level::info, " Message from the board : {}" , response.c_str ());
147
+ std::size_t found = response.find (" $$$" );
148
+ if (found == std::string::npos)
149
+ {
150
+ return (int )BrainFlowExitCodes::BOARD_NOT_READY_ERROR;
151
+ }
152
+ return (int )BrainFlowExitCodes::STATUS_OK;
171
153
}
172
154
173
155
int OpenBCISerialBoard::prepare_session ()
0 commit comments