1

シリアル ポートが /dev/tty.EV3-SerialPort である Lego EV3 ブロックとの接続を開こうとしています。Mac 10.6.8 を使用しています。これを行うとリソースがビジーになりますが、他のAPIを使用して接続すると(pyserialではなくシリアルポートに書き込みます)、エラーは表示されません。このエラーを回避する方法を見つけたいと思います。なぜビジーなのか、他のすべての Bluetooth アプリケーションが無効になっています。これが私のコードです:

test.py:

import serial
import time
ser = serial.Serial('/dev/tty.EV3-SerialPort', 19200, timeout=1)  # open first serial port
ser.close()
ser.open()
time.sleep(1)
ser.close()
print "closed"

出力されるエラーは次のとおりです。

File "test.py", line 7, in <module>
ser.open()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/serial/serialposix.py", line 289, in open
self.fd = os.open(self.portstr, os.O_RDWR|os.O_NOCTTY|os.O_NONBLOCK)
OSError: [Errno 16] Resource busy: '/dev/tty.EV3-SerialPort'

ポップアップも表示され、次のように表示されます。

A Bluetooth serial failure has occurred.
Failed to open an RFCOMM serial channel.
Check if authentication needs to be enabled in your device
4

2 に答える 2