Jzhou187
Posts: 6
Joined: Fri Feb 06, 2015 10:47 pm

Webiopi doesn't work on Raspberry Pi 2

Fri Feb 06, 2015 11:03 pm

I bought 3 Pi2 and try to replace one of my Pi B+ which is running webiopi but I got error with the Pi2:
pi@pi2garage ~/WebIOPi-0.7.0/htdocs $ sudo webiopi -d -c /etc/webiopi/config
2015-02-06 17:02:36 - WebIOPi - INFO - Starting WebIOPi/0.7.0/Python3.2
2015-02-06 17:02:36 - WebIOPi - DEBUG - Mapping GPIO.digitalCount to REST GET /GPIO/count
2015-02-06 17:02:36 - WebIOPi - DEBUG - Mapping GPIO.digitalRead to REST GET /GPIO/%(channel)d/value
2015-02-06 17:02:36 - WebIOPi - DEBUG - Mapping GPIO.digitalWrite to REST POST /GPIO/%(channel)d/value/%(value)d
2015-02-06 17:02:36 - WebIOPi - DEBUG - Mapping GPIO.getFunctionString to REST GET /GPIO/%(channel)d/function
2015-02-06 17:02:36 - WebIOPi - DEBUG - Mapping GPIO.getPulse to REST GET /GPIO/%(channel)d/pulse
2015-02-06 17:02:36 - WebIOPi - DEBUG - Mapping GPIO.outputSequence to REST POST /GPIO/%(channel)d/sequence/%(args)s
2015-02-06 17:02:36 - WebIOPi - DEBUG - Mapping GPIO.portRead to REST GET /GPIO/*/integer
2015-02-06 17:02:36 - WebIOPi - DEBUG - Mapping GPIO.portWrite to REST POST /GPIO/*/integer/%(value)d
2015-02-06 17:02:36 - WebIOPi - DEBUG - Mapping GPIO.pulse to REST POST /GPIO/%(channel)d/pulse/
2015-02-06 17:02:36 - WebIOPi - DEBUG - Mapping GPIO.pulseAngle to REST POST /GPIO/%(channel)d/pulseAngle/%(value)f
2015-02-06 17:02:36 - WebIOPi - DEBUG - Mapping GPIO.pulseRatio to REST POST /GPIO/%(channel)d/pulseRatio/%(value)f
2015-02-06 17:02:36 - WebIOPi - DEBUG - Mapping GPIO.setFunctionString to REST POST /GPIO/%(channel)d/function/%(value)s
2015-02-06 17:02:36 - WebIOPi - DEBUG - Mapping GPIO.wildcard to REST GET /GPIO/*
2015-02-06 17:02:36 - WebIOPi - INFO - GPIO - Native mapped to REST API /GPIO
2015-02-06 17:02:36 - WebIOPi - INFO - Loading configuration from /etc/webiopi/config
2015-02-06 17:02:36 - WebIOPi - ERROR - global name 'GPIO' is not defined
Traceback (most recent call last):
File "/usr/local/lib/python3.2/dist-packages/WebIOPi-0.7.0-py3.2-linux-armv7l.egg/webiopi/__main__.py", line 75, in <module>
main(sys.argv)
File "/usr/local/lib/python3.2/dist-packages/WebIOPi-0.7.0-py3.2-linux-armv7l.egg/webiopi/__main__.py", line 69, in main
server = Server(port=port, configfile=configfile, scriptfile=scriptfile)
File "/usr/local/lib/python3.2/dist-packages/WebIOPi-0.7.0-py3.2-linux-armv7l.egg/webiopi/server/__init__.py", line 52, in __init__
self.gpio.addSetups(config.items("GPIO"))
File "/usr/local/lib/python3.2/dist-packages/WebIOPi-0.7.0-py3.2-linux-armv7l.egg/webiopi/devices/digital/gpio.py", line 62, in addSetups
self.addGPIOSetup(gpio, params)
File "/usr/local/lib/python3.2/dist-packages/WebIOPi-0.7.0-py3.2-linux-armv7l.egg/webiopi/devices/digital/gpio.py", line 55, in addGPIOSetup
self.addGPIO(self.gpio_setup, gpio, params)
File "/usr/local/lib/python3.2/dist-packages/WebIOPi-0.7.0-py3.2-linux-armv7l.egg/webiopi/devices/digital/gpio.py", line 45, in addGPIO
func = GPIO.OUT
NameError: global name 'GPIO' is not defined

Please help!

User avatar
DougieLawson
Posts: 42771
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK

Re: Webiopi doesn't work on Raspberry Pi 2

Sat Feb 07, 2015 10:01 am

It's using Ben Croston's code to access the GPIO pins through memory mapping with /dev/mem.

If you look in the install package at ../WebIOPi-0.7.0/python/native/gpio.c you should be able to patch that code to work with the new base address for the RPI2. Hint: #define BCM2708_PERI_BASE 0x20000000 needs to change.
Languages using left-hand whitespace for syntax are ridiculous

DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.

The use of crystal balls and mind reading is prohibited.

User avatar
B.Goode
Posts: 15876
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Webiopi doesn't work on Raspberry Pi 2

Sat Feb 07, 2015 10:43 am

This thread might also be relevant. http://www.raspberrypi.org/forums/viewt ... 66#p686869

The author/maintainer of RPi.GPIO is Ben Croston [ @croston on these forums ], one of the contributors to that thread.
Beware of the Leopard

Jzhou187
Posts: 6
Joined: Fri Feb 06, 2015 10:47 pm

Re: Webiopi doesn't work on Raspberry Pi 2

Sat Feb 07, 2015 1:26 pm

DougieLawson wrote:It's using Ben Croston's code to access the GPIO pins through memory mapping with /dev/mem.

If you look in the install package at ../WebIOPi-0.7.0/python/native/gpio.c you should be able to patch that code to work with the new base address for the RPI2. Hint: #define BCM2708_PERI_BASE 0x20000000 needs to change.
Thank you for the Hint. Sorry I am a newbie could you tell me what should I change to?

User avatar
croston
Posts: 723
Joined: Sat Nov 26, 2011 12:33 pm
Location: Blackpool

Re: Webiopi doesn't work on Raspberry Pi 2

Sat Feb 07, 2015 1:32 pm

Compare gpio.c with:
https://sourceforge.net/p/raspberry-gpi ... format=raw
and apply the base address differences.

Jzhou187
Posts: 6
Joined: Fri Feb 06, 2015 10:47 pm

Re: Webiopi doesn't work on Raspberry Pi 2

Sat Feb 07, 2015 1:47 pm

croston wrote:Compare gpio.c with:
https://sourceforge.net/p/raspberry-gpi ... format=raw
and apply the base address differences.
the gpio.c from the link is a lot different than my one. Which part should I change? or should I just copy everything?

Thanks

User avatar
croston
Posts: 723
Joined: Sat Nov 26, 2011 12:33 pm
Location: Blackpool

Re: Webiopi doesn't work on Raspberry Pi 2

Sat Feb 07, 2015 1:54 pm

Looks like the setup() function and a couple of new #define lines at the top.

Jzhou187
Posts: 6
Joined: Fri Feb 06, 2015 10:47 pm

Re: Webiopi doesn't work on Raspberry Pi 2

Sat Feb 07, 2015 4:30 pm

croston wrote:Looks like the setup() function and a couple of new #define lines at the top.
sorry I still can't get it to work :(

AforAlex
Posts: 85
Joined: Thu May 31, 2012 7:56 pm

Re: Webiopi doesn't work on Raspberry Pi 2

Wed Feb 11, 2015 8:30 pm

Has anyone got this to work with the raspberry pi 2? And if so would you be willing to upload the files some place? Be got a lovely Web controlled big track with Web Cam that thanks to the increased power of the pi 2 is now drivable over the Web so keen to get working on pi 2, but uses webiopi which don't work :-(

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

Re: Webiopi doesn't work on Raspberry Pi 2

Wed Feb 11, 2015 10:30 pm

Why not contact the author of webiopi?
There is a Google groups support website. Gotta be quicker than going through this forum.
Texy
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

AforAlex
Posts: 85
Joined: Thu May 31, 2012 7:56 pm

Re: Webiopi doesn't work on Raspberry Pi 2

Thu Feb 12, 2015 3:02 pm

Cheers, will do, have posted on their Google groups forum jobbie.

Many thanks

konglingboy
Posts: 1
Joined: Tue Mar 17, 2015 8:28 am

Re: Webiopi doesn't work on Raspberry Pi 2

Tue Mar 17, 2015 8:35 am

1.python/native/cpuinfo.c,change "BCM2708" to "BCM2709";
2.python/native/gpio.c, change "#define BCM2708_PERI_BASE 0x20000000" to "#define BCM2708_PERI_BASE 0x3f000000";
3.run setup.sh again.

fatsel
Posts: 1
Joined: Wed Mar 25, 2015 1:26 pm

Re: Webiopi doesn't work on Raspberry Pi 2

Wed Mar 25, 2015 1:30 pm

Did anyone get webiopi to work with the pi2? Can you please help with the code?

User avatar
B.Goode
Posts: 15876
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Webiopi doesn't work on Raspberry Pi 2

Wed Mar 25, 2015 9:51 pm

fatsel wrote:Did anyone get webiopi to work with the pi2? Can you please help with the code?
@konglingboy, who posted the message preceding yours, appears to have done so and has posted clear details of the code changes needed.
Beware of the Leopard

digitize
Posts: 1
Joined: Tue Jun 23, 2015 3:08 am

Re: Webiopi doesn't work on Raspberry Pi 2

Tue Jun 23, 2015 3:13 am

@konglingboy, posted a simple solution above that worked for me. He is amazing. Thanks!

blavery
Posts: 95
Joined: Sun Jul 01, 2012 2:57 am
Location: QLD. Australia

Re: Webiopi doesn't work on Raspberry Pi 2

Thu Jun 25, 2015 12:26 pm

Disclaimer: I haven't tried @konglingboy's "fix" ...

But it looks to me like it might simply change WEBIOPI from RPI(1) specific to RPI2 specific.
So that would mean I can't take that SD card and move it from a RPI2 to a RPI(1) ???
I think I won't use WEBIOPI for the moment.

It's now getting a bit bleak regarding remote GPIO control with web display:
* RASPCTL - discontinued.
* RASPCONTROL - disappeared.
* NETIO - still there, with smartphone control. The simplistic socket server they offered long back for RPI I found too fragile, but I think they might have a stronger example server now. I should try it again. I did buy the app, still on my phone & tablet.
* INSTRUCTABLES.COM php-javascript DIY simple port controller (http://www.instructables.com/id/Simple- ... ur-Raspbe/) - yea that might be a sampler, but it still works.

Maybe I've missed something obvious.

trinity
Posts: 1
Joined: Fri Jul 24, 2015 8:36 am

Re: Webiopi doesn't work on Raspberry Pi 2

Fri Jul 24, 2015 8:41 am

You can use the patch from the following URL to get WebIOPi-0.7.1 up and running on pi-2 :D

https://github.com/doublebind/raspi

blavery
Posts: 95
Joined: Sun Jul 01, 2012 2:57 am
Location: QLD. Australia

Re: Webiopi doesn't work on Raspberry Pi 2

Sun Aug 02, 2015 9:54 am

Oh dear,
The doublebind patch (post above) works in some cases. It is almost identically a re-work of the patch at
https://github.com/acrobotic/Ai_Demos_R ... demos/gpio, which similarly works in some cases.

Take a look at the patch they both offer for board version detection (in file ...../python/native/cpuinfo.c):

Code: Select all

int get_rpi_revision(void)
{
   char revision[1024] = {'\0'};
   
   if (get_cpuinfo_revision(revision) == NULL)
      return -1;
      
   if ((strcmp(revision, "0002") == 0) ||
       (strcmp(revision, "1000002") == 0 ) ||
       (strcmp(revision, "0003") == 0) ||
       (strcmp(revision, "1000003") == 0 ))
      return 1;
   else if ((strcmp(revision, "0004") == 0) ||
            (strcmp(revision, "1000004") == 0 ) ||
            (strcmp(revision, "0005") == 0) ||
            (strcmp(revision, "1000005") == 0 ) ||
            (strcmp(revision, "0006") == 0) ||
            (strcmp(revision, "1000006") == 0 ))
      return 2;
   else if ((strcmp(revision, "a01041") == 0) ||
            (strcmp(revision, "a21041") == 0 ))
      return 3;
   else // assume rev 4
      return 4;
}
Well guess what? My 4 RPi boards have revision numbers 0002, 000e, 000f, a21041. The middle 2 numbers are not recognised by the patched code above.


http://elinux.org/RPi_HardwareHistory indicates many more board versions. Maybe even that wiki listing is not up to date? But can I offer the following roughed-up code for the board revision function, code that is at least in closer accord with the wiki.

Code: Select all

int get_rpi_revision(void)
{
   char revision[1024] = {'\0'};
   
   if (get_cpuinfo_revision(revision) == NULL)
      return -1;
      
   if ((strcmp(revision, "0002") == 0) ||
       (strcmp(revision, "1000002") == 0 ) ||
       (strcmp(revision, "0003") == 0) ||
       (strcmp(revision, "1000003") == 0 ))
      return 1;
   else if ((strcmp(revision, "a01041") == 0) ||
            (strcmp(revision, "a21041") == 0 ) ||
            (strcmp(revision, "0012") == 0 ) ||
            (strcmp(revision, "0013") == 0 ))
      return 3;  // A+  B+  RPI2
   else 
      return 2; // all the 0004 - 000f
}
Are we seeing a sad fade-away on a useful project? I can't even think about the ambitions of WebIOPi re Weaved or REST etc, if the core functionality remains unsupported and broken.

blavery
Posts: 95
Joined: Sun Jul 01, 2012 2:57 am
Location: QLD. Australia

Re: Webiopi doesn't work on Raspberry Pi 2

Sun Sep 06, 2015 1:46 am

And for anyone who wants, here is my own patched up 0.7.1 -- not official, not guaranteed -- that I have used for a local hobby class. It builds on those other sources/ideas above.

http://brian2012class.nfshost.com/where-are-we/ Check under entry for 15 August. It identifies as 0.7.1.p
All of my class used it successfully on a variety of Pi versions.

vlatkojordanov
Posts: 2
Joined: Wed Dec 02, 2015 1:36 pm

Re: Webiopi doesn't work on Raspberry Pi 2

Wed Jan 06, 2016 7:07 pm

blavery wrote:And for anyone who wants, here is my own patched up 0.7.1 -- not official, not guaranteed -- that I have used for a local hobby class. It builds on those other sources/ideas above.

http://brian2012class.nfshost.com/where-are-we/ Check under entry for 15 August. It identifies as 0.7.1.p
All of my class used it successfully on a variety of Pi versions.

Hello blavery,

So what happened with the link it seems dead ? Or I am having trouble opening it I am not sure, anyway guys, any idea if there is any similar web interface like this one which is working on the pi2+ ?

danjperron
Posts: 4504
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: Webiopi doesn't work on Raspberry Pi 2

Wed Jan 06, 2016 8:22 pm

Code: Select all

cd
wget http://sourceforge.net/projects/webiopi/files/WebIOPi-0.7.1.tar.gz
tar -zxvf WebIOPi-0.7.1.tar.gz
The patch for Pi2

Code: Select all

cd
git clone https://github.com/acrobotic/Ai_Demos_RPi
cd WebIOPi-0.7.1
patch -p0 -i ~/Ai_Demos_RPi/demos/gpio/webiopi_raspberry_pi_2_cpu_support.patch 
patch -p0 -i ~/Ai_Demos_RPi/demos/gpio/webiopi_raspberry_pi_2_gpio_40_pin.patch 
patch -p0 -i ~/Ai_Demos_RPi/demos/gpio/webiopi_raspberry_pi_2_gpio_mapping.patch 
The installation

Code: Select all

cd
cd WebIOPi-0.7.1
sudo ./setup.sh
Enable webiopi on systemd

Code: Select all

sudo systemctl enable webiopi.service
sudo systemctl start webiopi.service

blavery
Posts: 95
Joined: Sun Jul 01, 2012 2:57 am
Location: QLD. Australia

Re: Webiopi doesn't work on Raspberry Pi 2

Wed Jan 06, 2016 10:28 pm

Ahh, Sorry, That stuff got archived. You can still see it here:

http://www.blavery.com/BotSoftware-RPI/ ... index.html

Check for 15 August entry.
Brian

Netmonster
Posts: 1
Joined: Sat Jan 30, 2016 10:24 pm

Re: Webiopi doesn't work on Raspberry Pi 2

Sat Jan 30, 2016 10:27 pm

danjperron solution worked for me. :D

elektroivo
Posts: 1
Joined: Wed Feb 10, 2016 6:42 am

Re: Webiopi doesn't work on Raspberry Pi 2

Wed Feb 10, 2016 7:20 am

Hello from Croatia...

First, I must point out that I'm new to programming and RPi
I'm having problems with Webiopi custom web pages on RPi2 model B.
When i'm using default demo web page, everything is working OK.

If I try to use custom web page (for example, I tried to use this http://webiopi.trouch.com/JAVASCRIPT.html ), all buttons are gray and not functioning. I've verified that with demo page all buttons are fully functional.

I've done all patches available thru this forum, and tried with simple python script ( http://raspi.tv/2013/how-to-use-interru ... d-rpi-gpio ) whitch works as expected.

Can someone at least point me in right direction where to look?

Luke.H
Posts: 2
Joined: Fri Jan 15, 2016 12:28 pm

Re: Webiopi doesn't work on Raspberry Pi 2

Tue Feb 23, 2016 10:15 am

When attempting to access the webiopi portal via HTTP, it accepts my username/password, but gives me a completely blank page. When I go into https://ubuntu:8000/app/gpio-header I get this error:

Code: Select all

HTTP/1.0 500 Internal Server Error Server: WebIOPi/0.7.1/Python3.4 Date: Tue, 23 Feb 2016 10:10:55 GMT Content-Type: text/html;charset=utf-8 Connection: close Content-Length: 458
Error response

Error code: 500

Message: Internal Server Error.

Error code explan
Any idea what this could be?

Thanks for the help

Return to “General discussion”