質問編集履歴
1
疑問点の表記の変更
title
CHANGED
File without changes
|
body
CHANGED
@@ -2,30 +2,17 @@
|
|
2
2
|
②GPIOの入力状態(スイッチでLEDを点灯消灯)をwebブラウザにリアルタイムに表示する
|
3
3
|
上記の動作を同一プロセスで実現したく、threadingを使用して試みました。
|
4
4
|
|
5
|
-
しかし下記のよう
|
5
|
+
しかし下記のようなエラーとなり、うまく動きませんでした。
|
6
|
-
・コード実行⇒
|
7
|
-
動かない⇒Ctrl+C入力⇒def sendMessageが動作する⇒Ctrl+C入力⇒下記エラー
|
8
6
|
Traceback (most recent call last):
|
9
|
-
File "threadgpio.py", line 75, in <module>
|
10
|
-
thread1 = threading.Thread(target=sendMessage, args=((client, server)))
|
11
|
-
NameError: name 'client' is not defined
|
12
|
-
|
13
|
-
もしくは
|
14
|
-
|
15
|
-
・コード実行⇒
|
16
|
-
def sendMessageは動作⇒Ctrl+C入力⇒webブラウザ更新⇒
|
17
|
-
BrokenPipeError: [Errno 32] Broken pipe⇒
|
18
|
-
def receivedMessageは動作(def sendMessage動作せず)⇒
|
19
|
-
Ctrl+C入力⇒下記エラー
|
20
|
-
|
21
|
-
Traceback (most recent call last):
|
22
7
|
File "threadgpio.py", line 74, in <module>
|
23
8
|
thread1 = threading.Thread(target=sendMessage, args=((client, server)))
|
24
9
|
NameError: name 'client' is not defined
|
25
10
|
|
26
11
|
|
12
|
+
def sendMessage(client, server1):
|
13
|
+
def receivedMessage(client, server2, message):
|
27
|
-
|
14
|
+
上記のコールバック関数の引数を、threadに渡せてないようです。
|
28
|
-
|
15
|
+
どのようにすれば引数をthreadに渡すことができるでしょうか。
|
29
16
|
|
30
17
|
|
31
18
|
```python
|