nicolaiev / webiopi

Automatically exported from code.google.com/p/webiopi
0 stars 0 forks source link

Macros not mapped when using -s command switch #52

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. when calling a macro from javascript with clicking a button , then webiopi 
returns 404
2.
3.
...

WebIOPi version used?
=>0.6.0

Python version used?
=>3.2.3

Distro used? (WebIOPi has only been tested on Raspbian Wheezy)
=>2013-02-09-wheezy-raspbian

Raspberry Pi board revision? (1 or 2)
=>2

For Javascript side bugs, Browser?
=>firefox windows7(64)

Please provide any additional information below.

***********  python program  **************

import webiopi
import time
webiopi.setDebug()
GPIO = webiopi.GPIO
L1 = 4
L3 = 18

# default function
def setup():
    GPIO.setFunction(L1, GPIO.OUT)
    GPIO.setFunction(L3, GPIO.OUT)

def loop():
    l3v = not GPIO.digitalRead(L3)
    GPIO.digitalWrite(L3,l3v)
    webiopi.sleep(2)

def destroy():
    GPIO.setFunction(L1,GPIO.IN)
    GPIO.setFunction(L3,GPIO.IN)

# macros
@webiopi.macro
def led1_lit():
    GPIO.digitalWrite(L1,GPIO.HIGH)
    webiopi.debug("click1.")

*************  html and javascript  *************

<html>
<head>
  <title>witest</title>
  <script type="text/javascript" src="/webiopi.js"></script>
  <script type="text/javascript">
  function init() {
      var btn0,ct0;
      ct0 = $("#box");
      btn0 = webiopi().createButton("led1","L1",click_led1);
      ct0.append(btn0);
  }
  function click_led1() {
      webiopi().callMacro("led1_lit");
  }
  webiopi().ready(init);
  </script>
</head>
<body>
  <div id="box" align="center"> </div>
</body>
<html>

******************************************

i made a very simple program and html
to try calling a macro like that.

i start webiopi with 
$ sudo webiopi -w (script name).py
then webiopi starts service
and LED on GPIO-18 starts blinking.

but webiopi outputs
HTTP - DEBUG - "POST /macros/led1_lit/ HTTP/1.1" 404 -
on console screen when i clicked "L1" button.

i think "@webiopi.macro" does not work on my python script.

by the way, if i access at
http://(Raspberry Pi address):8000/*
then browser displays JSON message normally.

and "@webiopi.macro" has no trouble on webiopi-0.5.3 .

i have no idea why @webiopi.macro is invalid
on may python script.

may i have any help for it,please ?

thank you.

Original issue reported on code.google.com by nekobox...@gmail.com on 26 May 2013 at 7:29

GoogleCodeExporter commented 8 years ago
Hi I can't really help you but what if you try to add in your .py file:

server.addMacro(led1_lit)    

good luck anyways!!

Original comment by sebastie...@gmail.com on 5 Jun 2013 at 1:55

GoogleCodeExporter commented 8 years ago
Thank you for your information.
I tried "server.addMacro" function ,but it might be for 0.5.3 or before.

I have not found any way with both debug-mode and 0.6.0 .

I'm looking forward it is going to be fixed till version1.0 .

Original comment by nekobox...@gmail.com on 6 Jun 2013 at 6:16

GoogleCodeExporter commented 8 years ago
In conclusion, my macros in my python script worked fine with not only "-s (my 
script).py" option but also "-c /etc/webiopi/config" option.
I had thought that "-c" option was not needed when using macros.

Because "setup()","loop()","destroy()" functions worked fine when I started 
webiopi with only "sudo webiopi -s (my script).py".
So I don't doubt that all python functions are valid with "-s" option ,and 
accessing to macro functions ,too.

I found that "-c" option is needed when using any macros and/or devices.

I can't understand why "normal functions are ok ,but macro functions are not 
ok" yet.
(Both functions are in the same program ,and macros worked without any option 
with version 0.5.3!)

But anyway ,I have found how to work my macros.

https://groups.google.com/forum/?fromgroups#!topic/webiopi/VlLMEtntyZs

Original comment by nekobox...@gmail.com on 19 Jun 2013 at 2:31

GoogleCodeExporter commented 8 years ago
Definitely a bug with the -s command switch.

Original comment by tro...@trouch.com on 27 Nov 2013 at 9:30

GoogleCodeExporter commented 8 years ago
atleast foe you a 404 but for me socker error 98

Original comment by easydo...@gmail.com on 23 Dec 2013 at 4:38

GoogleCodeExporter commented 8 years ago

Original comment by tro...@trouch.com on 4 Jan 2014 at 9:00

GoogleCodeExporter commented 8 years ago

Original comment by tro...@trouch.com on 4 Jan 2014 at 9:01

GoogleCodeExporter commented 8 years ago
This issue was closed by revision r1415.

Original comment by tro...@trouch.com on 31 Jan 2014 at 12:12

GoogleCodeExporter commented 8 years ago
i have a problem when calling macro from javascript.
404 returned from webiopi server
when calling a macro with POST method.

in console showing following error : POST 
http://raspberrypi:8000/macros/setLightHours/12,15 [HTTP/1.0 404 setLightHours 
Not Found 21ms]

check following link for code
https://code.google.com/p/webiopi/wiki/Tutorial_Macros 

please help me

Original comment by npradeep...@gmail.com on 13 Feb 2015 at 4:27