[メモ] WebIOPiのRaspberryPi2 簡単対応 (GPIO Header 40pin)


[Raspberry Pi Advent Calendar 2015](http://qiita.com/advent-calendar/2015/raspberrypi) 12月10日 tapun_nikkiさんの記事をたまたま見かけて、トライしてみました。

> Raspberry Pi |【失敗記事】スマホからGPIOを制御してみたい！（WebIOPi）
http://www.tapun.net/raspi/raspberry-pi-webiopi-guide-failed

***
- 修正をどうすすめていったか、を追記しました。
- メモ: `RPi.GPIO` [(python.org)](https://pypi.python.org/pypi/RPi.GPIO)と [(sourceforge)](http://sourceforge.net/projects/raspberry-gpio-python/) - 
http://sourceforge.net/p/raspberry-gpio-python/code/ci/default/tree/source/c_gpio.c
- [追記:2016/7/13] Raspberry Pi 3 Model Bで、動作したとのことです。(@toatsushiさん、[報告](http://qiita.com/mt08/items/5e14e42e817ba3c2ac43#comment-ebcbdd0f882c9aaa431f)、ありがとうございました)


## 修正箇所

### GPIO基本動作
軽く見たところ、修正箇所は2箇所

- 1. RaspberryPiで実行されているかのチェック ("BCM2708"から、"BCM2709"へ変更)

```c:WebIOPi-0.7.1/python/native/cpuinfo.c__40行目
        if (strcmp(hardware, "BCM2709") == 0)
```

- 2. GPIOの処理 (ペリフェラルのベースアドレスを0x20000000から、0x3F000000へ変更)
 
```c:WebIOPi-0.7.1/python/native/gpio.c__32行目
  #define BCM2708_PERI_BASE   0x3F000000
```

### GPIO Header(/app/gpio-header)の40pin対応

- 1. SoCのGPIOピン番号と、らずぱい基盤のピン番号のマッピング
<br>`/proc/cpuinfo`から、ボードのリビジョンを調べてるらしいが、[2]が使われてるので、こっちのみ変更。

```py:WebIOPi-0.7.1/python/webiopi/utils/version.py
_MAPPING[2] = ["V33", "V50", 2, "V50", 3, "GND", 4, 14, "GND", 15, 17, 18, 27, "GND", 22, 23, "V33", 24, 10, "GND", 9, 25, 11, 8, "GND", 7, 0, 1, 5, "GND", 6, 12, 13, "GND", 19, 16, 26, 20, "GND", 21]
```

- 2. 26 -> 40ピンのテーブル作成

```js:WebIOPi-0.7.1/htdocs/webiopi.js__76行目と580行目
...
          this.PINS = Array(41);
...
          for (var pin=1; pin<=40; pin++) {
...
``` 


## 動作確認
1. GPIO21(3番ピン)を、OUTにして、H/Lをテスタで。<br>
![WebIOPi_RasPi2-1.png](https://qiita-image-store.s3.amazonaws.com/0/75594/2ec2d152-a8ea-b304-ee16-72f3070b638a.png)
2. GPIO21(40番ピン)を、OUTにして、H/Lをテスタで。<br>
![WebIOPi_RasPi2-2.png](https://qiita-image-store.s3.amazonaws.com/0/75594/fe2317f9-3f85-08f4-9d3f-5a6b126c0e65.png)

## 修正をどうすすめていったか
### 修正手順

1. 不具合/修正内容の確認
2. 何が起きているか、想像する
3. コード見る、ググる、直す(壊す?)、試す
4. 2-3を繰りかえす。
5. 手順の整理(と報告)

### 1. 不具合/修正内容の確認
- a) らずぱい１で動いてるのに、らずぱい２だと動かない.
- b) WebUIの GPIO Headerを26から40ピンにしたい.

### 2 何が起きているか、想像する
- a) らずぱい1と2の違い?=>ハードウェアの変更あり? => OS経由じゃなくて、HWを直接たたいてる部分があるんじゃない？？
- b) htmlとか、jsとかでごにょごにょしてる... それ以上こまかいことは想像できない.. コードをみてから考える。

### 3 コード見る、ググる、直す(壊す?)、試す
#### a)　らずぱい１=> らずぱい２でのHW, GPIOの対応
- 1. とりあえず、ググる。 キーワード: `raspberry pi 2 GPIO ハードウェア変更`
  - [*"Raspberry Pi メモ (42) Raspberry Pi2 の非互換性"*](http://www.mztn.org/rpi/rpi42.html)<br>
"非互換性"!?... ごくり。

 > *Raspberry Pi B+ までの Peripherals Base Address は 0x20000000 でしたが、Raspberry Pi2 B では 0x3F000000 に変更されています。*

- 2. とりあえず、20000000でgrep。

```shell-session
pi@rasp4 ~/dev/WebIOPi-0.7.1 $ grep 20000000 *
grep: doc: Is a directory
grep: examples: Is a directory
grep: htdocs: Is a directory
grep: java: Is a directory
grep: midori: Is a directory
grep: python: Is a directory
grep: tutorials: Is a directory
pi@rasp4 ~/dev/WebIOPi-0.7.1 $ grep 20000000 */*
grep: examples/clients: Is a directory
grep: examples/magpi-cambot: Is a directory
grep: examples/scripts: Is a directory
grep: htdocs/app: Is a directory
grep: java/client: Is a directory
grep: python/native: Is a directory
grep: python/webiopi: Is a directory
grep: tutorials/1.basis: Is a directory
grep: tutorials/2.macros: Is a directory
grep: tutorials/3.devices: Is a directory
grep: tutorials/4.serial-streaming: Is a directory
grep: tutorials/5.serial-command: Is a directory
pi@rasp4 ~/dev/WebIOPi-0.7.1 $ grep 20000000 */*/*
grep: examples/scripts/basic: Is a directory
grep: examples/scripts/blink: Is a directory
grep: examples/scripts/macros: Is a directory
grep: examples/scripts/simple: Is a directory
grep: htdocs/app/devices-monitor: Is a directory
grep: htdocs/app/gpio-header: Is a directory
grep: htdocs/app/gpio-list: Is a directory
grep: htdocs/app/serial-monitor: Is a directory
grep: java/client/src: Is a directory
python/native/gpio.c:#define BCM2708_PERI_BASE   0x20000000
grep: python/webiopi/clients: Is a directory
grep: python/webiopi/decorators: Is a directory
grep: python/webiopi/devices: Is a directory
grep: python/webiopi/protocols: Is a directory
grep: python/webiopi/server: Is a directory
grep: python/webiopi/utils: Is a directory
```
- 3 `python/native/gpio.c:#define BCM2708_PERI_BASE   0x20000000` 
ここを `0x3F000000` に変えれば、うごくんじゃね？
`$ ./setup.sh skip-apt`
  - => 結果は、、、、これだけでは動きません。むむむ

- 4 コマンドライン起動ができるっぽいので　`$ sudo webiopi -d` で起動して、テストしてみて、デバッグ情報を見てみる。
WindowsのFirefoxから、`http://rpi_ip_address:8000/` にアクセス、ここまでは、OK.
で、`GPIO Header`をクリックしてすすむと.. Exception？!
> `global name 'GPIO' is not defined`


```
...
2015-12-18 11:11:12 - HTTP - DEBUG - "GET /app/gpio-header HTTP/1.1" - 200 OK (Client: 10.10.1.113 <Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:43.0) Gecko/20100101 Firefox/43.0>)
2015-12-18 11:11:13 - HTTP - DEBUG - "GET /webiopi.js HTTP/1.1" - 200 OK (Client: 10.10.1.113 <Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:43.0) Gecko/20100101 Firefox/43.0>)
2015-12-18 11:11:13 - HTTP - DEBUG - "GET /jquery.js HTTP/1.1" - 200 OK (Client: 10.10.1.113 <Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:43.0) Gecko/20100101 Firefox/43.0>)
2015-12-18 11:11:13 - HTTP - DEBUG - "GET /webiopi.css HTTP/1.1" - 200 OK (Client: 10.10.1.113 <Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:43.0) Gecko/20100101 Firefox/43.0>)
2015-12-18 11:11:13 - HTTP - DEBUG - "GET /map HTTP/1.1" - 200 OK (Client: 10.10.1.113 <Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:43.0) Gecko/20100101 Firefox/43.0>)
----------------------------------------
Exception happened during processing of request from ('10.10.1.113', 50120)
Traceback (most recent call last):
  File "/usr/local/lib/python3.2/dist-packages/WebIOPi-0.7.1-py3.2-linux-armv7l.egg/webiopi/protocols/http.py", line 238, in processRequest
    result = self.server.handler.do_GET(relativePath, compact)
  File "/usr/local/lib/python3.2/dist-packages/WebIOPi-0.7.1-py3.2-linux-armv7l.egg/webiopi/protocols/rest.py", line 147, in do_GET
    return (200, self.getJSON(compact), M_JSON)
  File "/usr/local/lib/python3.2/dist-packages/WebIOPi-0.7.1-py3.2-linux-armv7l.egg/webiopi/protocols/rest.py", line 245, in getJSON
    gpios[gpio][f] = GPIO.getFunctionString(gpio)
NameError: global name 'GPIO' is not defined

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.2/socketserver.py", line 295, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/usr/lib/python3.2/socketserver.py", line 321, in process_request
    self.finish_request(request, client_address)
  File "/usr/lib/python3.2/socketserver.py", line 334, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python3.2/socketserver.py", line 648, in __init__
    self.handle()
  File "/usr/lib/python3.2/http/server.py", line 396, in handle
    self.handle_one_request()
  File "/usr/lib/python3.2/http/server.py", line 384, in handle_one_request
    method()
  File "/usr/local/lib/python3.2/dist-packages/WebIOPi-0.7.1-py3.2-linux-armv7l.egg/webiopi/protocols/http.py", line 267, in do_GET
    self.processRequest()
  File "/usr/local/lib/python3.2/dist-packages/WebIOPi-0.7.1-py3.2-linux-armv7l.egg/webiopi/protocols/http.py", line 258, in processRequest
    except (GPIO.InvalidDirectionException, GPIO.InvalidChannelException, GPIO.SetupException) as e:
NameError: global name 'GPIO' is not defined
----------------------------------------
2015-12-18 11:11:13 - HTTP - DEBUG - "GET /version HTTP/1.1" - 200 OK (Client: 10.10.1.113 <Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:43.0) Gecko/20100101 Firefox/43.0>)
----------------------------------------
Exception happened during processing of request from ('10.10.1.113', 50122)
Traceback (most recent call last):
  File "/usr/local/lib/python3.2/dist-packages/WebIOPi-0.7.1-py3.2-linux-armv7l.egg/webiopi/protocols/http.py", line 238, in processRequest
    result = self.server.handler.do_GET(relativePath, compact)
  File "/usr/local/lib/python3.2/dist-packages/WebIOPi-0.7.1-py3.2-linux-armv7l.egg/webiopi/protocols/rest.py", line 147, in do_GET
    return (200, self.getJSON(compact), M_JSON)
  File "/usr/local/lib/python3.2/dist-packages/WebIOPi-0.7.1-py3.2-linux-armv7l.egg/webiopi/protocols/rest.py", line 245, in getJSON
    gpios[gpio][f] = GPIO.getFunctionString(gpio)
NameError: global name 'GPIO' is not defined
...
...
繰り返し
```
- 5 `GPIO`が定義されていないと`webiopi/protocols/rest.py`がいっている.
=> `GPIO`を `grep`。

```
pi@atrasp4:~/dev/WebIOPi-0.7.1$ find . | grep rest.py
./python/webiopi/decorators/rest.py
./python/webiopi/protocols/rest.py
./python/build/lib.linux-armv7l-3.2/webiopi/decorators/rest.py
./python/build/lib.linux-armv7l-3.2/webiopi/protocols/rest.py
./python/build/lib.linux-armv7l-2.7/webiopi/decorators/rest.py
./python/build/lib.linux-armv7l-2.7/webiopi/protocols/rest.py
pi@atrasp4:~/dev/WebIOPi-0.7.1$ grep -n GPIO ./python/webiopi/protocols/rest.py
24:    import _webiopi.GPIO as GPIO
164:        # Single GPIO getter
165:        elif relativePath.startswith("GPIO/"):
183:        if relativePath.startswith("GPIO/"):
238:            export = range(GPIO.GPIO_COUNT)
243:                gpios[gpio][f] = GPIO.getFunction(gpio)
245:                gpios[gpio][f] = GPIO.getFunctionString(gpio)
246:            gpios[gpio][v] = int(GPIO.input(gpio))
248:            if GPIO.getFunction(gpio) == GPIO.PWM:
249:                (pwmType, value) = GPIO.getPulse(gpio).split(':')
252:        json['GPIO'] = gpios
pi@atrasp4:~/dev/WebIOPi-0.7.1$
```
- `import _webiopi.GPIO as GPIO` というかたちでimportしている。<br>
=> その周辺を見てみる
- `pi@atrasp4:~/dev/WebIOPi-0.7.1$ cat -n python/webiopi/protocols/rest.py | less` 
で、`_webiopi.GPIO`を検索。`/_webiopi.GPIO[Enter]`

```py
    23  try:
    24      import _webiopi.GPIO as GPIO
    25  except:
    26      pass
```
=> importをtryして、失敗しても、スルー？ってことか？　`import _webiopi.GPIO`が失敗する場合もある？

- `_webiopi.GPIO`でgrep.

```
pi@atrasp4:~/dev/WebIOPi-0.7.1/python$ grep -n _webiopi.GPIO *
grep: build: Is a directory
grep: dist: Is a directory
grep: native: Is a directory
setup.py:36:      ext_modules      = [Extension('_webiopi.GPIO', ['native/bridge.c', 'native/gpio.c', 'native/cpuinfo.c'])],
grep: webiopi: Is a directory
grep: WebIOPi.egg-info: Is a directory
pi@atrasp4:~/dev/WebIOPi-0.7.1/python$ grep -n _webiopi.GPIO */*
grep: build/bdist.linux-armv7l: Is a directory
grep: build/lib.linux-armv7l-2.7: Is a directory
grep: build/lib.linux-armv7l-3.2: Is a directory
grep: build/temp.linux-armv7l-2.7: Is a directory
grep: build/temp.linux-armv7l-3.2: Is a directory
Binary file dist/WebIOPi-0.7.1-py2.7-linux-armv7l.egg matches
Binary file dist/WebIOPi-0.7.1-py3.2-linux-armv7l.egg matches
native/bridge.c:607:    "_webiopi.GPIO", /* name of module */
native/bridge.c:628:    if ((module = Py_InitModule("_webiopi.GPIO", python_methods)) == NULL)
native/bridge.c:632:    _SetupException = PyErr_NewException("_webiopi.GPIO.SetupException", NULL, NULL);
native/bridge.c:635:    _InvalidDirectionException = PyErr_NewException("_webiopi.GPIO.InvalidDirectionException", NULL, NULL);
native/bridge.c:638:    _InvalidChannelException = PyErr_NewException("_webiopi.GPIO.InvalidChannelException", NULL, NULL);
native/bridge.c:641:    _InvalidPullException = PyErr_NewException("_webiopi.GPIO.InvalidPullException", NULL, NULL);
grep: webiopi/clients: Is a directory
grep: webiopi/decorators: Is a directory
grep: webiopi/devices: Is a directory
webiopi/__init__.py:29:    import _webiopi.GPIO as GPIO
grep: webiopi/protocols: Is a directory
grep: webiopi/server: Is a directory
grep: webiopi/utils: Is a directory
pi@atrasp4:~/dev/WebIOPi-0.7.1/python$
```

- `native/bridge.c:607:    "_webiopi.GPIO", /* name of module */`<br>
 こいつ(`native/bridge.c`)が、`python`と`C`とやり取りするファイル？こいつが`import`時に失敗させたりしてる？
=> 眺める... `detect board revision` というコメントが...

```c:WebIOPi-0.7.1/python/native/bridge.c
   689          // detect board revision and set up accordingly
   690          revision = get_rpi_revision();
   691          if (revision == -1)
   692          {
   693                  PyErr_SetString(_SetupException, "This module can only b
e run on a Raspberry Pi!");
   694  #if PY_MAJOR_VERSION > 2
   695                  return NULL;
   696  #else
   697                  return;
   698  #endif
   699          }
   700
   701          _board_revision = Py_BuildValue("i", revision);
   702          PyModule_AddObject(module, "BOARD_REVISION", _board_revision);
```
=> `get_rpi_revision()`というので、らずぱいから実行されているか、チェックしている! そのあと、`BOARD_REVISION`もセットしている(?)

- `get_rpi_revision`をgrep.<br>

```
pi@atrasp4 ~/dev/WebIOPi-0.7.1/python/native $ grep get_rpi_revision *
bridge.c:       revision = get_rpi_revision();
cpuinfo.c:int get_rpi_revision(void)
cpuinfo.h:int get_rpi_revision(void);
pi@atrasp4 ~/dev/WebIOPi-0.7.1/python/native $
```
- cpuinfo.c　をながめると、
 `/proc/cpuinfo`を開いて、`Hardware  :`なんちゃらのとこで、`BCM2708`という文字列と比較している。

```
pi@atrasp4 ~/dev/WebIOPi-0.7.1/python/native $ cat /proc/cpuinfo | grep Hardware
Hardware        : BCM2709
```
=> らずぱい２では、 `BCM2709`とでる。.. ここを書き換える。

- 修正して、セットアップ`sudo ./setup.sh skip-apt`、実行 `sudo webiopi -d`で、ブラウザからアクセス。<br>
=> うごいたっぽい。


#### b)　WebUIの GPIO Headerを26から40ピンにしたい.

- 1 ブラウザ(Firefox)で、開いて、htmlのソース見る. 
 
```html:WebIOPi-0.7.1/htdocs/app/gpio-header/index.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <meta name="viewport" content = "width = 420, user-scalable = no" />
        <title>WebIOPi | GPIO Header</title>
        <script type="text/javascript" src="/webiopi.js"></script>
        <script type="text/javascript">
        webiopi().ready(function() {
                webiopi().RPiHeader().createTable("content");
                w().refreshGPIO(true);
        });
        </script>
</head>
<body>
<div id="content" align="center"></div>
</body>
</html>
```
=> `src="/webiopi.js"`が、本体っぽい.. 

- `webiopi().RPiHeader().createTable("content");` 
=> createTableってので、`<div id="content"...>`のとこに、26ピンの図を作ってる？ 

- `webiopi.js`をみてみる.  `pi@atrasp4 ~/dev/WebIOPi-0.7.1/htdocs $ cat -n webiopi.js | less`で、`/`を押して、`createTable[Enter]`

```js:WebIOPi-0.7.1/htdocs/webiopi.js
   577  RPiHeader.prototype.createTable = function (containerId) {
   578          var table = $("<table>");
   579          table.attr("id", "RPiHeader")
   580          for (var pin=1; pin<=26; pin++) {
   581                  var line =      $('<tr>');
   582                  line.append(this.getFunctionCell(pin))
   583                  line.append(this.getDescriptionCell(pin, "right"))
   584                  line.append(this.getPinCell(pin));
   585
   586                  pin++;
   587                  line.append(this.getPinCell(pin));
   588                  line.append(this.getDescriptionCell(pin, "left"))
   589                  line.append(this.getFunctionCell(pin))
   590
   591                  table.append(line);
   592          }
         ...
```
=> なんかそれっぽ処理。
- `26`を`40`へ変更して、`http://rpi_ip_addr:8000/app/gpio-header`へ。<br>
=> <font color="red">なんもうつらなくなった。。</font>

- 2 (Firefoxなので)FireBugで、見てみる。 [F12]をおして、FireBugをひらいて、gpio-headerへアクセス。
=> なんかエラーでてる
![WebIOPi_RasPi2-3.png](https://qiita-image-store.s3.amazonaws.com/0/75594/80a28f35-802e-5a85-9599-f6c7a08f96fc.png)
- `http://rpi_ip_addr:8000/map`へアクセス後、

```
TypeError: w(...).PINS[pin] is undefined
	
if (w().PINS[pin].type.value == w().TYPE.GPIO.value) {
```
というエラー。PINSをgrep

```js:WebIOPi-0.7.1/htdocs/webiopi.js
    75          this.GPIO = Array(54);
    76          this.PINS = Array(27);
```
=> `27 = 26pin+1`??なら、`40pin+1` => 41だろ？！

- ここを直しても、同じエラー。
=> xxx:8000/map でかえってくるのが、26個分のピンのマップしかない？ここを対応させよう。
- とりあえず、grepしてみるか...

```
pi@atrasp4 ~/dev/WebIOPi-0.7.1 $ grep '"V33", "V50", 2, "V50", 3' */*/*/*
grep: java/client/src/com: Is a directory
grep: java/client/src/org: Is a directory
grep: python/build/lib.linux-armv7l-2.7/webiopi: Is a directory
grep: python/build/lib.linux-armv7l-2.7/_webiopi: Is a directory
grep: python/build/lib.linux-armv7l-3.2/webiopi: Is a directory
grep: python/build/lib.linux-armv7l-3.2/_webiopi: Is a directory
grep: python/build/temp.linux-armv7l-2.7/native: Is a directory
grep: python/build/temp.linux-armv7l-3.2/native: Is a directory
grep: python/webiopi/devices/analog: Is a directory
grep: python/webiopi/devices/digital: Is a directory
grep: python/webiopi/devices/sensor: Is a directory
grep: python/webiopi/devices/shield: Is a directory
python/webiopi/utils/version.py:_MAPPING[2] = ["V33", "V50", 2, "V50", 3, "GND", 4, 14, "GND", 15, 17, 18, 27, "GND", 22, 23, "V33", 24, 10, "GND", 9, 25, 11, 8, "GND", 7]
```
- `python/webiopi/utils/version.py:_MAPPING[2] = ["V33", "V50", 2, "V50", 3, "GND", 4, 14, "GND", 15, 17, 18, 27, "GND", 22, 23, "V33", 24, 10, "GND", 9, 25, 11, 8, "GND", 7]` <br>
=> ググって、40pin用のマップをてきとうに作成...<br>
`_MAPPING[2] = ["V33", "V50", 2, "V50", 3, "GND", 4, 14, "GND", 15, 17, 18, 27, "GND", 22, 23, "V33", 24, 10, "GND", 9, 25, 11, 8, "GND", 7, 0, 1, 5, "GND", 6, 12, 13, "GND", 19, 16, 26, 20, "GND", 21]`

=> うごいたっぽい..

***

## その他
- 1. `$ ./setup.sh skip-apt` とすると、`apt-get update`が実行されない。(ちょいちょい変更して試す場合など)
- 2. `http://raspberrypi.local:8000/map`  で

```text
["V33", "V50", 2, "V50", 3, "GND", 4, 14, "GND", 15, 17, 18, 27, "GND", 22, 23, "V33", 24, 10, "GND", 9, 25, 11, 8, "GND", 7, 0, 1, 5, "GND", 6, 12, 13, "GND", 19, 16, 26, 20, "GND", 21]
```
- 3. `http://raspberrypi.local:8000/GPIO/*` で

```text
{"0": {"function": "IN", "value": 1}, "1": {"function": "IN", "value": 1}, "2": {"function": "IN", "value": 1}, "3": {"function": "IN", "value": 1}, "4": {"function": "IN", "value": 1}, "5": {"function": "IN", "value": 1}, "6": {"function": "IN", "value": 1}, "7": {"function": "IN", "value": 1}, "8": {"function": "IN", "value": 0}, "9": {"function": "IN", "value": 0}, "10": {"function": "IN", "value": 0}, "11": {"function": "IN", "value": 0}, "12": {"function": "IN", "value": 0}, "13": {"function": "IN", "value": 0}, "14": {"function": "ALT0", "value": 0}, "15": {"function": "ALT0", "value": 1}, "16": {"function": "IN", "value": 0}, "17": {"function": "IN", "value": 0}, "18": {"function": "IN", "value": 0}, "19": {"function": "IN", "value": 0}, "20": {"function": "IN", "value": 0}, "21": {"function": "OUT", "value": 1}, "22": {"function": "IN", "value": 0}, "23": {"function": "IN", "value": 0}, "24": {"function": "IN", "value": 0}, "25": {"function": "IN", "value": 0}, "26": {"function": "IN", "value": 0}, "27": {"function": "OUT", "value": 0}, "28": {"function": "IN", "value": 1}, "29": {"function": "IN", "value": 1}, "30": {"function": "IN", "value": 0}, "31": {"function": "OUT", "value": 1}, "32": {"function": "OUT", "value": 0}, "33": {"function": "IN", "value": 0}, "34": {"function": "IN", "value": 1}, "35": {"function": "IN", "value": 1}, "36": {"function": "IN", "value": 1}, "37": {"function": "IN", "value": 0}, "38": {"function": "OUT", "value": 0}, "39": {"function": "IN", "value": 0}, "40": {"function": "ALT0", "value": 0}, "41": {"function": "OUT", "value": 0}, "42": {"function": "IN", "value": 1}, "43": {"function": "IN", "value": 1}, "44": {"function": "ALT0", "value": 1}, "45": {"function": "ALT0", "value": 0}, "46": {"function": "IN", "value": 1}, "47": {"function": "OUT", "value": 0}, "48": {"function": "ALT0", "value": 0}, "49": {"function": "ALT0", "value": 1}, "50": {"function": "ALT0", "value": 1}, "51": {"function": "ALT0", "value": 1}, "52": {"function": "ALT0", "value": 1}, "53": {"function": "ALT0", "value": 1}}
```
- 4. `$ sudo webiopi -d`で、デバッグ情報がみれる。

```
$ sudo webiopi -d
2015-12-dd hh:mm:39 - WebIOPi - INFO - Starting WebIOPi/0.7.1/Python3.2
2015-12-dd hh:mm:39 - WebIOPi - DEBUG - Mapping GPIO.digitalCount to REST GET /GPIO/count
2015-12-dd hh:mm:39 - WebIOPi - DEBUG - Mapping GPIO.digitalRead to REST GET /GPIO/%(channel)d/value
2015-12-dd hh:mm:39 - WebIOPi - DEBUG - Mapping GPIO.digitalWrite to REST POST /GPIO/%(channel)d/value/%(value)d
2015-12-dd hh:mm:39 - WebIOPi - DEBUG - Mapping GPIO.getFunctionString to REST GET /GPIO/%(channel)d/function
2015-12-dd hh:mm:39 - WebIOPi - DEBUG - Mapping GPIO.getPulse to REST GET /GPIO/%(channel)d/pulse
2015-12-dd hh:mm:39 - WebIOPi - DEBUG - Mapping GPIO.outputSequence to REST POST /GPIO/%(channel)d/sequence/%(args)s
2015-12-dd hh:mm:39 - WebIOPi - DEBUG - Mapping GPIO.portRead to REST GET /GPIO/*/integer
2015-12-dd hh:mm:39 - WebIOPi - DEBUG - Mapping GPIO.portWrite to REST POST /GPIO/*/integer/%(value)d
2015-12-dd hh:mm:39 - WebIOPi - DEBUG - Mapping GPIO.pulse to REST POST /GPIO/%(channel)d/pulse/
2015-12-dd hh:mm:39 - WebIOPi - DEBUG - Mapping GPIO.pulseAngle to REST POST /GPIO/%(channel)d/pulseAngle/%(value)f
2015-12-dd hh:mm:39 - WebIOPi - DEBUG - Mapping GPIO.pulseRatio to REST POST /GPIO/%(channel)d/pulseRatio/%(value)f
2015-12-dd hh:mm:39 - WebIOPi - DEBUG - Mapping GPIO.setFunctionString to REST POST /GPIO/%(channel)d/function/%(value)s
2015-12-dd hh:mm:39 - WebIOPi - DEBUG - Mapping GPIO.wildcard to REST GET /GPIO/*
2015-12-dd hh:mm:39 - WebIOPi - INFO - GPIO - Native mapped to REST API /GPIO
2015-12-dd hh:mm:39 - WebIOPi - WARNING - Access unprotected
2015-12-dd hh:mm:39 - WebIOPi - INFO - HTTP Server binded on http://10.10.1.93:8000/
2015-12-dd hh:mm:39 - WebIOPi - INFO - CoAP Server binded on coap://10.10.1.93:5683/
2015-12-dd hh:mm:39 - WebIOPi - INFO - CoAP Server binded on coap://224.0.1.123:5683/ (MULTICAST)
2015-12-dd hh:mm:40 - HTTP - DEBUG - "GET /* HTTP/1.1" - 200 OK (Client: 10.10.1.113 <Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:42.0) Gecko/20100101 Firefox/42.0>)
2015-12-dd hh:mm:40 - HTTP - DEBUG - "GET /* HTTP/1.1" - 200 OK (Client: 10.10.1.113 <Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:42.0) Gecko/20100101 Firefox/42.0>)
2015-12-dd hh:mm:40 - HTTP - DEBUG - "GET /* HTTP/1.1" - 200 OK (Client: 10.10.1.113 <Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:42.0) Gecko/20100101 Firefox/42.0>)
2015-12-dd hh:mm:41 - HTTP - DEBUG - "GET /* HTTP/1.1" - 200 OK (Client: 10.10.1.113 <Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:42.0) Gecko/20100101 Firefox/42.0>)
2015-12-dd hh:mm:42 - HTTP - DEBUG - "GET /* HTTP/1.1" - 200 OK (Client: 10.10.1.113 <Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:42.0) Gecko/20100101 Firefox/42.0>)
^C2015-12-dd hh:mm:42 - WebIOPi - INFO - Stopping...
2015-12-dd hh:mm:42 - WebIOPi - DEBUG - Closing device GPIO - GPIO
2015-12-dd hh:mm:42 - WebIOPi - INFO - CoAP Server stopped
2015-12-dd hh:mm:42 - WebIOPi - INFO - HTTP Server stopped
```