Vin0 / webiopi

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

Can't run basis tutorial #93

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Exactly like here https://code.google.com/p/webiopi/wiki/Tutorial_Basis
2.
3.
...

WebIOPi version used?
=>WebIOPi-0.7.0

Python version used?
=>python3.2

Distro used? (WebIOPi has only been tested on Raspbian Wheezy)
=>Raspbian Whezzey January 2014

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

For Javascript side bugs, Browser?
=>Chrome

Please provide any additional information below.

When I run sudo webiopi -d -c /etc/webiopi/config I get this

pi@raspberrypi ~ $ sudo webiopi -d -c /etc/webiopi/config
2014-04-05 07:25:43 - WebIOPi - INFO - Starting WebIOPi/0.7.0/Python3.2
2014-04-05 07:25:43 - WebIOPi - DEBUG - Mapping GPIO.digitalCount to REST GET 
/G                                             PIO/count
2014-04-05 07:25:43 - WebIOPi - DEBUG - Mapping GPIO.digitalRead to REST GET 
/GP                                             IO/%(channel)d/value
2014-04-05 07:25:43 - WebIOPi - DEBUG - Mapping GPIO.digitalWrite to REST POST 
/                                             GPIO/%(channel)d/value/%(value)d
2014-04-05 07:25:43 - WebIOPi - DEBUG - Mapping GPIO.getFunctionString to REST 
G                                             ET /GPIO/%(channel)d/function
2014-04-05 07:25:43 - WebIOPi - DEBUG - Mapping GPIO.getPulse to REST GET 
/GPIO/                                             %(channel)d/pulse
2014-04-05 07:25:43 - WebIOPi - DEBUG - Mapping GPIO.outputSequence to REST 
POST                                              
/GPIO/%(channel)d/sequence/%(args)s
2014-04-05 07:25:43 - WebIOPi - DEBUG - Mapping GPIO.portRead to REST GET 
/GPIO/                                             */integer
2014-04-05 07:25:43 - WebIOPi - DEBUG - Mapping GPIO.portWrite to REST POST 
/GPI                                             O/*/integer/%(value)d
2014-04-05 07:25:43 - WebIOPi - DEBUG - Mapping GPIO.pulse to REST POST 
/GPIO/%(                                             channel)d/pulse/
2014-04-05 07:25:43 - WebIOPi - DEBUG - Mapping GPIO.pulseAngle to REST POST 
/GP                                             
IO/%(channel)d/pulseAngle/%(value)f
2014-04-05 07:25:43 - WebIOPi - DEBUG - Mapping GPIO.pulseRatio to REST POST 
/GP                                             
IO/%(channel)d/pulseRatio/%(value)f
2014-04-05 07:25:43 - WebIOPi - DEBUG - Mapping GPIO.setFunctionString to REST 
P                                             OST 
/GPIO/%(channel)d/function/%(value)s
2014-04-05 07:25:43 - WebIOPi - DEBUG - Mapping GPIO.wildcard to REST GET 
/GPIO/                                             *
2014-04-05 07:25:43 - WebIOPi - INFO - GPIO - Native mapped to REST API /GPIO
2014-04-05 07:25:43 - WebIOPi - INFO - Loading configuration from 
/etc/webiopi/c                                             onfig
2014-04-05 07:25:43 - WebIOPi - INFO - Loading myproject from 
/home/pi/myproject                                             /python/script.py
2014-04-05 07:25:43 - WebIOPi - ERROR - invalid character in identifier 
(script.                                             py, line 14)
Traceback (most recent call last):
  File "/usr/local/lib/python3.2/dist-packages/WebIOPi-0.7.0-py3.2-linux-armv6l.                                             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-armv6l.                                             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-armv6l.                                             egg/webiopi/server/__init__.py", line 75, in __init__
    loader.loadScript(name, source, self.restHandler)
  File "/usr/local/lib/python3.2/dist-packages/WebIOPi-0.7.0-py3.2-linux-armv6l.                                             egg/webiopi/utils/loader.py", line 8, in loadScript
    script = imp.load_source(name, source)
  File "/home/pi/myproject/python/script.py", line 14
    GPIO.setFunction(LIGHT, GPIO.OUT)
   ^
SyntaxError: invalid character in identifier

The config file is like this
[GPIO]
# Initialize following GPIOs with given function and optional value
# This is used during WebIOPi start process
#21 = IN
#23 = OUT 0
#24 = OUT 0
#25 = OUT 1

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

[~GPIO]
# Reset following GPIOs with given function and optional value
# This is used at the end of WebIOPi stop process
#21 = IN
#23 = IN
#24 = IN
#25 = OUT 0

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

[SCRIPTS]
# Load custom scripts syntax :
# name = sourcefile
#   each sourcefile may have setup, loop and destroy functions and macros
#myscript = /home/pi/webiopi/examples/scripts/macros/script.py
myproject = /home/pi/myproject/python/script.py

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

[HTTP]
# HTTP Server configuration
enabled = true
port = 8000

# File containing sha256(base64("user:password"))
# Use webiopi-passwd command to generate it
passwd-file = /etc/webiopi/passwd

# Change login prompt message
prompt = "WebIOPi"

# Use doc-root to change default HTML and resource files location
#doc-root = /home/pi/webiopi/examples/scripts/macros
doc-root = /home/pi/myproject/html

# Use welcome-file to change the default "Welcome" file
#welcome-file = index.html

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

[COAP]
# CoAP Server configuration
enabled = true
port = 5683
# Enable CoAP multicast
multicast = true

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

[DEVICES]
# Device configuration syntax:
# name = device [args...]
#   name   : used in the URL mapping
#   device : device name
#   args   : (optional) see device driver doc
# If enabled, devices configured here are mapped on REST API /device/name
# Devices are also accessible in custom scripts using deviceInstance(name)
# See device driver doc for methods and URI scheme available

# Raspberry native UART on GPIO, uncomment to enable
# Don't forget to remove console on ttyAMA0 in /boot/cmdline.txt
# And also disable getty on ttyAMA0 in /etc/inittab
#serial0 = Serial device:ttyAMA0 baudrate:9600

# USB serial adapters
#usb0 = Serial device:ttyUSB0 baudrate:9600
#usb1 = Serial device:ttyACM0 baudrate:9600

#temp0 = TMP102
#temp1 = TMP102 slave:0x49
#temp2 = DS18B20
#temp3 = DS18B20 slave:28-0000049bc218

#bmp = BMP085

#gpio0 = PCF8574
#gpio1 = PCF8574 slave:0x21

#light0 = TSL2561T
#light1 = TSL2561T slave:0b0101001

#gpio0 = MCP23017
#gpio1 = MCP23017 slave:0x21
#gpio2 = MCP23017 slave:0x22

#pwm0 = PCA9685
#pwm1 = PCA9685 slave:0x41

#adc0 = MCP3008
#adc1 = MCP3008 chip:1 vref:5
#dac1 = MCP4922 chip:1

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

[REST]
# By default, REST API allows to GET/POST on all GPIOs
# Use gpio-export to limit GPIO available through REST API
#gpio-export = 21, 23, 24, 25
gpio-export = 21

# Uncomment to forbid changing GPIO values
#gpio-post-value = false
gpio-post-value = true

# Uncomment to forbid changing GPIO functions
#gpio-post-function = false
gpio-post-function = false
# Uncomment to disable automatic device mapping
#device-mapping = false

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

[ROUTES]
# Custom REST API route syntax :
# source = destination
#   source      : URL to route
#   destination : Resulting URL
# Adding routes allows to simplify access with Human comprehensive URLs

# In the next example with have the bedroom light connected to GPIO 25
# and a temperature sensor named temp2, defined in [DEVICES] section
#  - GET  /bedroom/light       => GET  /GPIO/25/value, returns the light state
#  - POST /bedroom/light/0     => POST /GPIO/25/value/0, turn off the light
#  - POST /bedroom/light/1         => POST /GPIO/25/value/1, turn on the light
#  - GET  /bedroom/temperature => GET  /devices/temp2/temperature/c, returns 
the temperature in celsius
#/bedroom/light = /GPIO/25/value
#/bedroom/temperature = /devices/temp2/temperature/c

#/livingroom/light = /devices/expander0/0
#/livingroom/brightness = /devices/adc/0/float
#/livingroom/temperature = /devices/temp0/temperature/c

#/weather/temperature = /devices/bmp/temperature/c
#/weather/pressure = /devices/bmp/pressure/hpa

Original issue reported on code.google.com by stancu....@gmail.com on 5 Apr 2014 at 7:30

GoogleCodeExporter commented 9 years ago
Same problem ! Anybody can help ?

Original comment by the...@gmail.com on 9 May 2014 at 10:16

GoogleCodeExporter commented 9 years ago
If anyone runs into this issue it appears there are some illegal characters 
that in the file if you cut and paste right from the web page. I just went 
through and at the beginning of each line deleted any spaces and then just hit 
the tab key until the line was back to its original position. Worked for me and 
I was seeing exactly the same issue as the first post.

Original comment by earthnb...@gmail.com on 23 Aug 2014 at 12:28