質問するログイン新規登録

質問編集履歴

2

アドレスを××に

2016/05/20 07:34

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -17,8 +17,8 @@
17
17
  import bluetooth
18
18
  from time import sleep
19
19
 
20
- bd_addr1 = "00:06:66:7D:BE:90" #the address form the Arduino
20
+ bd_addr1 = "××:××:××:××:××:××" #the address
21
- port1 = 1 #Connect Port (raspberry pi to Arduino)
21
+ port1 = 1 #Connect Port
22
22
  sock1 = bluetooth.BluetoothSocket(bluetooth.RFCOMM) #config
23
23
 
24
24
  print "connect......"

1

情報不足の指摘があったためつき追記

2016/05/20 07:34

投稿

退会済みユーザー
title CHANGED
@@ -1,1 +1,1 @@
1
- Python
1
+ Python Bluetooth通信におけるデータの送信
body CHANGED
@@ -14,8 +14,33 @@
14
14
  BluetoothError: (9, 'Bad file descriptor')
15
15
 
16
16
  ###該当のソースコード
17
+ import bluetooth
18
+ from time import sleep
17
19
 
20
+ bd_addr1 = "00:06:66:7D:BE:90" #the address form the Arduino
21
+ port1 = 1 #Connect Port (raspberry pi to Arduino)
18
- sock1.sendall("0")
22
+ sock1 = bluetooth.BluetoothSocket(bluetooth.RFCOMM) #config
19
23
 
24
+ print "connect......"
25
+ sleep(2)
26
+ sock1.connect((bd_addr1 ,port1))
27
+ print "connected"
28
+
29
+ sleep(1)
30
+
31
+ print("Entering main loop now")
32
+
33
+ try:
34
+ while 1:
35
+ print "input"
36
+ tosend = raw_input()
20
- ###補足情報(言語/FW/ツール等のバージョンなど)
37
+ if tosend != 'q':
38
+ #sock1.sendall(tosend)
39
+ sock1.sendall("0")
21
- より詳細な情報
40
+ else:
41
+ break
42
+ print "Wait...."
43
+ sleep(0.01)
44
+ sock.close()
45
+ except KeyboardInterrupt:
46
+ pass