4 Replies Latest reply on Nov 22, 2014 6:33 PM by flummer

    Serial1 not available on Galileo 1 in my sketch

    jay07920

      Other people on the forums seem to have had success with using Serial1 on Gen 1 Galileo.  I'm not able to use Serial1 for some reason. Any ideas?

       

      I'm trying to use Digital Pins 0 and 1 as serial port. From what I've read, it should be available through Serial1 object.

       

      I've jumpered D0 and D1.

       

      My simple test sketch is below. When I run it and use Arduino 1.5.3's serial monitor, "Serial1 not available" keeps printing since line 14 fails. If I comment out lines 14, 24-26, Line 23 prints -1.

       

      If I use Serial2 instead of Serial1, the serial port (3.5mm jack) shows a seg fault:

      [  446.519427] sketch.elf[1401]: segfault at d65903ac ip 08049412 sp b6590390 error 5 in sketch.elf[8048000+6000]

       

      int i = 0;
      char incomingByte;
      
      
      void setup() {  
        Serial1.begin(9600);
      }  
        
      void loop() {  
        delay(1000);  
        i++;
        
          
        if (Serial1.available() > 0) {
                Serial1.println(i, DEC);
                Serial.print("Wrote: ");
                Serial.println(i, DEC);  
                // read the incoming byte:
                incomingByte = Serial2.read();
                
                // say what you got:
                Serial.print("I received: ");
                Serial.println(incomingByte, DEC);
         } else {
           Serial.println("Serial1 not available");
         }
      } 
      
        • 1. Re: Serial1 not available on Galileo 1 in my sketch
          DinoT_Intel

          Hi jay07920,

           

          Try moving Serial1.print() outside of Serial1.available(). Then you should actually have data on the buffer before checking Serial1.available().

          • 2. Re: Serial1 not available on Galileo 1 in my sketch
            jay07920

            Thanks DinoT. Is this what you meant? I

             

            Line 20 still keeps printing -1.

             

            If you have something similar, can you please post it so I can rule out the BSP I built vs. problem in sketch?

            int i = 0;
            char incomingByte;
            
            
            void setup() {
              Serial1.begin(9600);
            }
            
            void loop() {
              delay(1000);
              i++;
            
            
              Serial1.println(i, DEC);
              Serial.print("Wrote: ");
              Serial.println(i, DEC);
                         
              incomingByte = Serial1.read();
            
              Serial.print("Serial One received: ");
              Serial.println(incomingByte, DEC);
            }
            
            • 3. Re: Serial1 not available on Galileo 1 in my sketch
              CMata_Intel

              Hi jay0792;

               

              First, let's change in your code the printing instances, you are using Serial1, but in some cases you are using Serial.print, change those ones to Serial1.print. If you want to use Serial.print you will have to initialize it in the void setup just as you did for Serial1. Let me know about your results.

               

              Regards;

              CMata

              • 4. Re: Serial1 not available on Galileo 1 in my sketch
                flummer

                Hi jay07920,

                 

                Are you using the latest firmware image for the Galileo?

                 

                If I recall correctly, the first versions didn't hook up all the serial ports correctly to the serial objects in the Arduino IDE.

                 

                It's just a guess, but worth a try!

                 

                One of the Serial port objects is shared with the console port on the 3.5mm jack connector (I always forget which one it is). When you initialize in the Arduino sketch (usually with SerialX.begin(baud_rate) in setup()), it's disconnected from the console.

                 

                /Thomas