4 Replies Latest reply on Jun 12, 2014 11:14 AM by jmount

    Galileo linux connecting to serial on /dev/ttyS0 questions

    jmount

      Hello everyone,

       

      I have been running into a problem that I didn't expect to be trouble but it seems to be.  We are interested in retrieving data from a serial connection from the linux side of a Galileo.  I would like to use pyserial to get values from sensors on the Arduino side.  I found information that indicates that this should work on the following sites:

      I also tried changing the serial.println to output output to serial1.println (and serial2.println) to write to those serial ports.  I'm not sure what the problem is but it would be really good to get this working.

       

      Has anyone got something like this to work?  Thanks for any information,

      Jerry

        • 1. Re: Galileo linux connecting to serial on /dev/ttyS0 questions
          JPMontero_Intel

          Hi

           

          Let me see if I understand your issue. You can see the data in the Linux part by using the cat command and in python with the pyserial command ser.read() , but you are not seeing the data of the serial port in the serial monitor of the command line, is this correct?

           

          Regards
          JPMontero_Intel

          • 2. Re: Galileo linux connecting to serial on /dev/ttyS0 questions
            jmount

            Hi,

             

            Basically I followed those 2 pages I listed before - Trying to use PySerial to drive a serial lcd (parallax)? - this one provides the following python code that I used:

             

            import serial

            ser = serial.Serial(“/dev/ttyS0”, 57600)            

            ser = serial.Serial(“/dev/ttyGS0”, 9600) 

            for i in range(10):   #I added these 2 lines

                 ser.read()

             

            I just added a loop for it to listen to a certain number of requests.  I could send data from the serial monitor in the IDE and it would display in python.  So the /dev/ttyS0 port could be monitored in this way.  I am trying to write data from sensors to the /dev/ttyS0 UART from the sketch - and I tried serial.print(data); and serial1.print(data) and serial2.print(data) but I never receive any data from the ser.read() in pyserial. 

             

            I hope that makes sense - thanks for the quick response.

            • 3. Re: Galileo linux connecting to serial on /dev/ttyS0 questions
              JPMontero_Intel

              Well the commands ser = serial.Serial(“/dev/ttyS0,57600) and ser = serial.Serial(“/dev/ttyGS0”, 9600) are used to initialize the ports. The ttyS0 is the pin 0 and 1 used as serial port and the GS0 is the USB client, in case you want to use both, you’ll have to change the name one the variables from “ser” to another name, because if you use the code like you posted, you would use as ser the USB client not the serial port. Also remember to change the speeds depending on the speed the sensor sends the data, for example for the ttyS0 maybe your sensor sends data at 9600 bauds you just have to change the 57600 for 9600. To read a line of data you can use line = ser.readline(). I recommend you to check this post in there is an introduction to pyserial. http://pyserial.sourceforge.net/shortintro.html it might be useful.

              Regards
              JPMontero_Intel

              • 4. Re: Galileo linux connecting to serial on /dev/ttyS0 questions
                jmount

                Thanks - I was just following the code posted on the second page I listed.  I wondered why they would declare a variable that pointed to 2 different ports.  I tried it using different variable names polling different ports but it didn't work either.  I know pyserial fairly well so I checked all the port speeds and things like that but I still can't get data through the ttyS0 port.  I guess I will give up for a while - I tried every permutation that I could think of but never got any data.  I gave up this morning and connected a mega instead of a Galileo and everything works well so I'll just stick with that.  It is kind of disappointing though as seems that it should work.

                 

                Thanks,

                Jerry