“ IOError:提供了无效的参数。”尝试连接到插座时

时间:2018-10-09 18:49:47

标签: python-2.7 pybluez

我正在尝试连接到套接字,但是,一旦connect()被调用,它将引发IOError异常。  我的代码:

import Tkinter as tk
import bluetooth as bt

configFile = open(r"Configuration\conf.ini", "r")

addr = configFile.readline()
port = configFile.readline()

addr = addr.replace('address: ','')
port = port.replace('port: ','')
root = tk.Tk()

cs = bt.BluetoothSocket( bt.RFCOMM )

def connectEvent():
    cs.connect( (addr,int(port)) )
def endEvent():
    cs.close()

if __name__ == '__main__':
    connB = tk.Button(root, text="Connect to Robot", command=connectEvent, relief=tk.GROOVE)
    endB = tk.Button(root, text="End connection", command=endEvent,relief=tk.GROOVE)

我尝试提供不同于configFile的地址和端口,但是,没有一个能真正解决问题

configFile内容:

address: 00:12:D2:5A:BD:E4
port: 9832

0 个答案:

没有答案