8 Replies Latest reply on Jan 23, 2014 11:08 AM by AlexT_Intel

    Serial ports

    EJP

      Hi

      i can see on GalileoLinuxSample, there are 2 ports

      /dev/ttyGS0  or      Serial

      /dev/ttyS0    or      Serial1

      If i understand well the Arduino, on the extension port there is an another serial port (port digital TX=1, RX=0)

      what is the references of this port

      Thanks

      Eric

        • 1. Re: Serial ports
          Rod_H

          GS0 or serial is the Gadget Serial, which is the client usb that you connect to upload sketches, the S0 or serial1 is the 3-pin jack that you can use putty to log on to Linux. Galileo Schematic shows TX/RX as UART0 and serial1 as UART1, two different ports I guess.

          1 of 1 people found this helpful
          • 2. Re: Serial ports
            Clayton Hofrock

            The Digital 0 and Digital 1 (Rx and Tx) are connected to Linux device /dev/ttyS1.

             

            I think this might map to Serial2 in the Arduino IDE? I am not sure though, I have not played with that port.

            • 3. Re: Serial ports
              AlexT_Intel

              As far as I can see in Linux configs, it's actually vice versa:

               

              /dev/ttyS0 is the first Quark UART (UART0) and it's the Digital 0 and 1 pins

              /dev/ttyS1 is the second Quark UART (UART1) and it's the audio jack one

               

              /dev/ttyGS0 is, like Rod_H mentioned, the virtual serial device created by the Linux cdc-acm driver via the Galileo USB port marked as "USB client".

               

              As far as the Arduino mappings are concerned, as far as I can see from looking at the sources coming with Arduino IDE and the console output when the sketch runs, the mapping is as follows (assuming you haven't changed any port configs in grub.conf or inittab or in clloader sources):

               

              Serial is routed to the /dev/ttyGS0

              Serial1 is routed to /dev/ttyS0

              Serial2 is not used

               

              The below sketch demonstrates that

              void setup() {
              }
              
              void loop() {
                delay(5000);
                if(Serial) {
                  Serial.println("This is Serial, must be mapped to /dev/ttyGS0, i.e. visible in Arduino IDE's Serial Monitor");
                }
                else {
                  printf("Serial is not ready");
                }
              
                if(Serial1) {
                  Serial1.println("This is Serial1, must be mapped to /dev/ttyS0, i.e. visible on something connected to the Digital pins 0 & 1");
                }
                else {
                  printf("Serial1 is not ready");
                }
              
                if(Serial2) {
                  Serial2.println("This is Serial2, unused, you shouldn't see this anywhere");
                }
                else {
                  printf("Serial2 is not ready");
                } 
              }
              
              
              
              • 4. Re: Serial ports
                VintageBits

                I think that Serial2 is mapped to the audio jack serial port, ttyS1, but won't actually work because usually there is a login process attached to the port. If the configuration is changed so that login is not on the port, it should work fine.

                • 5. Re: Serial ports
                  EJP

                  Hi,

                  So we can start by this setting ?

                  ComPorts.JPG

                  • 6. Re: Serial ports
                    AlexT_Intel

                    I think that Serial2 is mapped to the audio jack serial port, ttyS1

                    I believe it's not. Not sure what makes you think so, but what I did was checking out the sources coming with the IDE and also the clloader program sources (the one that runs and manages the sketches on Galileo).

                     

                    Sketch is compiled into a Linux program, which can take up to three arguments and whatever is passed as these arguments is used to initialize ttys for Serial, Serial1 and Serial2 objects. In both current BSP releases, 0.7.5 and 0.8.0, these are hardcoded in clloader's sources. First argument is always a /dev/pts0 device, for which a master ptmx device is created by clloader and then mapped to the GS0 port. Second argument is "/dev/ttyS0", that is the pins and the third one is set to NULL. There's an "else" statement with a comment that "parent  manage /tty interface" but it seems to be never used. You can easily see that yourself in the meta-clanton-galileo Yocto layer, galileo-target recipe, there's a tar.gz file with clloader sources in the "files" directory, see clloader.c.

                     

                    EJP, yes I think the table is correct, with the exception of Serial2, due to above.

                    1 of 1 people found this helpful
                    • 7. Re: Serial ports
                      VintageBits

                      Hmm. I had grepped the source for Serial and saw these lines:

                       

                      TTYUARTClass Serial(&rx_buffer1, 0);            // ttyS0

                      TTYUARTClass Serial1(&rx_buffer2, 1);           // ttyGS0

                      TTYUARTClass Serial2(&rx_buffer3, 2);           // ttyS1

                       

                      so I assumed that these comments were meaningful. Sorry if that is not the case.

                      • 8. Re: Serial ports
                        AlexT_Intel

                        No worries, I also thought so at first :-) But these comments only partially true. And that becomes clear only after you take the clloader into account.

                         

                        You can run the sketch manually (though that would require disabling the respawning of clloader), you can then provide it with three command line arguments and that's when Serial2 will be initialized too.