Wrong end bytes warning and strange signals
Hello!
I have the following code for getting data from OpenBCI Cyton board.
BOARD_ID = BoardIds.CYTON_BOARD.value
params = BrainFlowInputParams()
params.serial_port = '/dev/rfcomm0'
BOARD = BoardShim(BOARD_ID, params)
BOARD.prepare_session()
BOARD.start_stream()
data = BOARD.get_board_data()
if data.shape[1] > 0:
for channel in range(0, MAX_NB_CHANNELS):
# filtering
freq = 50.0
DataFilter.perform_bandstop(data[channel + 1], BoardShim.get_sampling_rate(BOARD_ID), freq, 4.0, 2,
FilterTypes.BUTTERWORTH.value, 0.0)
start_freq = 5.0
stop_freq = 50.0
center_freq = (start_freq + stop_freq) / 2.0
band_width = stop_freq - start_freq
DataFilter.perform_bandpass(data[channel + 1], BoardShim.get_sampling_rate(BOARD_ID), center_freq, band_width, 2, FilterTypes.BUTTERWORTH.value, 0.0)
But i have 2 problems:
1) In console I see warnings about wrong bytes:
[2021-07-04 01:03:56.309] [brainflow_logger] [info] incomming json: {
"ip_address": "",
"ip_port": 0,
"ip_protocol": 0,
"mac_address": "",
"other_info": "",
"serial_number": "",
"serial_port": "/dev/rfcomm0",
"timeout": 0
}
[2021-07-04 01:03:56.309] [brainflow_logger] [info] openning port /dev/rfcomm0
[2021-07-04 01:04:06.522] [brainflow_logger] [warning] Wrong end byte 128
[2021-07-04 01:04:08.940] [brainflow_logger] [warning] Wrong end byte 0
[2021-07-04 01:04:11.370] [brainflow_logger] [warning] Wrong end byte 0
[2021-07-04 01:04:14.677] [brainflow_logger] [warning] Wrong end byte 1
[2021-07-04 01:04:17.105] [brainflow_logger] [warning] Wrong end byte 0
[2021-07-04 01:04:22.000] [brainflow_logger] [warning] Wrong end byte 136
[2021-07-04 01:04:24.429] [brainflow_logger] [warning] Wrong end byte 0
[2021-07-04 01:04:41.382] [brainflow_logger] [warning] Wrong end byte 0
[2021-07-04 01:04:42.580] [brainflow_logger] [warning] Wrong end byte 2
[2021-07-04 01:04:43.791] [brainflow_logger] [warning] Wrong end byte 3
2) My signals before and after filtration look like the same. But I've copy/pasted code form OpenBCI GUI and expected another result
In OpenBCI GUI signal is perfect.
So the questions:
What does mean wrong byte? How to solve it?
What may be wrong with filtration?
Comments
Hello Stan,
Look at this related Raspberry thread:
https://openbci.com/forum/index.php?p=/discussion/2815/brainflow-serial-port-name-on-raspberry-vs-mac
Is there some reason you are using /dev/rfcomm0 instead of the more typical /dev/ttyUSB0 or 1 ? It's possible that the rfcomm version of the driver, is not fully compliant with tty port emulation.
Let us know if changing the port name solves your issue.
Regards, William
Also mention what OS and version you are using.
Hello @wjcroft!
Thank you for your answer and support. I'm using Debian GNU/Linux 11 (bullseye).
Changing ports was not solved problem.
As I've mentioned in first post, in the Official OpenBCI GUI all is okay with signals, even with /dev/rfcomm0. But in Python when I'm using brainflow library (the same library and settings as in OpenBCI GUI in Java/Processing) I'm bumping into problems with wrong byte warnings. Maybe it lead to incorrect signals and therefore filtering have no sense. Because after filtering I see bad signals too.
I guess I'm not correctly using brainflow library and it leads to problems.
@wjcroft, could I ask you or anyone else to take a look on my Python code from first post? Maybe I made some rude mistakes.
Suggest you post your question on the Brainflow Slack, see signup link here,
https://brainflow.org/
Hello @wjcroft!
Sorry for long delay in answer, I was on vacation. I've managed to solve problem with signals - the core of problem was in incorrect pins connection on board.
But I still have in console warnings like:
[brainflow_logger] [warning] Wrong end byte
Do you know what does it mean?
In signals I see every 3-7 secs some noises.
Stan, hi.
Again, I suggest you join the Brainflow Slack, using previous link, reproduced below. The Brainflow developer, Andrey @Andrey1994, monitors the Slack closely and provides very timely answers.
https://brainflow.org/
William
https://github.com/brainflow-dev/brainflow/blob/master/src/board_controller/openbci/cyton.cpp#L70 check this code for more information about this message.
It reads 1 byte after that 32 more bytes and checks the end byte. If the end byte is outside from expected range it prints this message
Its reasons can be different, like smth unexpected in the serial port buffer, lost data, etc. If you see it once its ok