'+' character in command protocol

edited November 2015 in Software
I have a doubt about the commnand protocol.
In the documentation is not reported the use of the '+' character but in the Arduino code I see that it is used.

In the eventSerial() function ask if the inChar variable is equal to '+' and in the comments says: // if we see a 'bun' on the serial

What does it mean? Is '+' the first character that I have to send to communicate with the openBCI?


Comments

  • biomurphbiomurph Brooklyn, NY
    We are using the + character to help avoid any noise in the serial protocol connection.
    When you send a command character, like the '?', the dongle will do the work to insert the + characters to send to the board.
  • Ahh ok. 
    I am working in a design that does not use the dongle, so I will try to solve this in a different way.
    Thanks!
  • But what happens if I send for example: x 3 0 2 0 0 0 0 X 
    The dongle insert '+' before every character?

  • Or, another possibility that I am seeing is that every command characters is sent between +'s. In the example it would be:

    +x+ +3+ +0+ +2+  +0+ +0+ +0+ +0+ +X+
  • biomurphbiomurph Brooklyn, NY
    The Dongle inserts the '+' sign into the signal. You, or the controlling program, does not have to do it.

  • Thanks biomurph. As I am working in a new design, that does not use the dongle, I wont take in mind the '+' sign.

  • yjyj France , Bordeaux
    Hello all,

    @biomurph,

    "The Dongle inserts the '+' sign into the signal. You, or the controlling program, does not have to do it."

    It seams logic but I cannot get any reaction of the programme if I dont write all the "+".

    From the Arduino IDE, when I use the "Tools / Serial Monitor" I have to write (without the double quotes):
    "+v+"  or "+?+"  or  "+=++a++N+" , etc...   It works

    How do you understand that ?
    Is my Dongle wrong ?

    Funny , if I  write      "+v+?+"    or    "+?+v+"  ,  with only one "+" between "v" and "?" ,  
    I get in both cases the "restart from scratch" but no "print registers" ...

    If I repeat the last sequence ,           I get only the registers,
    If I repeat the last sequence again, I get only the restart,
    If I repeat the last sequence again, I get only the registers,
    then If I write "+v+" , I get nothing
    If I continue  writing "++v+" it restarts one time over two.

      In the code of the function "void eventSerial(){" , one can read : " if(millis() - commandTimer < 5){  // if it's not too late, "

       Too late for what ?

     Wish you happy hollidays.

       Yannick.

  • biomurphbiomurph Brooklyn, NY
    @yannick

    The Dongle should be adding the '+' characters, and you should not need to do that in any terminal software.
    The Dongle software looks for a single character, and then it adds the plus signs.

    Did you alter the Dongle firmware?

    Your 'Funny,' comment does make some sense, in that the board will only respond to a command character that is surrounded by the '+' characters. So when you say that only the 'first' command registers, that makes sense.

    which source code are you referring to that containse the eventSerial() ??
  • yjyj France , Bordeaux
    @biomurph

    Thank's for your answer,

    - I have not touched the Dongle firmware.

    - In the file OpenBCI_32bit_SD_Only.ino
      After the main loop we find :

    // =============== some variables to help find 'burger protocol' commands

    int plusCounter = 0;
    char testChar;
    unsigned long commandTimer;

    void eventSerial(){
      while(Serial0.available()){
        char inChar = (char)Serial0.read();

        if(plusCounter == 1){  // if we have received the first 'bun'
          testChar = inChar;   // this might be the 'patty', stop laughing
          plusCounter++;       // get ready to look for another 'bun'
          commandTimer = millis();  // don't wait too long!
        }

        if(inChar == '+'){  // if we see a 'bun' on the serial
          plusCounter++;    // make a note of it
          if(plusCounter == 3){  // looks like we got a command character
            if(millis() - commandTimer < 5){  // if it's not too late,
              if(getChannelSettings){ // if we just got an 'x' expect channel setting parameters
                loadChannelSettings(testChar);  // go get em!
              }else if(getLeadOffSettings){  // if we just got a 'z' expect lead-off setting parameters
                loadLeadOffSettings(testChar); // go get em!
              }else{
                getCommand(testChar);    // decode the command
              }
            }
            plusCounter = 0;  // get ready for the next one
          }
        }
      }
    }

    But dont bother with that, you have so much to do at the moment...

    Thank's for all,
        Yannick.
  • I understand the code in this way: to receive a valid command (character or group of characters) the function eventSerial() first confirms that the character is surrounded by '+' characters. First detects the first '+', then save the next received character (possible command) and then detect the final '+'. If it is correct, only then interprets and executes the command.

    The line: "if(millis() - command Timer < 5){ // if it's not too late" limits the time available to receive a command. If it takes longer than 5 ms it aborts the command and allow the system to get new data acquired.

    This behavior will make the system more robust because if it is received a command by error or there is a problem at serial transmission, the system may stop there waiting and waiting.

    Please @biomurph or somebody else correct me if I am wrong.
  • yjyj France , Bordeaux
    @AgustinS

    I ,   for my part ,   fully agree with your interpretation of the Sandwich protocole and its timing.

    On the net the best I found was :

      image
      Yannick.
  • yjyj France , Bordeaux
    @biomurph

    you asked me if I had altered the dongle firmware...

    Do you mean that someting could be wrong with this dongle?

    What should I do?

    Is there anything to check? How?
    Is there a way to know which version is running?

    Thank's
    Yannick.

  • biomurphbiomurph Brooklyn, NY
    @AgustinS: you are correct in your interpretation of the code.

    @yj, It does not make sense that you have to insert the '+' when you are running a serial terminal.
    You should just be able to send the character, say the '?' character, and the board will report back the hardware register values.

    If this is not happening, then please try to re-program the Dongle, and see if that works.
  • yjyj France , Bordeaux
    edited December 2015
    @biomurph

    I am trying to re-program the Dongle.

       But : OpenBCI_32bit_Host.ino:35:53: fatal error: RFduinoGZLL.h: No such file or directory

    Do I absolutely need to use the 1.5.8 ide ?

    If yes can it coexiste with the 1.6.5 that I curently use?

    if the 1.6.5 is OK, then  where should I put the library?

         I put       OpenBCI_Radios-master\OpenBCI_RFduino_Library\RFduino
         In :         c:\Program Files\Arduino\Hardware\arduino

        Thank's for your help,

          Yannick.

    <span style="color: rgb(255, 0, 0);"><br></span>
  • biomurphbiomurph Brooklyn, NY
    @yj, we use Arduino 1.5.8 here to program our RFduino modules. That was the latest version when we first did it, and it works.

  • yjyj France , Bordeaux
    Thank's @biomurph,

    Then can it coexiste with the 1.6.5 that I curently use?

     Yannick.
  • biomurphbiomurph Brooklyn, NY
    @yj, we have not even tried to use it with 1.6.5
    There's a ton of changes that happened between the 1.5 and 1.6 versions. 
  • yjyj France , Bordeaux
    Thank's @biomurph,

    My english is bad...,

    I just wanted to know if the two versions , 1.5.8 and 1.6.5 can be installed on the same computer ?

    & sorry again...
       Yannick.
  • biomurphbiomurph Brooklyn, NY
    @yj

    I have a mac. I switched from a windows about two years ago, and I am very happy. 
    On my mac, I have had, at times, up to 5 versions of Arduino installed. I can re-name them in the file system to add the version numbers no problem. I can even run them simultaneously.

    I don't know about windows. anybody have experience with windows and multiple versions of arduino?
  • yjyj France , Bordeaux
    @biomurph,

    yesteday, using windows 7 I remarked that the "+" are no longer needed ! ! !
    Thus the ++ problem that I observed under XP, would not be caused by the Dongle itself ?
    Have you ever heard of a such incompatibility?

      Yannick.
  • wjcroftwjcroft Mount Shasta, CA
    I have a Windows XP SP3 here that works fine with the OpenBCI and dongle.

  • yjyj France , Bordeaux
    @biomurph , @wjcroft ,

    Following your recommandation I finally compiled the Dongle code...

    My problem was that I forgot to choose in "Tools/Board"  Rfduino , causing to appear the error message :

    OpenBCI_32bit_Host.ino:35:53: fatal error: RFduinoGZLL.h: No such file or directory

    For mindless guys like me, you might add  " Choose in "Tools/Board"  Rfduino"   in the How To Program OPENBCI Dongle...

    Thank's
    Yannick.
  • yjyj France , Bordeaux
    @biomurph , @wjcroft ,

    "One train may hide another"
    and a  problem , another...


    I Uploaded the Host Firmware to the Dongle following the instructions:
        32 bits Host...
             device_t    role                  =   HOST   ;
             RFduinoGZLL.channel    =       4        ;               //     4     from the antistatic bag.

    Arduino  ver 1.5.8   replied "SUCCESS"

    and I went back to my OBCI Board   to see if I could better upload its code... (I still have the biggest difficulties to upload)

      Then frustration , disappointment , consternation... ( I joke a little bit)
        Now : "No target found."

    In the tutorial the comment of the line :
    RFduinoGZLL.channel = 4   ;       // use channels 2-25. 1 is same as 0 and 0-8 in normal GZLL library
    makes me perplexed.

    "  The channel your boards were shipped with is noted on the static baggie that it came in. "
      It is written "4" on the baggie
    then I must write : RFduinoGZLL.channel = 4   ;
    Isnt' it ?

      What's wrong ?      the OBCI Board radio code is not compatible with the Dongle update?

      Thank's a lot for your help.

         Yannick.


     


  • biomurphbiomurph Brooklyn, NY
    It does sound like what you are doing is correct. You must make sure that both radios (Host and Device) are both on the same channel, which it looks like you are doing.
    Are you loading the Device code onto the OpenBCI Board Radio and the Host code onto the OpenBCI Dongle?
  • yjyj France , Bordeaux
    Yes @biomurph, the Host on the Dongle and it works very well when I choose the channel of another one  of our 3 new Cards...

    A last symptome : If I try to upload the firmware of the Card, as I use to do, the blue diode whick blinks slowly after the sequence "RST - PROG" , begins to blink faster as soon as the upload should start.
    But no more reaction from the Card...
    On the dongle side the green led flashes a few time , may be 6 short flashs and nothing else after that.
    At least it shows that something has been transmitted.
    If I repeat this with a bad channel number, the diode frequency does not change at all, I did that to be sure that the "4" on the baggie was the true one...

    Concerning the upload of the "device radio code" to the OpenBci Board, I meticulously checked all aspects of the protocol but never succeeded...

       Thanks for your time.
         Yannick.
Sign In or Register to comment.