I am using a Raspberry Pi 2 Model B v1.1. I have looked at the GPIO file in /sys but I don't understand how I actually turn on/ turn off GPIO ports or I set them to read in/read out, I am trying to do a project for college using my Raspberry PI and LISP but without this knowledge I am unable to do this, this is the library that is written for NewLIsp: https://github.com/gatesphere/raspi-gpio-newlisp/blob/master/raspi-gpio.lsp Some clarification of what actually needs to be written and where it needs to be written to send out/read in values on the GPIO ports is need, any help will be greatly appreciated.
This is clearly and simply documented in the kernel docs. I will not bother to regurgitate it here.
Note that you can't use sudo
with echo >
because of redirection, but that does not impact what you are trying to do.
Anecdotely I'd say using if using high level stream functions doesn't work on sys/proc nodes, use lower level methods. I don't speak lisp so I don't know how relevant that is.
-
Thank you :D I'll give this a read and see where I get. I want to write my own library to easily handle the I/O of the GPIO ports, but I've been confused as to how to actually do any of it. – Floofk Oct 22 '15 at 14:30
Here are some chunks of a program that might help - the whole thing is too big
import sys
sys.path.insert(0, '/home/pi/pgms')
import RPi.GPIO as GPIO import time import datetime from datetime import timedelta import os import subprocess import glob import suntime
GPIO.setwarnings(False) GPIO.setmode(GPIO.BOARD) ## Use board pin numbering
dirarr=["off","on"] pinarr=[7,8,10,11,12,13]
for i in range(0,6): ## Print current pin usage
fno = GPIO.gpio_function(pinarr[i]) ## get function number
print ("Pin " + str(pinarr[i]) + " usage is " + pin_use[fno])
for i in range(0,2):
print (" " )
print ("Python version is %s " % str(sys.version[0:6]))
print ("GPIO version is %s " % GPIO.VERSION)
print ("Board revision is %s " % getbr()[:4])
print ("Program name is %s " % sys.argv[0])
print("System path is ",sys.path)
for i in range(len(pinarr)): GPIO.setup((pinarr[i]), GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
man gpio
? Why Lisp? Is this just to make it more difficult - I though Lisp was only used with Emacs these days. – Milliways Oct 22 '15 at 10:23gpio
is an executable and calling it from another is clunky and expensive vs. using a kernel fs interface. Lisp is still used in university intro AI courses (at least where I am), and along with Haskell probably one of the most popular functional languages. For what it's worth, it's actually ahead of Haskell on the TIOBE index, which tracks current internet references (and if you look at the long term index there, was in the top 15 overall until 5 years ago). – goldilocks♦ Oct 22 '15 at 14:30