GPIO.RPI_REVISION


17 posts
by slindojr » Sat Jul 20, 2013 6:21 pm
I purchased a Beaglebone Black. The testing Python code uses the following:

if GPIO.RPI_REVISION == 1 <<---causes error msg and stops the code from executing.

all the rest of the code seems to work just fine.

I have the latest Wheezy installed. I am using the 512 Pi board.
I researched this and every article says the above code snippet should run just fine.
THIS IS DRIVING ME NUTS!!!

If anyone can help I would really appreciate it.

Stan
Posts: 17
Joined: Thu Feb 28, 2013 10:34 pm
by DeeJay » Sat Jul 20, 2013 6:44 pm
'if' starts a code block - you need ':' at the end of the line ?
How To Ask Questions The Smart Way: http://www.catb.org/~esr/faqs/smart-questions.html
How to Report Bugs Effectively: http://www.chiark.greenend.org.uk/~sgtatham/bugs.html
User avatar
Posts: 2033
Joined: Tue Jan 01, 2013 9:33 pm
Location: East Midlands, UK
by jojopi » Sat Jul 20, 2013 7:55 pm
slindojr wrote:if GPIO.RPI_REVISION == 1 <<---causes error msg and stops the code from executing.
An error message is for the benefit of the human, not the computer! You make the problem into a riddle if you omit the important diagnostic information.

It would also be good to indicate exactly where the code came from, so that we can consult it and try it ourselves. The name "GPIO" is part of the program's namespace, so we cannot be certain how it was declared from that isolated line.

At a guess, you have somehow installed a very old version of RPi.GPIO, which does not support board revision detection. (You have a revision 2 board, because you say it has 512MiB RAM.)
User avatar
Posts: 2036
Joined: Tue Oct 11, 2011 8:38 pm
by joan » Sat Jul 20, 2013 8:00 pm
Are you running this code on a Beaglebone?
User avatar
Posts: 5427
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK
by texy » Sat Jul 20, 2013 9:13 pm
Yeah - I'm unsure of the relevance of the first sentence.
Texy
"2.8inch TFT LCD + Touch screen" add-on boards for sale here :
http://www.raspberrypi.org/phpBB3/viewtopic.php?f=93&t=65566
50p goes to the Foundation ;-)
Forum Moderator
Forum Moderator
Posts: 2340
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England
by slindojr » Sat Jul 20, 2013 9:47 pm
Fellas I must have been smokin...yea you know what!

I totally got this wrong so here goes....I not filling the room up with smoke this time.

I have a GertBoard. Getboard Python code examples have this line:

if GPIO.RPI_REVISION == 1:
ports = [25, 24, 23, 22, 21, 18, 17, 11, 10, 9, 8, 7]
else:

The error msg: says that the module is not defined.
So if we use GPIO. <- there is no function found. You get OUTPUT, HIGH, LOW ect. but no RPI_REVISION

I have updated libraries. When I use: sudo apt-get install (or update) python or python3 I get the message that the latest version is installed.

I am sorry for wasting good peoples time. But may be you can over look my former brain F...

Stan
Posts: 17
Joined: Thu Feb 28, 2013 10:34 pm
by DeeJay » Sat Jul 20, 2013 10:08 pm
This works for me. Does it work for you too?

pi@NOOBSv121pub ~ $ sudo python
Python 2.7.3 (default, Jan 13 2013, 11:20:46)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import RPi.GPIO as GPIO
>>> GPIO.RPI_REVISION
2
>>>
How To Ask Questions The Smart Way: http://www.catb.org/~esr/faqs/smart-questions.html
How to Report Bugs Effectively: http://www.chiark.greenend.org.uk/~sgtatham/bugs.html
User avatar
Posts: 2033
Joined: Tue Jan 01, 2013 9:33 pm
Location: East Midlands, UK
by slindojr » Sat Jul 20, 2013 10:30 pm
DeeJay:

I am not creating new code I am using what was downloaded from the Gertboard site.

The line of code that will not work is: GPIO.RPI_REVISION Gertboard needs this to determine what board you are using.
Gertboard code uses phyton2.7 ect

All the articles I found on the internet say this should work, but does not.

All the help you can give would be appreciated.

Stan
Posts: 17
Joined: Thu Feb 28, 2013 10:34 pm
by rpdom » Sun Jul 21, 2013 5:40 am
I think old versions of the GPIO python library didn't have the REVISION test in. That was added after the Rev. 2 Pi came out with the different pin layout.

You probably need to update the library, maybe with apt-get update/apt-get upgrade, or perhaps download the code from somewhere? I'm not familiar with Python and don't use it for GPIO, but I'm sure I've seen mention of needing an upgrade.
Posts: 3410
Joined: Sun May 06, 2012 5:17 am
Location: Essex, UK
by simplesi » Sun Jul 21, 2013 8:54 am
All the help you can give would be appreciated.


Then please try Deejays suggestion and let us know what it does :)

Run up LX Terminal and type

Code: Select all
sudo python
import RPi.GPIO as GPIO
GPIO.RPI_REVISION


Simon
Seeking help with Scratch and I/O stuff for Primary age children
http://cymplecy.wordpress.com/ @cymplecy on twitter
Posts: 2041
Joined: Fri Feb 24, 2012 6:19 pm
Location: Euxton, Lancashire, UK
by slindojr » Mon Jul 22, 2013 7:46 pm
Thanks to all who have taken the time to help!

I have tried all the suggestions. Nothing changed. In addition I did this:

sudo find /usr | grep -i gpio

I should have versions 0.4.1a or 0.5.3a for the RPI_REVISION to work.

I have 0.3.0.8a. I have tried everything to update the library.

with DeeJays suggestion: --> sudo apt-get update && sudo apt.get upgrade

Still GPIO lib version remains: 0.3.08a.

I have installed "Wheezy" from the download site dated 5-25-13 that should contain what I need, especially have updating and upgrading the libraries.

The question now becomes how to go outside the box and get rpi.gpio upgraded to the proper version???

Please, help if you can. I need those suggestions.

Stan
Posts: 17
Joined: Thu Feb 28, 2013 10:34 pm
by rpdom » Mon Jul 22, 2013 8:03 pm
Perhaps you don't have the Raspbian package installed, although I can't see why.

Try
Code: Select all
sudo apt-get install python-rpi.gpio


The current version is 0.5.3a-1, so that should be what you need.
Posts: 3410
Joined: Sun May 06, 2012 5:17 am
Location: Essex, UK
by jojopi » Mon Jul 22, 2013 8:08 pm
The 2013-05-25 image comes with RPi.GPIO-0.5.2a, which is why I said earlier that you must have installed the old version yourself.

To (re)install the version from the repository:
Code: Select all
sudo apt-get update
sudo apt-get install --reinstall python-rpi.gpio
But if your older version is taking precedence you will also need to find and remove it.
User avatar
Posts: 2036
Joined: Tue Oct 11, 2011 8:38 pm
by alexeames » Mon Jul 22, 2013 9:16 pm
Sounds like you may have installed an older version of RPi.GPIO at some point. If you did it with apt-get, the above should help. If you did it with a .deb file, there is a way to manually uninstall, but I don't know it.

You can sidestep this issue by tweaking the Python code though. If you know what Rev Pi you have, just delete a bit of the code. I presume it's the leds program. I don't think the others have Rev checking in. (It's a while since I wrote them) ;)

Just change...
Code: Select all
if GPIO.RPI_REVISION == 1:      # check Pi Revision to set port 21/27 correctly
    # define ports list for Revision 1 Pi
    ports = [25, 24, 23, 22, 21, 18, 17, 11, 10, 9, 8, 7]
else:
    # define ports list all others
    ports = [25, 24, 23, 22, 27, 18, 17, 11, 10, 9, 8, 7] 


if you have Rev 1 Pi to...
Code: Select all
ports = [25, 24, 23, 22, 21, 18, 17, 11, 10, 9, 8, 7]


if you have Rev 2 Pi to...
Code: Select all
ports = [25, 24, 23, 22, 27, 18, 17, 11, 10, 9, 8, 7] 


The only difference is 21/27

p.s. There's a whole section for Gertboard related stuff in the hardware forum. But smoking is not permitted in there. :lol:
Alex Eames RasPi.TV HDMIPi.com RasP.iO
User avatar
Posts: 2064
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
by slindojr » Mon Jul 22, 2013 10:26 pm
I can not tell you how proud I am of this FORUM!
I am in my seventies and for 45 of those years I have been a computer programmer and have help many a person get out a black hole. You have given me great ideas and now I am going to see if I have loaded the wrong version of Wheezy, possible when you are my age, and I will try -- reinstall

I know that I can work around the problem, but don't you just hate it when you have to do it!!!

THANK YOU ALL FOR YOUR KINDNESS...!

I am doing a lot of embedded design work using the Parallax Propeller Chip. If can help any of you with design or programming contact me at: slindojr@msn.com

Stan
Posts: 17
Joined: Thu Feb 28, 2013 10:34 pm
by alexeames » Tue Jul 23, 2013 7:23 am
LOL. You're probably 1000s of times better at programming than me then, but hopefully the workaround solution might help someone else doing a search in future :)

The pace of improvements to the OS is so fast, that I would recommend flashing a new SD card with the latest version of Raspbian - then, after update/upgrade you'll have RPi.GPIO 0.5.3a, which is now in the Raspbian repo.

OK, so you will probably lose some time setting things up just how you want them, but a clean start helps every once in a while. :)
Alex Eames RasPi.TV HDMIPi.com RasP.iO
User avatar
Posts: 2064
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
by vistauser » Tue Jul 23, 2013 10:21 am
Hi Stan,

had the same Problem.
Try this which helped me:

RPi.GPIO force to update from older version:
sudo pip install RPi.GPIO --upgrade

cheers
Olaf
Posts: 8
Joined: Mon Mar 18, 2013 6:48 pm