###前提・実現したいこと
Python Bluetooth socketを用いてデータの送信
sock1.sendall(0)としたところ
TypeError: must be string or read-only buffer, not list
と出たので"0"にしたのですが解決しません
###発生している問題・エラーメッセージ
Traceback (most recent call last):
File "/home/pi/PS3RN42.py", line 40, in <module>
sock1.sendall("0")
File "<string>", line 5, in sendall
BluetoothError: (9, 'Bad file descriptor')
###該当のソースコード
import bluetooth
from time import sleep
bd_addr1 = "××:××:××:××:××:××" #the address
port1 = 1 #Connect Port
sock1 = bluetooth.BluetoothSocket(bluetooth.RFCOMM) #config
print "connect......"
sleep(2)
sock1.connect((bd_addr1 ,port1))
print "connected"
sleep(1)
print("Entering main loop now")
try:
while 1:
print "input"
tosend = raw_input()
if tosend != 'q':
#sock1.sendall(tosend)
sock1.sendall("0")
else:
break
print "Wait...."
sleep(0.01)
sock.close()
except KeyboardInterrupt:
pass
回答1件
あなたの回答
tips
プレビュー