Sending long SDK commands from inside Cyton firmware
Hi,
Using the Cyton board via Arduino program, I need to write long commands in order to set a channel for example. A command like "x3020000X". But if I try to send it using the function board.processChar('x3020000X'); I get an error. Therefore, I have to divide it into many small commands like:
board.processChar('x');
board.processChar('3');
board.processChar('0');
board.processChar('2');
board.processChar('0');
board.processChar('0');
board.processChar('0');
board.processChar('0');
board.processChar('X');
but this is very uncomfortable.
What is the right way to do it?
Thank you,
Gilad
Comments
Hi Gilad,
As you can see from the source code:
https://github.com/OpenBCI/OpenBCI_Cyton_Library/blob/master/OpenBCI_32bit_Library.cpp#L125
This function is only designed to process one single character at a time. So it cannot be called with a string. Your simplest solution is to just write your own function that takes a string (a character pointer in C), and passes each byte to
processChar. C strings have a zero byte at the end of the string, so that is how you test for completing the string processing.Normally this function is only being called one byte at a time as serial port input characters are received.
Regards, William
To clarify, in the C language used in Arduino programming, character delimiters are single quotes surrounding the character. But strings are quoted with double quote marks,
".