我使用一个名为 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() 函数。尤其是在开始轮询的代码之前。但是,看来我无法以某种方式关闭套接字。你能就这个问题提出一些建议吗?
提前致谢。