2016-08-08 5 views
0

파이썬에서 시리얼 포트와 통신하고 싶습니다.파이썬이 포트를 열 수 없습니다

import thread 
import serial 
PORT = '/dev/rfcomm0' 
BAUDRATE = 921600 
TIMEOUT = 1 
port = serial.Serial(port=PORT, baudrate=BAUDRATE, timeout=TIMEOUT) 
port.open() 
... 
port.close() 

그것은 다음과 같은 오류를 제공합니다 :

Traceback (most recent call last): 
    File "/home/dnaphone/PycharmProjects/test/BluetoothClient.py", line 12, in <module> 
    port = serial.Serial(port=PORT, baudrate=BAUDRATE, timeout=TIMEOUT) 
    File "/usr/local/lib/python2.7/dist-packages/serial/serialutil.py", line 182, in __init__ 
    self.open() 
    File "/usr/local/lib/python2.7/dist-packages/serial/serialposix.py", line 247, in open 
    raise SerialException(msg.errno, "could not open port {}: {}".format(self._port, msg)) 
serial.serialutil.SerialException: [Errno 2] could not open port /dev/rfcomm0: [Errno 2] No such file or directory: '/dev/rfcomm0' 
+0

/dev/rfcomm0을 마운트하지 않은 기본 OS와 관련된 것으로 보입니다. – Lino

+0

'python -m serial.tools.list_ports'를 실행하고'/ dev/rfcomm0'이 나타나는지 확인하십시오. – dhdavvie

+0

@dhavavie after 실행 결과입니다 : 포트를 찾을 수 없습니다 –

답변

0

는/dev/rfcomm0는 BlueZ는 가상 장치 포트를 등록 보인다 나는 리눅스에 대한 pyserial를 설치했습니다. 이 장치를 시스템에 등록 할 수 있습니까? 블루투스가 잘 시작 했습니까?

관련 문제