roadlabs / webiopi

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

GPIO Expander Port Write REST Error #74

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
$ curl -X POST http://pi:8000/devices/mcp/*/integer/129

==> invalid literal for int() with base 10: '*'.

Original issue reported on code.google.com by tro...@trouch.com on 12 Jan 2014 at 12:21

GoogleCodeExporter commented 9 years ago
delayed for major release - need new function mapping or REST handler refactor.

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

GoogleCodeExporter commented 9 years ago
If anyone really needs portWrite() on digital devices, here is a small 
workaround that I use. Put the following code snippet into a custom server 
script:

#----------------------

import webiopi

@webiopi.macro
def mPortWrite(digitalDeviceName, value):
    digitalDevice = webiopi.deviceInstance(digitalDeviceName)
    if digitalDevice != None:
        return digitalDevice.portWrite(int(value))

#----------------------

It defines a macro that calls portWrite() for a digital device. The first 
parameter is the name of the digital device, the second one is the interger 
value to wite. This macro works only for digital devices, using names of other 
ones will cause an error.

REST path would be (using your example above):

..../macros/mPortWrite/mcp,129

Don't forget to include the script into your config file with the correct path 
to it.

Andreas

Original comment by andreas....@googlemail.com on 30 Apr 2014 at 12:54