BlackJack
Posts: 288
Joined: Sat Aug 04, 2012 8:28 am
Contact: Website

Re: WiringPython - WiringPi for Python

Fri Aug 24, 2012 11:03 am

@Grumpy Mike: Just do the same search with „Windows” instead of „Linux”. Maybe it is a typical *user* reaction to ignore errors that don't seem to impact the result, because users can't do anything about it anyway.

Code: Select all

while not self.asleep():
    sheep += 1

User avatar
Grumpy Mike
Posts: 914
Joined: Sat Sep 10, 2011 7:49 pm
Location: Manchester (England England)
Contact: Website

Re: WiringPython - WiringPi for Python

Fri Aug 24, 2012 11:34 am

BlackJack wrote:@Grumpy Mike: Just do the same search with „Windows” instead of „Linux”. Maybe it is a typical *user* reaction to ignore errors that don't seem to impact the result, because users can't do anything about it anyway.
It may be, and my googling was not meant to be exclusive research. But I have seen many many threads on Linux forums that say, just ignore the error, even those posted by the author of the script or utility themselves. On one occasion where I looked at the script I found it would always generate an error message due to incorrect nesting of condition statements. Like I say this is poor but then my experience of Linux systems over the last three months has lead me to believe this is common. Things break very quickly with Linux, it is not a very stable platform. Having negotiated the "text adventure" game that is installation, next you are faced with the snakes and ladders that is new distros.

I would attempt to fix this problem myself but I know little about Python and how to provide wrappers to C functions. Maybe I should learn.

At the moment I believe that this library is the only way to access the PWM pin from Python, I have asked in another thread for alternatives but had no replies. I have contacted Gordon who wrote the actual WiringPi module but he is not a Python programmer and knows little about how to make it work with Python.

BlackJack
Posts: 288
Joined: Sat Aug 04, 2012 8:28 am
Contact: Website

Re: WiringPython - WiringPi for Python

Fri Aug 24, 2012 2:26 pm

@Grumpy Mike: Things don't break very quickly with Linux and it is a really stable platform. It is a server operating system which *has* to be stable. I think you are just experiencing that it is easy for everyone to hack in some quick and dirty scripts of questionable quality.

Installation does not have to be like a text adventure. There are GUI front ends like Synaptic to the package system.

Code: Select all

while not self.asleep():
    sheep += 1

dimonic
Posts: 41
Joined: Fri Jun 08, 2012 9:08 pm

Re: WiringPython - WiringPi for Python

Fri Aug 24, 2012 2:46 pm

Grumpy Mike wrote:It may be, and my googling was not meant to be exclusive research. But I have seen many many threads on Linux forums that say, just ignore the error, even those posted by the author of the script or utility themselves. On one occasion where I looked at the script I found it would always generate an error message due to incorrect nesting of condition statements. Like I say this is poor but then my experience of Linux systems over the last three months has lead me to believe this is common. Things break very quickly with Linux, it is not a very stable platform. Having negotiated the "text adventure" game that is installation, next you are faced with the snakes and ladders that is new distros.
No platform remains "stable" in the areas of active development, and that is exactly what you are looking at. "Linux", which you are criticising, is a stable OS. A Linux install should occurr without error messages. A Linux kernel compile should occur without error messages. On stable platforms it does. For stable packages, they do.

I have been working in Linux (as my primary OS) since 1996, and I can't tell you how many Windows re-installs (in my line of work) I have done since then, but in Linux I am still running the what was the original code-base, upgraded in place, with replaced hardware over time, many times. My uptimes are generally in the hundreds of days.

We are dealing with a new platform, and new packages on that platform. I think you will find that the "ignore error" mentions pretty much all have to do with one condition or the other. They will in fact be especially common to be stated by delvelopers, since the developer is in the unique position to know when an error can be ignored (and he has probably fixed the bug in his own code base).

As to the reason why such bugs actually get into the wild - typically, developers work incrementally. They add things, compile, build, test. Rarely do they take their code base and install it onto a fresh machine and build from scratch as this is very time consumung. Essentially, they let the users do the testing (more so since they are not being paid to develop the code, and also have a full time job doing other things), and even some of the bug-fixing. That said, I find that developers are pretty responsive to bugs and fix them far more quickly than in the commercial source world (try getting bugs fixed by Microsoft - the typical answer is that the bug will (or may) be fixed in the next release - which I would have to pay for).

Saulverde
Posts: 15
Joined: Fri Aug 17, 2012 12:18 am

Re: WiringPython - WiringPi for Python

Fri Aug 24, 2012 3:08 pm

@GrumpyMike ~ I only ignored the error because I'm not smart enough to fix it yet. I actually was careful to read every line in the console looking for errors otherwise I wouldn't have seen it. I know Gadgetoid is reading this thread and working on some raspbian instructions. In this instance I felt I was getting the error to more capable people.

If you are just looking to access the pins from python you should check out this article, http://log.liminastudio.com/writing/tut ... an-arduino
It works on the exported pin files so the program opens, writes and closes a file each time it changes a pin value or function. It works but it is much slower than using wiringpi with or without a python wrapper.

User avatar
Grumpy Mike
Posts: 914
Joined: Sat Sep 10, 2011 7:49 pm
Location: Manchester (England England)
Contact: Website

Re: WiringPython - WiringPi for Python

Fri Aug 24, 2012 3:52 pm

No platform remains "stable" in the areas of active development, and that is exactly what you are looking at. "Linux", which you are criticising, is a stable OS.
So it is stable and not stable simultaneously, rather like Schrodinger's cat.
try getting bugs fixed by Microsoft -
So Mussolini was not so bad you should have seen Hitler!

Yes I do know it is a development platform and it is new, and these people are doing it for free.
I know Gadgetoid is reading this thread and working on some raspbian instructions. In this instance I felt I was getting the error to more capable people.
Yes if you read the thread you will see I pointed out this missing file on Aug 19, Aug 24 and Gadgetoid himself mentioned it on Aug 21 and doesn't know why it is happening.
If you are just looking to access the pins from python
No I can do that, what I said is that I want to access the PWM pin. I can do it in C but not Python.

I had a look at writing a wrapper myself. Typical Linux text adventure.
Found how to do it on http://karuppuswamy.com/wordpress/2012/ ... c-library/
Tried it and it didn't work because it could not find the .os file.
So searched on that and found an answer about changing a environment variable LD_LIBRARY_PATH, but that didn't do it so did some more searching and was directed to install some utility that I would have to install three other things before I could install that. Am I supposed to be impressed? Open the door but the dragon is in the way. So give the dragon some food but have to get some gold to buy the food, the gold is behind the door so open the door.

Still so long as it is better than Microsoft it is all OK isn't it.

dimonic
Posts: 41
Joined: Fri Jun 08, 2012 9:08 pm

Re: WiringPython - WiringPi for Python

Fri Aug 24, 2012 4:11 pm

@Grumpy Mike - no, I am not saying you are supposed to be impressed or unimpressed. Clearly with a moniker like grumpy mike, you make it your "style" to be unimpressed. I am sure I am not going to change that.

Your "Schrodinger's cat" mention is of course, I sure you realize quite unreasonable, albeit somewhat witty.

A good new car is stable. The same company probably has a similar car in development, adding new features, testing them - that is probably quite unstable - although it could be based on the stable model you are driving right now. Is it fair to criticize (for example) the current Toyota Fj Cruiser based on a test drive of the engineer's prototype for next year? Is that then a Schrodinger's car?

You sound like a smart fellow. I am sure you will get stuff working in the end. I am just trying to set your expectations reasonably, and deflect your unreasonable criticism of Linux in general - which you are basing on your experience with a bleeding edge (brand new) platform and architecture, and a bleeding edge (just written) package. We are all in this together. Criticising the tools and the community is not going to get you help any faster.

BlackJack
Posts: 288
Joined: Sat Aug 04, 2012 8:28 am
Contact: Website

Re: WiringPython - WiringPi for Python

Fri Aug 24, 2012 4:22 pm

@Grumpy Mike: Not like Schrodinger's cat — we have more than one cat here. Linux is stable as it is possible to install and run a pretty stable system with it. And then there are versions and parts under developement which may be not so stable. Drawing conclusions about the system by looking at random user's scripts or the build process of Python bindings to the WiringPi library, where the bindings and the library are quite new, is a huge leap.

Writing a wrapper is not a „typical Linux text adventure”. It would be the same „adventure” on other platforms. For using the `ctypes` module you don't need some utility that needs three other things. Knowing C, Python, and how the `ctypes` module works should be enough to interface a shared library with C calling conventions and a known API.

Code: Select all

while not self.asleep():
    sheep += 1

Saulverde
Posts: 15
Joined: Fri Aug 17, 2012 12:18 am

Re: WiringPython - WiringPi for Python

Fri Aug 24, 2012 4:23 pm

Wouldn't it be easier to help gadgetoid de-bug rather than starting from scratch?

gadgetoid
Posts: 152
Joined: Wed Mar 07, 2012 9:58 pm

Re: WiringPython - WiringPi for Python

Sat Aug 25, 2012 7:13 am

If all else fails, you should be able to check out the version of WiringPi-Python from Git prior to the changes which seem to have broke the build.

Those changes were the start of PyPI packaging, which should ultimately make this install a fairly simple process- ala RPi.GPIO. Alas I'm still learning and don't have a lot of help, but we'll get there!

BlackJack
Posts: 288
Joined: Sat Aug 04, 2012 8:28 am
Contact: Website

Re: WiringPython - WiringPi for Python

Sat Aug 25, 2012 7:45 am

@gadgetoid: The problem seems to be ``packages = ["WiringPi"],`` in the ``setup.py``. There is no package by that name.

Code: Select all

while not self.asleep():
    sheep += 1

gadgetoid
Posts: 152
Joined: Wed Mar 07, 2012 9:58 pm

Re: WiringPython - WiringPi for Python

Sat Aug 25, 2012 8:45 am

BlackJack wrote:@gadgetoid: The problem seems to be ``packages = ["WiringPi"],`` in the ``setup.py``. There is no package by that name.
I didn't add it, and am not sure exactly what it's there for. But I'll remove it and see if it builds for me.


I've added the package to pypi, http://pypi.python.org/pypi/wiringpi/1.0

You may be able to "pip install wiringpi", but I can't appear to uninstall it so that I can test this.

BlackJack
Posts: 288
Joined: Sat Aug 04, 2012 8:28 am
Contact: Website

Re: WiringPython - WiringPi for Python

Sat Aug 25, 2012 11:01 am

@gadgetoid: There is no reason to have `packages` in an extension that doesn't actually have packages. It is an error. That's why it generates the ``package init file 'WiringPi/__init__.py' not found (or not a regular file)`` message.

Code: Select all

while not self.asleep():
    sheep += 1

dawid
Posts: 1
Joined: Sat Aug 25, 2012 8:29 pm

Re: WiringPython - WiringPi for Python

Sat Aug 25, 2012 8:41 pm

Grumpy Mike wrote:I have found that if after the:-
git pull origin master
I then go and make a copy of the file wiringSerial.c and call it serial.c
I can then go through all the steps at http://blogs.foomatic.org/blink-away-the-tears/
Successfully, until the end, step 5 testing.
gpio commands issued from the command line don't appear to do anything and an
import wiringpi
in a python script will give me a :-
"No module named wiringpi" error message.
The problem is that the file wiringpi.py is not installed, is was lost in an commit, Aug 18, 2012, c93dadf7cf826878968dc49048f3b7e6f6287691.

There is a fix in https://github.com/WiringPi/WiringPi-Python/pull/4

Saulverde
Posts: 15
Joined: Fri Aug 17, 2012 12:18 am

Re: WiringPython - WiringPi for Python

Sat Aug 25, 2012 9:40 pm

can someone post instructions on getting the old install?

gadgetoid
Posts: 152
Joined: Wed Mar 07, 2012 9:58 pm

Re: WiringPython - WiringPi for Python

Sun Aug 26, 2012 9:43 pm

Saulverde wrote:can someone post instructions on getting the old install?
Something to the tune of:

Code: Select all

git checkout c9d00e49cff5ebf17ac75b581f95167092471662
But try:

Code: Select all

sudo pip install wiringpi
First.

sparkyhall
Posts: 130
Joined: Mon Aug 27, 2012 9:14 am

Re: WiringPython - WiringPi for Python

Mon Aug 27, 2012 9:35 am

@gadgetoid issuing "pip install wiringpi" (as root) installs wiringpi but running the following test code causes a segmentation fault, this is on slackware 14rc2:

Code: Select all

#!/usr/bin/python

import time
import wiringpi
wiringpi.wiringPiSetup # for sequential pin numbering

# set RPi board pin 12 as output
wiringpi.pinMode(1,1)

while True:
  wiringpi.digitalWrite(1,1)
  time.sleep(0.001)
  wiringpi.digitalWrite(1,0)
  time.sleep(0.001)
I then tried the same on Raspian as follows:

Code: Select all

sudo apt-get install python-pip
sudo pip install wiringpi
I followed this by running my test code via sudo which promptly returned me to the command line with no errors. I then tried running as normal user and this time my test code gave me a segmentation fault so I guess sudo somehow prevents the seg fault from being reported.

It seems that wiringpi-python is still broken. Anyhow a big thanks for all your efforts in trying to get this working.

gadgetoid
Posts: 152
Joined: Wed Mar 07, 2012 9:58 pm

Re: WiringPython - WiringPi for Python

Mon Aug 27, 2012 8:14 pm

sparkyhall wrote: I followed this by running my test code via sudo which promptly returned me to the command line with no errors.
You must, indeed, run as root. Normal users do not have access to the shared memory mumbo-jumbo that makes GPIO happen.

Alternatively you can use Gordon's GPIO binary to export the /sys/class/gpio stuff into userspace, and then run in the alternate mode. It's slower, but not needing to run as root is handy if you're paranoid about security or something to that effect.

Also... slackware! Wow... I'm going to have my work cut out for me testing different distributions when my second Pi turns up!

User avatar
Bigcat123
Posts: 230
Joined: Thu Aug 23, 2012 2:41 pm

Re: WiringPython - WiringPi for Python

Tue Aug 28, 2012 6:48 pm

Any one got some instructions for how to install wiringPI.py.... The link does not work (404).

Please help, I am very interested in using it instead of RPI.GPIO 0.3.1a!!! :) :)
Just a beginner sharing his experiences on his way to geek nirvana...

sparkyhall
Posts: 130
Joined: Mon Aug 27, 2012 9:14 am

Re: WiringPython - WiringPi for Python

Thu Aug 30, 2012 9:56 pm

gadgetoid wrote:
sparkyhall wrote: I followed this by running my test code via sudo which promptly returned me to the command line with no errors.
You must, indeed, run as root. Normal users do not have access to the shared memory mumbo-jumbo that makes GPIO happen.

Alternatively you can use Gordon's GPIO binary to export the /sys/class/gpio stuff into userspace, and then run in the alternate mode. It's slower, but not needing to run as root is handy if you're paranoid about security or something to that effect.

Also... slackware! Wow... I'm going to have my work cut out for me testing different distributions when my second Pi turns up!
I have finally figured out why I was getting seq faults, the "wiringpi.wiringPiSetup" line in my test code needs brackets on the end i.e it should be "wiringpi.wiringPiSetup()". It may be a good idea to update your readme file as this is also missing the brackets under the usage examples.

I can now confirm that

Code: Select all

sudo pip install wiringpi
does work as does pulling wiringpi-python-1.0.5 from git and running

Code: Select all

python setup.py install
One other point worth mentioning is that if you want to run wiringpi-python as a normal user then you need to build/install the wiringpi library so that you can export the GPIO pin, is it not possible for wiringpi-python to install this automatically?

Regards,

sparkyhall

User avatar
Bigcat123
Posts: 230
Joined: Thu Aug 23, 2012 2:41 pm

Re: WiringPython - WiringPi for Python

Fri Aug 31, 2012 4:23 pm

Seems to me that wiring-python is no where near as good as RPi.GPIO! Not going to even bother installing it
Just a beginner sharing his experiences on his way to geek nirvana...

texy
Forum Moderator
Forum Moderator
Posts: 5155
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England

Re: WiringPython - WiringPi for Python

Fri Aug 31, 2012 4:28 pm

.......because you can't install it ?

T.
Various male/female 40- and 26-way GPIO header for sale here ( IDEAL FOR YOUR PiZero ):
https://www.raspberrypi.org/forums/viewtopic.php?f=93&t=147682#p971555

dimonic
Posts: 41
Joined: Fri Jun 08, 2012 9:08 pm

Re: WiringPython - WiringPi for Python

Fri Aug 31, 2012 4:37 pm

Bigcat123 wrote:Seems to me that wiring-python is no where near as good as RPi.GPIO! Not going to even bother installing it
It would be a pity if people choose not to use the best tool for a job because they have heard of some (vocal) users' difficulty in getting the latest version of the tool installed. For myself, I tend to look into the specifications of the tool choices out there, look at the overal experiences people have, and then make studious attempts to learn what appears to be the best tool.

I am accustomed to experiencing occasional glitches in installing all but the most "produced for mass consumption" software, and I do not expect (nor always get) one click installs, or even error free installs - although more often than not, I do get that.

The main advantage of WiringPi for me (over other tools) is that it closely (by design) resembles another tool I have spent some time learning - Wiring for the Arduino. This enables me to hit the ground running in terms of development - once I have succesfully installed the tools. If your needs do not include a development environment and language that resembles that for the Arduino - then by all means choose another tool that appear easier to use for you.

User avatar
Grumpy Mike
Posts: 914
Joined: Sat Sep 10, 2011 7:49 pm
Location: Manchester (England England)
Contact: Website

Re: WiringPython - WiringPi for Python

Sat Sep 01, 2012 11:30 am

Bigcat123 wrote:Seems to me that wiring-python is no where near as good as RPi.GPIO! Not going to even bother installing it
It is the only package that supports the PWM pin, so if you need to use that then this is all you can do.

Got it installed now :D
The trick was to do a 'sudo apt-get install python-setuptools' first
Then I followed the instructions in
http://blogs.foomatic.org/blink-away-the-tears/
I have added a comment pointing out the bit that is lacking.

gadgetoid
Posts: 152
Joined: Wed Mar 07, 2012 9:58 pm

Re: WiringPython - WiringPi for Python

Sat Sep 01, 2012 1:17 pm

I've been busy with other decidedly more awesome Pi-related projects as of late, but I'm keeping my eye on this thread.

I have an updated Python package in the works, including all of Gordon's changes to WiringPi to date and adding some general cleanup where I can.

I'm still learning Python, so excuse any failings in my documentation or code and know that I take any suggestions or criticism seriously and without prejudice!

I will endeavour to get the GPIO binary source packaged in and somehow built when the PyPi package is installed, so that it can be used to setup the userspace mode. I've no clue if this is even possible in a Python package, but it can't hurt to try!

Cheers for the ongoing feedback, and thanks most of all to Gordon for actually creating WiringPi in the first place and developing it constantly!

Return to “Python”