当试图通过Bacpypes再次从网络读取时,Errno 10048

时间:2015-01-31 09:16:54

标签: python sockets errno bacnet

我使用一个名为Bacpypes的python库来读取网络中的bacnet点。在我用函数MultipleReadProperty读取我的点的第一次试验中,没有问题。我毫无问题地获得所有价值。但在第二次民意调查中,我得到一个关于套接字的错误,如下所示:

[0.0, 1149064.0, 1941115.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 13525024.0, 448152.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
[31/Jan/2015:11:39:33] HTTP Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\cherrypy\_cprequest.py", line 670, in respond
    response.body = self.handler()
  File "C:\Python27\lib\site-packages\cherrypy\lib\encoding.py", line 217, in __call__
    self.body = self.oldhandler(*args, **kwargs)
  File "C:\Python27\lib\site-packages\cherrypy\_cpdispatch.py", line 61, in __call__
    return self.callable(*self.args, **self.kwargs)
  File "C:\Users\Sansal\Desktop\Projeler\sayac_okuma8\main2.py", line 231, in sayac_oku
    readings_from_counters=ReadCounters(counters_list)
  File "C:\Users\Sansal\Desktop\Projeler\sayac_okuma8\main2.py", line 153, in ReadCounters
    this_application = ReadPointListApplication(points_list, this_device, args.ini.address)
  File "C:\Users\Sansal\Desktop\Projeler\sayac_okuma8\main2.py", line 43, in __init__
    BIPSimpleApplication.__init__(self, *args)
  File "C:\Python27\lib\site-packages\bacpypes-0.10.6-py2.7.egg\bacpypes\app.py", line 555, in __init__
    self.mux = UDPMultiplexer(self.localAddress)
  File "C:\Python27\lib\site-packages\bacpypes-0.10.6-py2.7.egg\bacpypes\bvllservice.py", line 85, in __init__
    self.directPort = udp.UDPDirector(self.addrTuple)
  File "C:\Python27\lib\site-packages\bacpypes-0.10.6-py2.7.egg\bacpypes\udp.py", line 144, in __init__
    self.bind(address)
  File "C:\Python27\lib\asyncore.py", line 342, in bind
    return self.socket.bind(addr)
  File "C:\Python27\lib\socket.py", line 224, in meth
    return getattr(self._sock,name)(*args)
error: [Errno 10048] Only one usage of each socket address (protocol/network address/port) is normally permitted. 

如第一行所示,我从网络中获取所有值没有问题。

为了解决问题,我在几个代码点使用了Bacpypes库的stop()函数。特别是在开始轮询的代码之前。但是,似乎我无法以某种方式关闭套接字。你能就这个问题提出一些建议吗?

提前致谢。

1 个答案:

答案 0 :(得分:1)

Bacpypes最近已更新至0.15版本,并且在文档中已经做了很多努力。有许多新功能,代码已经简化为典型的东西,如whois,IAm。

我建议你看看http://bacpypes.readthedocs.io/en/latest/

在这里:https://github.com/JoelBender/bacpypes/blob/master/samples/MultipleReadProperty.py

我还可以建议BAC0(http://bac0.readthedocs.io/en/latest/),它建立在bacpypes之上,并提供与BACnet设备通信的开箱即用功能。 (免责声明:BAC0是我的项目,我是bacpypes的贡献者)