Issue #052 [Fixed/closed] - Macros not mapped when using -s command switch

Posted by nekobox999

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)


@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 https://(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.

Comment 1

Posted by sebastien.ivanez69

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


good luck anyways!!

Comment 2

Posted by nekobox999

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 .

Comment 3

Posted by nekobox999

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.!topic/webiopi/VlLMEtntyZs

Comment 4

Posted by trouch

Definitely a bug with the -s command switch.

Comment 5

Posted by easydog83

atleast foe you a 404 but for me socker error 98

Comment 6

Posted by trouch

Comment 7

Posted by trouch

Comment 8

Posted by trouch

This issue was closed by revision r1415.

Comment 9

Posted by npradeep465

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 https://raspberrypi:8000/macros/setLightHours/12,15 [HTTP/1.0 404 setLightHours Not Found 21ms]

check following link for code\_Macros

please help me