Issue #074 [Accepted/open] - GPIO Expander Port Write REST Error

Posted by trouch

$ curl -X POST https://pi:8000/devices/mcp/\*/integer/129

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


Comment 1

Posted by trouch

delayed for major release - need new function mapping or REST handler refactor.


Comment 2

Posted by andreas.riegg

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