LoginSignup
1
3

More than 5 years have passed since last update.

ラズパイ3 + Dasher で"No devices to listen"エラー

Last updated at Posted at 2017-07-10

Dasher を実行すると "en0: No such device"

RaspberryPi3(Raspbian Jessie Lite) + 有線 LAN + Dasher(w/node.js+npm+libpcap-dev+git) 環境で実行(sudo npm run start)すると、「en0: No such device」エラーが出る。[#実行時のエラー内容]

TL;DR

~/dasher/config/config.json の "interface" : "en0" 行を削除するか、"en0" を "eth0" に変更する。

{"buttons":[
  {
    "name": "PUSHED_ADB_NESCAFE",
    "address": "b4:7c:9c:xx:xx:xx",
    "interface": "en0", ← この行を削除か"eth0"に変更
    "protocol": "udp",
    "timeout": "60000",
    "url": "https://sample.com/ping?hello=world",
    "method": "POST",
    "json": true,
    "body": {"value1": "hoge", "value2": "hogehoge", "foo": "bar"}
  }
]}

エラーの説明

簡単に言えば「"en0" と指定しているが、接続の確立されていない Wifi を監視しようとしているため発生しているエラー」です。

Dasher は、起動するとネットワークのブロードキャスト信号を監視して、指定した MAC アドレスとプロトコル(arp か udp)で何かしらの動きがあるとトリガーを叩く(指定した URL に HTTP リクエストを送る)というシンプルな動きをします。

通常、有効なネットワークインターフェースを指定する時は「en0」を利用するため、一見「安定性を優先して有線 LAN接続なのに」と悩んでしまいます。Ether も動いているし。

ラズパイ3 は WiFi と Ether (無線 LAN と有線 LAN )を標準で備えているので、WiFi を無効にせず SSID などの設定もせずにそのままの状態で、有線 LAN だけの接続を行なっている場合にこの現象が発生します。

つまり、「en0」を指定することで、「動いているが接続が確立されていない WiFi」を通して監視しようとするので「No devices to listen」と「監視できるもんがないよ」と怒られてしまうのです。

そのため、有線 LAN(Ether) ポート「eth0」を指定するか、指定行を削除します。「interface」の指定行を削除すると、すべてのインターフェースを監視するため、後日 WiFi の SSID の設定を行なっても動作します。また、監視の負荷を減らしたい場合は、あえて「eth0」を指定する方がいいでしょう。

所感

ラズパイの定番の遊びの1つに、Amazon の DashButton (以下 ADB)を WebHook のトリガーにするものがあります。

①ADB を押す、②指定された URL が叩かれる、③叩かれた側(自作の Web アプリなど)で、あんなことやこんなことができる、と妄想を膨らませられます

以前から妄想を膨らませていた矢先、セールで 300 円/個になっていたので、ポチってしまいました。

ボタンを押すと音楽が鳴るとか色々考えていたのですが、「トイレに入った時に押すボタン」と、「タバコを吸った時に押すボタン」の2つから始めました。

というのも、母が長いこと膀胱炎で悩んでいる(治ったりの再発を繰り返している)のですが、正確な原因を調べるためトイレの回数と入った時間の記録を取らないといけないらしく、なかなか苦労して(記憶を頼りに後日一気にノートに記入して)いました。トイレでボタンを押すとタイムスタンプが押されるだけの単純なものですが、CSV に出力して Excel で整えられるため、先生も関心していました。

2つめに試したのは「タバコを吸った時に押すボタン」で、これも押されたタイムスタンプを記録するだけの単純なものです。
今は無理して止めようとは思わないのですが、健康には気を使わないといけません。そこで、タバコを吸う動向を記録しておいて、後日ディープラーニングの学習に使いたいなと考えています。

あと1つあるので何に使うか検討中ですが、楽しみです。

関連情報

実行時のエラー内容

pi@raspberrypi:~/dasher $ sudo npm run start

> dasher@1.4.1 start /home/pi/dasher
> node app.js

warning: SIOCGIFADDR: en0: No such device - this may not actually work
[Error: SIOCGIFHWADDR: No such device]
Failed to create pcap session: couldn't find devices to listen on.
Try running with elevated privileges via 'sudo'
/home/pi/dasher/node_modules/node-dash-button/index.js:28
        throw new Error('Error: No devices to listen');
        ^

Error: Error: No devices to listen
    at create_session (/home/pi/dasher/node_modules/node-dash-button/index.js:28:15)
    at register (/home/pi/dasher/node_modules/node-dash-button/index.js:47:24)
    at new DasherButton (/home/pi/dasher/lib/dasher.js:14:21)
    at Object.<anonymous> (/home/pi/dasher/app.js:8:16)
    at Module._compile (module.js:435:26)
    at Object.Module._extensions..js (module.js:442:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Function.Module.runMain (module.js:467:10)
    at startup (node.js:134:18)

npm ERR! Linux 4.9.36-v7+
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "start"
npm ERR! node v4.2.1
npm ERR! npm  v2.14.7
npm ERR! code ELIFECYCLE
npm ERR! dasher@1.4.1 start: `node app.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the dasher@1.4.1 start script 'node app.js'.
npm ERR! This is most likely a problem with the dasher package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node app.js
npm ERR! You can get their info via:
npm ERR!     npm owner ls dasher
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/pi/dasher/npm-debug.log

/home/pi/dasher/npm-debug.log の内容

pi@raspberrypi:~/dasher $ cat /home/pi/dasher/npm-debug.log
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'start' ]
2 info using npm@2.14.7
3 info using node@v4.2.1
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info prestart dasher@1.4.1
6 info start dasher@1.4.1
7 verbose unsafe-perm in lifecycle true
8 info dasher@1.4.1 Failed to exec start script
9 verbose stack Error: dasher@1.4.1 start: `node app.js`
9 verbose stack Exit status 1
9 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:214:16)
9 verbose stack     at emitTwo (events.js:87:13)
9 verbose stack     at EventEmitter.emit (events.js:172:7)
9 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:24:14)
9 verbose stack     at emitTwo (events.js:87:13)
9 verbose stack     at ChildProcess.emit (events.js:172:7)
9 verbose stack     at maybeClose (internal/child_process.js:818:16)
9 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
10 verbose pkgid dasher@1.4.1
11 verbose cwd /home/pi/dasher
12 error Linux 4.9.36-v7+
13 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "start"
14 error node v4.2.1
15 error npm  v2.14.7
16 error code ELIFECYCLE
17 error dasher@1.4.1 start: `node app.js`
17 error Exit status 1
18 error Failed at the dasher@1.4.1 start script 'node app.js'.
18 error This is most likely a problem with the dasher package,
18 error not with npm itself.
18 error Tell the author that this fails on your system:
18 error     node app.js
18 error You can get their info via:
18 error     npm owner ls dasher
18 error There is likely additional logging output above.
19 verbose exit [ 1, true ]

正常動作の表示

pi@raspberrypi:~/dasher $ sudo npm run start

> dasher@1.4.1 start /home/pi/dasher
> node app.js

[2017-07-10T13:31:46.972Z] PUSHED_ADB_NESCAFE added.
[2017-07-10T13:32:06.726Z] PUSHED_ADB_NESCAFE pressed. Count: 1 ←ADB押下で表示
1
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
3