Brainflow's get_board_data() throws error 13 when called twice
I'm trying to use brainflow in Matlab for a P300 matrix speller. I need to get the data after a few trials such that: (1) start_stream() --> (2) Run trials (change color of rows and columns) --> (3) get_board_data() --> (4) process data --> (5) repeat 2-4
But,
get_board_data() is what I need (return all data in the buffer, empty buffer) but seems I can't call it twice (eg: data=get_board_data(); pause(2); data2=get_board_data() throws error 13).
get_current_board_data() could be used but I don't know how many samples are in the buffer (I need all of them) and I want to delete them.
What's the solution? What am I missing?
Comments
I can reproduce this behaviour if streaming is not running, roughly speaking smth like that throws an error:
While smth like that works fine:
Difference is that
get_board_dataremoves data from the buffer, so its empty when you call it second time(if streaming is stopped) and for empty buffer it throws such error.There is a method
get_board_data_count();which you can use to check the current size of the buffer and make sure that you callstop_streamonly in the endYes, that's correct! I noticed I had by mistake stop_stream() at the beginning of my code. First time I was calling get_board_samples(), it returned samples (so didn't throw any error), second time the buffer was empty so it threw the error. Thanks!