OpenBCI / OpenBCI_Cyton_Library

Repository for OpenBCI Cyton Arduino Libraries
MIT License
87 stars 88 forks source link

cyton binary data format changed and inconsistent with documentation #87

Closed robertoostenveld closed 6 years ago

robertoostenveld commented 6 years ago

I just updated my Cyton to the latest version of the firmware (DefaultBoard). It seems that the data format has changed, most visible in the first channel that now shows the sample number.

Using the OpenBCI_GUI v2.1.2 (Jan 2017) I see

screen shot 2017-12-03 at 19 33 35

Note the first channel, which seems to be the sample number (which is reset every 256 samples, i.e. about every second).

Using my own code, I see

--------------------------------------------------
OpenBCI V3 8-16 channel
On Board ADS1299 Device ID: 0x3E
LIS3DH Device ID: 0x33
Firmware: v3.1.0
$$$
--------------------------------------------------
Starting to listen - press CTRL-C to quit
openbci2ft: start streaming
a0 41 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 40 f9 50 1e c0
a0 41 01 ff fc 68 ff fb 56 ff fb d3 ff fb 7b ff fb 2a ff fc ad ff fd 9c ff fd 28 00 00 00 00 00 c0
a0 00 c0 41 02 ff fc 5a ff fb 56 ff fb c8 ff fb 77 ff fb 2c ff fc bb ff fd 98 ff fd 2e 00 00 00 c0
a0 41 03 ff fc 5d ff fb 4f ff fb cd ff fb 79 ff fb 2e ff fc c3 ff fd 9a ff fd 27 00 00 00 00 00 c0
a0 41 04 ff fc 5c ff fb 4e ff fb ca ff fb 79 ff fb 2b ff fc b7 ff fd 95 ff fd 2e 00 00 00 00 00 c0
...

The first byte is as expected, the 2nd byte is not consistent with documentation here, the 3rd byte now seems to contain the sample number.

If there is indeed a change in the binary data format, that would explain why existing software is now broken.

robertoostenveld commented 6 years ago

It seems that the actual code is here where it sends OPENBCI_BOP (0x41), followed by the sample number.

In the loop() of DefaultBoard.ino I see that board.sendChannelData() is called, which calls sendChannelDataSerialBLE on line 1289

Might it be that the inconsistent format is due to me not having updated the RFduino firmware on the dongle and the board itself?

robertoostenveld commented 6 years ago

Let me answer my own question. The issue was indeed due to the OpenBCI firmware being incompatible with the firmware of the RFduino.

I have flashed the latest RadioHost32bit and RadioDevice32bit firmware from the OpenBCI_Radios repositories following the instructions. I first tried it with Arduino version 1.8.3, but I could not get the RFduino recognized by the Arduino IDE. It did work with Arduino 1.5.8, which luckily still worked on my computer. With the new firmware on host and device radio, the binary protocol again matches the description and the OpenBCI GUI shows the data as expected.