9 Replies Latest reply on Jan 14, 2016 1:05 PM by Intel_Peter

    Error returned when sending blank line from Serial Monitor

    Blueman

      The simple sketch below works using the Serial Monitor, but if I press Send without any characters entered, the following stream of characters are returned and the sketch becomes unresponsive in the Serial Monitor.  The received text is: "** B0100000063f694Š ".

       

      This is done using an Edison with Arduino breakout fresh out of the box and fresh IDE install.  I've tried various other sketches, and they fail similarly when a blank line is sent.  Non-blank lines seem to work fine and accurately.

       

      Failure occurs with setting of "Carriage return" and "Newline", but not with "No line ending" or with "Both NL & CR".

       

      Host system: Windows 8.1x64

      Devices are: Intel Edison USB Composite Device (COM5), Intel Edison Virtual Com Port (COM6), USB Serial Port (COM3).  IDE is configured to COM6.

      Board is connected to host on two USB ports, one to each of the uUSB connectors.  No external power adapter.

       

      Sketch code is:

       

      int xctr =0 ; 
      // the setup function runs once when you press reset or power the board 
      void setup() { 
        // initialize digital pin 13 as an output. 
        pinMode(5, OUTPUT); 
        digitalWrite(5,LOW); 
        Serial.begin(9600); 
        Serial.println("Ready..."); 
        delay(2000); 
      } 
      // the loop function runs over and over again forever 
      void loop() { 
        xctr++; 
        Serial.print(xctr); 
        Serial.println(".] Enter 1 or 2 to control LED "); 
        serialEvent();  // <---------Call the serialEvent() function 
        delay(1500);              // wait 
      } 
      
      void serialEvent() { 
         while (Serial.available()) { 
        char ch = Serial.read(); 
          if( ch == '1')  // Turn On Load1 
          { 
            digitalWrite(5,HIGH);  
            Serial.println("(1)");
          } 
          if(ch=='2') 
          { 
            digitalWrite(5,LOW); 
            Serial.println("(2)");
          } 
        } 
      } 
      
        • 1. Re: Error returned when sending blank line from Serial Monitor
          Intel_Peter

          Hello Blueman,

           

          I've been trying to replicate this issue, however I have had no luck. I used the following code on an Arduino UNO to send the serial data to my Edison:

           

          bool o;
          bool n;
          void setup()
          {
            Serial.begin(9600);
            pinMode(8, INPUT);
            pinMode(9, INPUT);
          }
          
          void loop()
          {
            o = digitalRead(8);
            n = digitalRead(9);
            while(o == HIGH)
            {
              Serial.println('1');
              delay(25);
              o = digitalRead(8);
            }
            while(n == HIGH)
            {
              Serial.println('2');
              delay(25);
              n = digitalRead(9);
            }
          }
          
          
          

           

          This as I expected worked just fine, then I tried adding some intentional errors in that code to see if I could manage to find out what's happening to you. I tried changing

           

          Serial.println('1');
          
          
          

           

          To

           

          Serial.print('1');
          
          
          

           

          Or

           

          Serial.print("1");
          
          
          

           

          Nothing changed the result, your sketch continued to work just fine for me. I even tried to remove the delay to see if that triggered the issue, but it didn't. I did notice that your code had a small error, you were trying to read using Serial instead of Serial1, so you weren't reading from pin 0 but from the USB port, do you think this is what's causing the issue? If it isn't then my guess is that the baud rate of the device you are trying to read is different from the one you set on your Edison. Bellow is the change I had to do to your code to make it work:

           

          int xctr =0 ; 
          // the setup function runs once when you press reset or power the board 
          void setup() { 
            // initialize digital pin 13 as an output. 
            pinMode(5, OUTPUT); 
            digitalWrite(5,LOW); 
            Serial.begin(9600); 
            Serial1.begin(9600);                                                           //<---------------I added this line
            Serial.println("Ready..."); 
            delay(2000); 
          } 
          // the loop function runs over and over again forever 
          void loop() { 
            xctr++; 
            Serial.print(xctr); 
            Serial.println(".] Enter 1 or 2 to control LED "); 
            serialEvent();  // <---------Call the serialEvent() function 
            delay(1500);              // wait 
          } 
          
          void serialEvent() { 
             while (Serial1.available()) {                                                 //<---------------I changed Serial to Serial1
            char ch = Serial1.read();                                                      //<---------------I changed Serial to Serial1
              if( ch == '1')  // Turn On Load1 
              { 
                digitalWrite(5,HIGH);  
                Serial.println("(1)");
              } 
              if(ch=='2') 
              { 
                digitalWrite(5,LOW); 
                Serial.println("(2)");
              } 
            } 
          } 
          
          
          

           

          Peter.

           

          P.S.: I edited your post to make the code easier to read.

          • 2. Re: Error returned when sending blank line from Serial Monitor
            Blueman

            The issue is relatively independent of what sketch is running, and it's not clear or not if the error might even be within the IDE.

             

            I'll send a simpler sketch that shows the issue, and with screenshots.

             

            Tim

            • 3. Re: Error returned when sending blank line from Serial Monitor
              Intel_Peter

              Some other information that might be helpful is that I'm using the latest image and I uploaded the sketch using Arduino IDE 1.6.6. In case you are using an older image I suggest you to flash the latest which can be found in Intel® Edison Downloads.

               

              Peter.

              • 4. Re: Error returned when sending blank line from Serial Monitor
                Blueman

                The system was fresh out of the box and it installed all the latest drivers, IDE and Edison flash.

                • 5. Re: Error returned when sending blank line from Serial Monitor
                  Blueman

                  Even this most simple sketch fails:

                   

                  void setup() {

                    pinMode(13, OUTPUT);

                  }

                   

                  void loop() {

                    digitalWrite(13, HIGH);  delay(100);

                    digitalWrite(13, LOW);   delay(100);

                  }

                   

                  Execution halts if a blank line is sent from the Serial Monitor in the Arudino IDE if set to "Newline" or "Carriage return", but not "No Line Ending" or "Both NL and CR"

                   

                  "Newline" or "Carriage return" with blank Send causes "** B0100000063f694Š ** B0100000063f694Š " to appear in the communication window and the sketch to halt.

                  • 6. Re: Error returned when sending blank line from Serial Monitor
                    Intel_Peter

                    I find that very weird, I used the "Carriage return" option and I was never able to replicate the issue. Are you sure the issue is not caused by the device sending the serial signals to your Edison? What are you using to send those signals to your board?

                    Another important point is that I'm using the latest image for Edison, which image are you using? You can find out by entering the command configure_edison --version on your Edison's console.

                     

                    Peter.

                    • 7. Re: Error returned when sending blank line from Serial Monitor
                      Blueman

                      As mentioned previously, this was a fresh install out of the box, and as a part of that it [supposedly] installed the most recent versions.

                       

                      configure_edison --version reports "159.devkit"

                      The IDE is 1.6.5

                      The COM3 serial driver is FTDI, 7/10/2015, version 2.12.6.0

                      the device communicating with the Edison board is a Lenovo laptop, i7 / E440 with no history of USB port issues

                      the cables in use are known good cables -- it's only the blank line condition that causes the fault

                       

                      Is this a reported issue on any known versions?

                      • 8. Re: Error returned when sending blank line from Serial Monitor
                        Intel_Peter

                        This is very strange, let me do some testing and see if I can find out the root cause of the issue, I'll try to get  back to you as soon as possible.

                         

                        Peter.

                        • 9. Re: Error returned when sending blank line from Serial Monitor
                          Intel_Peter

                          Hi Blueman,

                           

                          Finally we have been able to reproduce the issue. It has been reported as a bug and we are currently working on it. Hopefully it will be resolved in a future release, however there;s no ETA on it.

                           

                          Peter.