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

Don your testing hats, it's WiringPi2-Python

Thu Mar 28, 2013 12:17 am

Dear Pythonistas, Pythonists, Pythonese? No matter the name you assign yourselves, I must bow to your superior knowledge and experience of Python and ask you to try the following:

sudo pip install wiringpi2

For more information on exactly what this is and does, see my blog post here: http://pi.gadgetoid.com/post/039-wiring ... tra-python

And, more importantly, Gordon's new website here, paying particular attention to the "extensions" page: http://wiringpi.com/

Ultimately, if you use WiringPi-Python this is the library you'll want to migrate to. It's effectively the same, although it currently lacks the class-based stuff and includes a lot more shinies; yes that means

With WiringPi 2, playing with an MCP23017 ( the chip found on the Quick2Wire expander and HobbyTronics expander amongst others ) is as simple as:

Code: Select all

import wiringpi2

pin_base = 65
i2c_addr = 0x20
pins = [65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80]

wiringpi2.wiringPiSetup()
wiringpi2.mcp23017Setup(pin_base,i2c_addr)

for pin in pins:
	wiringpi2.pinMode(pin,1)
	wiringpi2.digitalWrite(pin,1)
You can then increment your pin_base to 81 and add another one there, giving you a seamless pair ( or more if you dare ) of IO expanders which you can very easily keep track of and enumerate.

See the GitHub repo here: https://github.com/Gadgetoid/WiringPi2-Python/

And the theoretical list of supported functions is as follows ( I don't know how many of these functions work and to what extent... I have a lot of testing to do, and not yet enough hardware to test it on ):

Code: Select all

int  wiringPiSetup       (void) ;    // Setup wiringPi using shared memory mode, requires root
int  wiringPiSetupSys    (void) ; // Setup wiringPi using /sys/class/gpio
int  wiringPiSetupGpio   (void) ;


int  piBoardRev          (void) ;  // Get the board revision of your Pi
int  wpiPinToGpio        (int wpiPin) ;  // Convert from WiringPi Pin numbering to GPIO Pin numbering

extern void pinMode           (int pin, int mode) ; // Set the mode ( 1 write, 0 read ) of a pin
extern int  getAlt            (int pin) ;
extern void pullUpDnControl   (int pin, int pud) ;
extern void digitalWrite      (int pin, int value) ; // Write a value ( 1 high, 0 low ) to a pin
extern void digitalWriteByte  (int value) ;
extern void gpioClockSet      (int pin, int freq) ;
extern void pwmWrite          (int pin, int value) ;
extern void setPadDrive       (int group, int value) ;
extern int  digitalRead       (int pin) ; // Read a value ( 1 high, 0 low ) from a pin

extern void pwmSetMode        (int mode) ;
extern void pwmSetRange       (unsigned int range) ;
extern void pwmSetClock       (int divisor) ;

// Interrupts
int  (*waitForInterrupt) (int pin, int mS) ;
int  wiringPiISR         (int pin, int mode, void (*function)(void)) ;

// Threads
int  piThreadCreate (void *(*fn)(void *)) ;
void piLock         (int key) ;
void piUnlock       (int key) ;

// Extras from arduino land
void         delay             (unsigned int howLong) ;
void         delayMicroseconds (unsigned int howLong) ;
unsigned int millis            (void) ;
unsigned int micros            (void) ;

// WiringSerial
int   serialOpen      (char *device, int baud) ;
void  serialClose     (int fd) ;
void  serialFlush     (int fd) ;
void  serialPutchar   (int fd, unsigned char c) ;
void  serialPuts      (int fd, char *s) ;
void  serialPrintf    (int fd, char *message, ...) ;
int   serialDataAvail (int fd) ;
int   serialGetchar   (int fd) ;

// Shifting
void shiftOut          (uint8_t dPin, uint8_t cPin, uint8_t order, uint8_t val);
uint8_t shiftIn        (uint8_t dPin, uint8_t cPin, uint8_t order);

// Spi
int wiringPiSPIGetFd  (int channel) ;
int wiringPiSPIDataRW (int channel, unsigned char *data, int len) ;
int wiringPiSPISetup  (int channel, int speed) ;

// i2c
int wiringPiI2CRead       (int fd) ;
int wiringPiI2CReadReg8   (int fd, int reg) ;
int wiringPiI2CReadReg16  (int fd, int reg) ;

int wiringPiI2CWrite      (int fd, int data) ;
int wiringPiI2CWriteReg8  (int fd, int reg, int data) ;
int wiringPiI2CWriteReg16 (int fd, int reg, int data) ;

// Soft Tone
int  softToneCreate (int pin) ;
void softToneWrite  (int pin, int frewq) ;

// Soft Servo
void softServoWrite  (int pin, int value) ;
int softServoSetup   (int p0, int p1, int p2, int p3, int p4, int p5, int p6, int p7) ;

// Soft PWM
int  softPwmCreate (int pin, int value, int range) ;
void softPwmWrite  (int pin, int value) ;

// mcp23x17
int mcp23s17Setup (int pinBase, int spiPort, int devId) ;
int mcp23017Setup (int pinBase, int i2cAddress) ;

// mcp23x08
int mcp23s08Setup (int pinBase, int spiPort, int devId) ;
int mcp23008Setup (int pinBase, int i2cAddress) ;

// 595 shift register
int sr595Setup (int pinBase, int numPins, int dataPin, int clockPin, int latchPin) ;

// Pi Face
int  piFaceSetup (int pinbase) ;

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2848
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: Don your testing hats, it's WiringPi2-Python

Thu Mar 28, 2013 10:05 am

This looks great Phil.

I'm just downloading a brand new distro to flash a new card to try this out on. The port expander part looks excellent :) even better, since I have one of those chips with me I can test it out. :lol:

Have you implemented the spi version of this chip (MCP23s17) as well? I see Gordon has on his new site.
Alex Eames RasPi.TV, RasP.iO

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

Re: Don your testing hats, it's WiringPi2-Python

Thu Mar 28, 2013 10:44 am

Implemented: yes. Tested: no. I don't have one to try!

Good luck, and do yell at me if anything explodes. Gordon has tested it, I believe, so if it doesn't work it's probably the wrappers fault.

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2848
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: Don your testing hats, it's WiringPi2-Python

Thu Mar 28, 2013 2:00 pm

Install failed on a brand new raspbian distro with python pip and python dev already installed.

Would this be because I installed wiringpi before wiringpi2? Can they coexist?

The message was...
WiringPi/wiringPi/piNes.c:25:22: fatal error: wiringPi.h: No such file or directory

compilation terminated

error: command 'gcc' failed with exit status 1

I sudo pip uninstalled wiringpi and got the same message when I tried to install wiringpi2 again. :(

Are there any other dependencies needed for the build? I remember in the early days wiringpi compilation used to fail in a very similar way
Alex Eames RasPi.TV, RasP.iO

canyon
Posts: 38
Joined: Sun Jan 29, 2012 9:47 am
Location: London UK

Re: Don your testing hats, it's WiringPi2-Python

Thu Mar 28, 2013 2:27 pm

Hi,
I got the same error as @alexjames, so it may be pervasive.
Unfortunately I don't understand c so I can't contribute by trying to debug the installer. :(

Great news that wiringpi2 is now available- I became a fan of the original version when I first got my Pi in May last year.

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

Re: Don your testing hats, it's WiringPi2-Python

Thu Mar 28, 2013 5:24 pm

I've managed to replicate this error by uninstalling WiringPi entirely from my system and attempting to install the Python package.

It's a classic problem I should have remembered from the original WiringPi- the include in the top of piNes.c uses <> instead of "". I'm not sharp on C, so I don't know what the implications of this are, but the result is that it looks in normal include paths for the wiringPi library rather than in the same folder it's compiling piNes.c in.

Fix incoming!


Fix uploaded, wiringpi2-1.0.2

Please remove any build directory you might have where pip failed, it should have a text file in to the tune of pip_delete_this_folder.txt.

Then run pip install wiringpi2 again and rejoice! ( hopefully )


Edit: Thanks for testing this, guys, it's a huge help!

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2848
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: Don your testing hats, it's WiringPi2-Python

Thu Mar 28, 2013 8:33 pm

OK, that installed this time. Now to make it do something :)

Code: Select all

sudo python
>>>wiringpi2.piBoardRev()
2
>>>
Seems to work. Will have a more ambitious play tomorrow.
Alex Eames RasPi.TV, RasP.iO

davidb24v
Posts: 19
Joined: Sat Dec 10, 2011 9:32 am

Re: Don your testing hats, it's WiringPi2-Python

Thu Mar 28, 2013 8:58 pm

gadgetoid wrote:Implemented: yes. Tested: no. I don't have one to try!

Good luck, and do yell at me if anything explodes. Gordon has tested it, I believe, so if it doesn't work it's probably the wrappers fault.
This is great stuff, will have a play soon, got too many other things to play with at the moment - me and my credit card :oops:

If you would like an MCP23s17 to play with then PM me and I'll send you one. I wanted one, once upon a time. It was much "cheaper" if I bought a pack of 10 :roll:

I did the Tcl bindings for WiringPI but I've pretty much given up on that now. Been using Tcl for 20+ years but I can't get any traction with it at work with the younger people. It be Pythons all the way down from here on in...

As a Python n00b, currently ripping through the Real Python course, you can replace your "pins =
  • " with "pins = range(65,81)". It's less typing, I do like less typing...

    Dave

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2848
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: Don your testing hats, it's WiringPi2-Python

Thu Mar 28, 2013 9:37 pm

Don't know if I've got something wrong, but...

Code: Select all

import wiringpi2
wiringpi2.wiringPiSetupGpio()              # initialise wiringpi
wiringpi2.pinMode(24, 1)                   # set up port 24 for output
wiringpi2.digitalWrite(24, 1)
...this switches on the led on GPIO 8

I thought I'd set it up for BCM?
Alex Eames RasPi.TV, RasP.iO

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

Re: Don your testing hats, it's WiringPi2-Python

Thu Mar 28, 2013 11:03 pm

I'm not entirely sure what you mean, but this page provides a complex overview of the different pin numbering schemes:

http://wiringpi.com/pins/

I usually just use "wiringpi.wiringPiSetup" without any of the numbering specific suffixes.

Also, all of my tests have involved various expansion boards and I haven't played much with a bare Pi... perhaps I should go back to basics and throw together a cleaner graphic for pin numbering!

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2848
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: Don your testing hats, it's WiringPi2-Python

Fri Mar 29, 2013 9:47 am

gadgetoid wrote:I'm not entirely sure what you mean, but this page provides a complex overview of the different pin numbering schemes:

http://wiringpi.com/pins/

I usually just use "wiringpi.wiringPiSetup" without any of the numbering specific suffixes.

Also, all of my tests have involved various expansion boards and I haven't played much with a bare Pi... perhaps I should go back to basics and throw together a cleaner graphic for pin numbering!
OK. It was late, I was trying to be quick. I'll give you a full answer now.
I'm well aware of all the pin numbering schemes. I use BCM GPIO numbers almost all the time.

I have written Python software for the Gertboard. I was testing some last night on wiringpi2, namely the program leds-wp.py, with changes to make it run on wiringpi2

The software is at raspi.tv/downloads

Because the Gertboard uses BCM GPIO port numbering, and I am used to it, I stuck with that, but something is badly broken - either my code or yours. The led pattern is all over the place and not in sequence at all. Some leds don't light, others are out of sequence. (It works fine on the same setup still with RPi.GPIO :p)

It seems to me that

Code: Select all

wiringpi2.wiringPiSetupGpio()
is not working. For boards like the Gertboard, it is essential that it works, or we'll have to stick to original wiringpi.

It is also possible that I've got something wrong and the new version needs a different call. I thought you might be able to throw light on that. :D
Alex Eames RasPi.TV, RasP.iO

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

Re: Don your testing hats, it's WiringPi2-Python

Fri Mar 29, 2013 12:06 pm

Didn't mean to patronise you, just trying to get to the bottom of it.

The additional detail helped, and Gordon is looking into it. I'll keep you posted if he doesn't drop by himself!

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2848
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: Don your testing hats, it's WiringPi2-Python

Fri Mar 29, 2013 12:18 pm

gadgetoid wrote:Didn't mean to patronise you, just trying to get to the bottom of it.

The additional detail helped, and Gordon is looking into it. I'll keep you posted if he doesn't drop by himself!
No worries. My post wasn't overly clear and descriptive. I can run some further tests if needed.
Alex Eames RasPi.TV, RasP.iO

User avatar
gordon@drogon.net
Posts: 2020
Joined: Tue Feb 07, 2012 2:14 pm
Location: Devon, UK
Contact: Website

Re: Don your testing hats, it's WiringPi2-Python

Fri Mar 29, 2013 12:24 pm

alexeames wrote: OK. It was late, I was trying to be quick. I'll give you a full answer now.
I'm well aware of all the pin numbering schemes. I use BCM GPIO numbers almost all the time.

I have written Python software for the Gertboard. I was testing some last night on wiringpi2, namely the program leds-wp.py, with changes to make it run on wiringpi2

The software is at raspi.tv/downloads

Because the Gertboard uses BCM GPIO port numbering, and I am used to it, I stuck with that, but something is badly broken - either my code or yours. The led pattern is all over the place and not in sequence at all. Some leds don't light, others are out of sequence. (It works fine on the same setup still with RPi.GPIO :p)

It seems to me that

Code: Select all

wiringpi2.wiringPiSetupGpio()
is not working. For boards like the Gertboard, it is essential that it works, or we'll have to stick to original wiringpi.
My fault.... (And Gadgetoids for taking beta software - I've not properly released wiringPi v2 myself yet, however it's good to get feedback!

There was a copy&paste error in the digitalWrite() function - all to do with me adding in support for the physical P1 connector pins (which I understand some people want to use!)

I've fixed it now & the good Mr Gadgetoid has the fix.

I'm hoping to officially release my own C version this weekend along with the new website, etc.

-Gordon
--
Gordons projects: https://projects.drogon.net/

User avatar
gordon@drogon.net
Posts: 2020
Joined: Tue Feb 07, 2012 2:14 pm
Location: Devon, UK
Contact: Website

Re: Don your testing hats, it's WiringPi2-Python

Fri Mar 29, 2013 12:37 pm

alexeames wrote:Don't know if I've got something wrong, but...

Code: Select all

import wiringpi2
wiringpi2.wiringPiSetupGpio()              # initialise wiringpi
wiringpi2.pinMode(24, 1)                   # set up port 24 for output
wiringpi2.digitalWrite(24, 1)
...this switches on the led on GPIO 8

I thought I'd set it up for BCM?
Well it shows the physical pin numbering works ;-) Physical P1 pin 24 is BCM_GPIO 8, or wiringPi pin 10...

Slight bug in my code... Fixed!

Cheers,

-Gordon
--
Gordons projects: https://projects.drogon.net/

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

Re: Don your testing hats, it's WiringPi2-Python

Fri Mar 29, 2013 12:38 pm

Yes. I should probably make it abundantly clear that this is beta! But I'd like to have WiringPi-Python, at least, ready to go and reasonably robust by the time WiringPi2 is officially released.

Fix has been pushed up to pypi as v1.0.3. Please give it a punt and let me know!

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2848
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: Don your testing hats, it's WiringPi2-Python

Fri Mar 29, 2013 12:41 pm

I broke down the leds test code into essentials to test each of the 12 ports used in this test...

Code: Select all

import wiringpi2
import time
wiringpi2.wiringPiSetupGpio() 

ports = [25, 24, 23, 22, 27, 18, 17, 11, 10, 9, 8, 7] #rev 2 Pi

for port in ports:
    wiringpi2.pinMode(port, 1) # set up ports

for port in ports:
    wiringpi2.digitalWrite(port, 1)
    print "setting port %d HIGH" % port
    time.sleep(3)
    wiringpi2.digitalWrite(port, 0)
    print "setting port %d LOW" % port
Outcome:
25 -
24 GPIO8
23 GPIO11
22 GPIO25
27 -
18 GPIO24
17 -
11 GPIO17
10 -
9 -
8 -
7 -

- equals no visible change. Where I've put a GPIO number, that's the BCM GPIO port that was triggered.

By the way, in a live Python environment, wiringpi2.wiringPiSetupGpio() returns 0 (I don't know if it's meant to do that or not?)
Alex Eames RasPi.TV, RasP.iO

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2848
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: Don your testing hats, it's WiringPi2-Python

Fri Mar 29, 2013 12:45 pm

gadgetoid wrote:Yes. I should probably make it abundantly clear that this is beta! But I'd like to have WiringPi-Python, at least, ready to go and reasonably robust by the time WiringPi2 is officially released.

Fix has been pushed up to pypi as v1.0.3. Please give it a punt and let me know!
Excellent. I'll get on it. :)
Alex Eames RasPi.TV, RasP.iO

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

Re: Don your testing hats, it's WiringPi2-Python

Fri Mar 29, 2013 12:49 pm

While I have a probably-far-more-experienced-than-I Python user to bounce off, can I ask if there's a specific reason that you don't use:
from wiringpi2 import *
I know it might have implications if it tramples any identically named functions, but I'd have thought wiringpi's would be pretty unique?

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2848
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: Don your testing hats, it's WiringPi2-Python

Fri Mar 29, 2013 12:53 pm

gadgetoid wrote:While I have a probably-far-more-experienced-than-I Python user to bounce off, can I ask if there's a specific reason that you don't use:
from wiringpi2 import *
I know it might have implications if it tramples any identically named functions, but I'd have thought wiringpi's would be pretty unique?
It's just habit I think. :D I'm not that vastly experienced with Python myself. Writing these progs was a learning challenge I set myself. :D

By the way the fix works fine. Gertboard leds program now works as expected with only one tweak, which was changing

Code: Select all

import wiringpi

to

Code: Select all

import wiringpi2 as wiringpi
Lazy, but it works :)
Last edited by alexeames on Fri Mar 29, 2013 1:17 pm, edited 1 time in total.
Alex Eames RasPi.TV, RasP.iO

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

Re: Don your testing hats, it's WiringPi2-Python

Fri Mar 29, 2013 12:58 pm

I use

Code: Select all

import wiringpi2 as wiringpi
And I don't consider it lazy at all.

I think the two libraries are more or less method for method compatible, and I'd personally either do the above or import all of the methods into whatever Python's equivalent of the Kernel class is.

Great news that it's now working as expected. Give us a shout if you manage to try out some of the new features and newly available old features.

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2848
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: Don your testing hats, it's WiringPi2-Python

Fri Mar 29, 2013 1:21 pm

gadgetoid wrote:I use

Code: Select all

import wiringpi2 as wiringpi
And I don't consider it lazy at all.
Efficient maybe then? It was easier to do that than go through the program changing every instance of wiringpi to wiringpi2.

Great - now the basics seem to be working, I'll see about testing something else. :)
Alex Eames RasPi.TV, RasP.iO

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2848
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: Don your testing hats, it's WiringPi2-Python

Fri Mar 29, 2013 1:44 pm

Pullups this time :lol:

another Gertboard program buttons-wp.py

In the previous version I used...

Code: Select all

wiringpi.pullUpDnControl(port_num, wiringpi.PUD_UP)
...to set the pullups

This bombs out in wiringpi2, so I tried

Code: Select all

wiringpi.pullUpDnControl(port_num, 1)
instead of wiringpi.PUD_UP
and although it doesn't error out, it also doesn't read the buttons either. :(

Any pointers?
Alex Eames RasPi.TV, RasP.iO

User avatar
gordon@drogon.net
Posts: 2020
Joined: Tue Feb 07, 2012 2:14 pm
Location: Devon, UK
Contact: Website

Re: Don your testing hats, it's WiringPi2-Python

Fri Mar 29, 2013 2:10 pm

alexeames wrote:Pullups this time :lol:

another Gertboard program buttons-wp.py

In the previous version I used...

Code: Select all

wiringpi.pullUpDnControl(port_num, wiringpi.PUD_UP)
...to set the pullups

This bombs out in wiringpi2, so I tried

Code: Select all

wiringpi.pullUpDnControl(port_num, 1)
instead of wiringpi.PUD_UP
and although it doesn't error out, it also doesn't read the buttons either. :(

Any pointers?
When you say "bombs out" what do you mean? The underlying C code can't generate an error message, however if you've not initialised wiringPi then it could crash the program..

My own test program (in C) works fine on the Gertboard in wiringPi or BCM_GPIO modes...

Code: Select all

/*
 * buttons.c:
 *      Read the Gertboard buttons. Each one will act as an on/off
 *      tiggle switch for 3 different LEDs
 *
 * Copyright (c) 2012-2013 Gordon Henderson. <projects@drogon.net>
 ***********************************************************************
 */


#include <stdio.h>
#include <wiringPi.h>

// Array to keep track of our LEDs

int leds [] = { 0, 0, 0 } ;

int pinMap [8] =
{
  17, 18, 21, 22, 23, 24, 25, 7
} ;


// scanButton:
//      See if a button is pushed, if so, then flip that LED and
//      wait for the button to be let-go

void scanButton (int button)
{
  if (digitalRead (pinMap [button]) == HIGH)    // Low is pushed
    return ;

  leds [button] ^= 1 ; // Invert state
  digitalWrite (pinMap [4 + button], leds [button]) ;

  while (digitalRead (pinMap [button]) == LOW)  // Wait for release
    delay (10) ;
}

int main (void)
{
  int i ;

  printf ("Raspberry Pi Gertboard Button Test - GPIO\n") ;

  wiringPiSetupGpio () ;

// Setup the outputs:
//      Pins 3, 4, 5, 6 and 7 output:
//      We're not using 3 or 4, but make sure they're off anyway
//      (Using same hardware config as blink12.c)

  for (i = 3 ; i < 8 ; ++i)
  {
    pinMode      (pinMap [i], OUTPUT) ;
    digitalWrite (pinMap [i], 0) ;
  }

// Setup the inputs

  for (i = 0 ; i < 3 ; ++i)
  {
    pinMode         (pinMap [i], INPUT) ;
    pullUpDnControl (pinMap [i], PUD_UP) ;
    leds [i] = 0 ;
  }

  for (;;)
  {
    for (i = 0 ; i < 3 ; ++i)
      scanButton (i) ;
    delay (1) ;
  }
}
-Gordon
--
Gordons projects: https://projects.drogon.net/

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2848
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: Don your testing hats, it's WiringPi2-Python

Fri Mar 29, 2013 2:45 pm

It was an error message from Python, something about PUD_UP not being an attribute of the wiringpi module (from memory). I'll run it again and catch the exact message.

Code: Select all

pi@raspberrypi ~/GB_Python $ sudo python buttons-wp.py 
Traceback (most recent call last):
  File "buttons-wp.py", line 13, in <module>
    wiringpi.pullUpDnControl(port_num, wiringpi.PUD_UP) #set pullups
AttributeError: 'module' object has no attribute 'PUD_UP'
pi@raspberrypi ~/GB_Python $ 
It's from the buttons-wp.py prog. All I changed was the import to import wiringpi2 as wiringpi. So the initialisation should have been the same as for the LEDS program.
Last edited by alexeames on Fri Mar 29, 2013 2:57 pm, edited 1 time in total.
Alex Eames RasPi.TV, RasP.iO

Return to “Python”