Laelaps  2.3.5
RoadNarrows Robotics Small Outdoor Mobile Robot Project
Gpio.py File Reference

Laelaps Odroid GPIO control. More...

Go to the source code of this file.

Functions

def Laelaps.Gpio.gpioReadValue (gpio)
 Read value of a GPIO pin. More...
 
def Laelaps.Gpio.gpioWriteValue (gpio, value)
 Write a value to a GPIO pin. More...
 
def Laelaps.Gpio.MotorCtlrChipSelectGpio (port, addrSel, addrLast)
 Laelaps specific chip select function using digital GPIO. More...
 
def Laelaps.Gpio.MotorCtlrChipselectRts (port, addrSel, addrLast)
 Laelaps specific chip select function using RTS. More...
 
def Laelaps.Gpio.enableMotorCtlrsPower (state)
 Enable/disable power to Laelaps motor controllers. More...
 
def Laelaps.Gpio.areMotorCtlrsPowered ()
 Test if the motor controllers are powered. More...
 

Detailed Description

Laelaps Odroid GPIO control.

LastChangedDate
2016-02-02 13:47:13 -0700 (Tue, 02 Feb 2016)
Rev
4293
Author
: Robin Knight (robin.nosp@m..kni.nosp@m.ght@r.nosp@m.oadn.nosp@m.arrow.nosp@m.s.co.nosp@m.m)
Copyright
© 2015-2017. RoadNarrows LLC.
http://www.roadnarrows.com
All Rights Reserved
EULA@

Permission is hereby granted, without written agreement and without license or royalty fees, to use, copy, modify, and distribute this software and its documentation for any purpose, provided that (1) The above copyright notice and the following two paragraphs appear in all copies of the source code and (2) redistributions including binaries reproduces these notices in the supporting documentation. Substantial modifications to this software may be copyrighted by their authors and need not follow the licensing terms described here, provided that the new terms are clearly indicated in all files where they apply.

IN NO EVENT SHALL THE AUTHOR, ROADNARROWS LLC, OR ANY MEMBERS/EMPLOYEES OF ROADNARROW LLC OR DISTRIBUTORS OF THIS SOFTWARE BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE AUTHORS OR ANY OF THE ABOVE PARTIES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

THE AUTHOR AND ROADNARROWS LLC SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.

—@

Definition in file Gpio.py.

Function Documentation

def Laelaps.Gpio.areMotorCtlrsPowered ( )

Test if the motor controllers are powered.

Returns
Returns True if powered, False if unpowered.

Definition at line 168 of file Gpio.py.

168 def areMotorCtlrsPowered():
169  if gpioReadValue(GpioMotorCtlrEn) == '1':
170  return True
171  else:
172  return False
173 
def Laelaps.Gpio.enableMotorCtlrsPower (   state)

Enable/disable power to Laelaps motor controllers.

Parameters
stateTrue to enable, False to disable.

Definition at line 160 of file Gpio.py.

160 def enableMotorCtlrsPower(state):
161  gpioWriteValue(GpioMotorCtlrEn, state);
162 
163 #
def Laelaps.Gpio.gpioReadValue (   gpio)

Read value of a GPIO pin.

Parameters
gpioExported GPIO number.
Returns
On success returns '0' or '1'. On error, '' is returned.

Definition at line 68 of file Gpio.py.

68 def gpioReadValue(gpio):
69  valFileName = "/sys/class/gpio/gpio%d/value" % (gpio)
70  try:
71  fp = open(valFileName, "r")
72  except IOError as inst:
73  print >>sys.stderr, "Error:", inst
74  return ''
75  try:
76  val = fp.read(1)
77  except IOError as inst:
78  print >>sys.stderr, "Error:", inst
79  val = ''
80  fp.close()
81  return val
82 
83 #
def Laelaps.Gpio.gpioWriteValue (   gpio,
  value 
)

Write a value to a GPIO pin.

Parameters
gpioExported GPIO number.
valueValue to write. If '0', 0, or False, value written is '0'. If '1', non-zero, or True, value written is '1'.
Returns
On success returns '0' or '1'. On error, '' is returned.

Definition at line 93 of file Gpio.py.

93 def gpioWriteValue(gpio, value):
94  valFileName = "/sys/class/gpio/gpio%d/value" % (gpio)
95  try:
96  fp = open(valFileName, "w")
97  except IOError as inst:
98  print >>sys.stderr, "Error:", inst
99  return ''
100  if (value == '0') or (value == '1'):
101  val = value
102  elif value:
103  val = '1'
104  else:
105  val = '0'
106  try:
107  val = fp.write(val+'\n')
108  except IOError as inst:
109  print >>sys.stderr, "Error:", inst
110  val = ''
111  fp.close()
112  return val
113 
114 #
def Laelaps.Gpio.MotorCtlrChipSelectGpio (   port,
  addrSel,
  addrLast 
)

Laelaps specific chip select function using digital GPIO.

Note
Deprecated

The Laelaps uses GPIO 173 to select the front or rear motor controllers. For the Odroid, this pin is also the RTS line. Hardware flow control is not used, so this pin is available for signalling.

Parameters
portOpened serial port (not used).
addrSelAddress of motor controller to be selected.
addrLastAddress of last motor controller selected.

Definition at line 127 of file Gpio.py.

127 def MotorCtlrChipSelectGpio(port, addrSel, addrLast):
128  if addrSel != addrLast:
129  if addrSel == MotorCtlrAddrFront:
130  val = 1
131  else:
132  val = 0
133  gpioWriteValue(GpioMotorCtlrCs, val);
134 
135 #
def Laelaps.Gpio.MotorCtlrChipselectRts (   port,
  addrSel,
  addrLast 
)

Laelaps specific chip select function using RTS.

Note
Deprecated
The RTS signal in current Odroid distro does not work, so this function is useless.
Parameters
portOpened serial port.
addrSelAddress of motor controller to be selected.
addrLastAddress of last motor controller selected.

Definition at line 147 of file Gpio.py.

147 def MotorCtlrChipselectRts(port, addrSel, addrLast):
148  if addrSel != addrLast:
149  if addrSel == MotorCtlrAddrFront:
150  level = True
151  else:
152  level = False
153  port.setRTS(level)
154 
155 #