4 Replies Latest reply on May 27, 2014 5:21 PM by jdschumacher

    Trying to use PySerial to drive a serial lcd (parallax)?

    jdschumacher

      I am trying to use PySerial to drive a serial lcd (parallax) from within a python program on the linux side of an intel galileo board......

      First issue is that I can't reserve gpio40 and set it to high. I tried following a few blogs, such as this one, http://www.malinov.com/Home/sergey-s-blog.

       

      Any advice or pointers on this?

        • 1. Re: Trying to use PySerial to drive a serial lcd (parallax)?
          JPMontero_Intel

          Greetings

          I was able to use PySerial to read and send strings. I just downloaded the pyserial 2.7 from this site https://pypi.python.org/pypi/pyserial , and install in my Galileo. Then I configured the gpio 4, 40 and 41 to use the pin 0 and 1 as a serial port by following the commands under GPIO configuration in Sergey’s blog http://www.malinov.com/Home/sergey-s-blog/intelgalileo-configuringtheserialportinlinux . Once the GPIOs are configured you are all set just go to python it is as simple as

          import serial

          ser = serial.Serial(“/dev/ttyS0”, 57600)                   #this is to use the pin 0 and 1 as a serial port

           

          or

           

          import serial
          ser = serial.Serial(“/dev/ttyGS0”, 9600)                  #you can test this by reading this post and send data through the serial monitor in Arduino IDE

          Then you can just follow this guide to learn how to use this library http://pyserial.sourceforge.net/shortintro.html .

          If you want to configure the GPIO pins inside python you’ll need to use the os library

          import os
          os.system(“echo –n  0 > /sys/class/gpio/gpio40/value”)

          This is just an example you can use all the commands in the configuration of Sergey’s blog like this os.system("command"), and remember if you want to use the pin 0 and 1 as a serial port, you need to put 0 in the value of gpio40 and gpio41 and don't forget the level shifter (gpio4) in case you need it. Let me know if this helped you.

          Regards
          JPMontero_Intel

          • 2. Re: Trying to use PySerial to drive a serial lcd (parallax)?
            jdschumacher

            My issue is in setting the gpio to use 0 and 1 as serial input/output.  I tried to follow the blog and I can easily export gpio 4, but it throws an error when I try to do 40/41.  The error is  `sh: echo: write error: Invalid argument`. The rest of the instructions seem simple enough to walk through, but I can't figure out how to fix this.

             

            (Does the "_Intel" at the end of everyone's name denote employee status?)

            • 3. Re: Trying to use PySerial to drive a serial lcd (parallax)?
              JPMontero_Intel

              Yes having Intel on the name it implies we are Intel employees but that doesn't mean that we all support Galileo, some contribute to the forum on their free time. Regarding your issue I've seen this error when you type non-valid value, for example

              echo –n “432” > /sys/class/gpio/export


              Maybe there is an error in your image since it doesn't allow you use:

              echo –n “40” > /sys/class/gpio/export


              I would recommend you to install a fresh install of the SD image and upgrade to the new firmware if you haven’t done it yet. Let me know if it worked.

               

              Regards
              JPMontero_Intel

              • 4. Re: Trying to use PySerial to drive a serial lcd (parallax)?
                jdschumacher

                You sir are correct. I just talked with Jeff Torello and a few others and there apparently is an issue accessing the GPIOs that are exposed by cy8c9540a.  I was using a Wind River image and when I switched over to Intel's provided devkit one (Yocto) it works like it should.  They raised a support ticket on Friday for it and i'll let you know if I hear back about it.