From 4d46b3731a2ba67362e96f4c05a8eaee0805465e Mon Sep 17 00:00:00 2001 From: Arkadiusz Ambroziak Date: Thu, 14 Sep 2023 11:28:47 +0200 Subject: [PATCH 1/2] fix for influxdb client --- BAC0/db/influxdb.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BAC0/db/influxdb.py b/BAC0/db/influxdb.py index 1636b6ac..8b6494a5 100644 --- a/BAC0/db/influxdb.py +++ b/BAC0/db/influxdb.py @@ -1,6 +1,6 @@ try: from influxdb_client import InfluxDBClient, Point, WriteOptions - from influxdb_client.client.write import WriteApi + from influxdb_client.client.write_api import WriteApi except ImportError: raise ImportError("Install influxdb to use this feature") From 78c58c2695c2e02836bd26612a976736174e0349 Mon Sep 17 00:00:00 2001 From: Neil Date: Thu, 9 Nov 2023 10:53:43 -0800 Subject: [PATCH 2/2] add sleep arg to whois --- BAC0/core/functions/Discover.py | 6 +++--- BAC0/scripts/Lite.py | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/BAC0/core/functions/Discover.py b/BAC0/core/functions/Discover.py index 755a9401..a215153f 100644 --- a/BAC0/core/functions/Discover.py +++ b/BAC0/core/functions/Discover.py @@ -163,7 +163,7 @@ class Discover: Define BACnet WhoIs and IAm functions. """ - def whois(self, *args, global_broadcast=False, destination=None): + def whois(self, *args, global_broadcast=False, destination=None, sleep_ms=100): """ Build a WhoIs request @@ -175,6 +175,7 @@ def whois(self, *args, global_broadcast=False, destination=None): whois(global_broadcast=True) # WhoIs broadcast globally. Every device will respond with an IAm whois('2:5') # WhoIs looking for the device at (Network 2, Address 5) whois('10 1000') # WhoIs looking for devices in the ID range (10 - 1000) + whois(sleep_ms=3000) # WhoIs waiting for 3 seconds for responses """ if not self._started: @@ -221,8 +222,7 @@ def whois(self, *args, global_broadcast=False, destination=None): if iocb.ioError: # unsuccessful: error/reject/abort pass - for each in range(100): - time.sleep(1 / 1000) + time.sleep(sleep_ms / 1000) self.discoveredDevices = self.this_application.i_am_counter return self.this_application._last_i_am_received diff --git a/BAC0/scripts/Lite.py b/BAC0/scripts/Lite.py index 5dae9bbe..683e4760 100755 --- a/BAC0/scripts/Lite.py +++ b/BAC0/scripts/Lite.py @@ -220,6 +220,7 @@ def discover( limits: t.Tuple[int, int] = (0, 4194303), global_broadcast: bool = False, reset: bool = False, + whois_sleep_ms: int = 100, ): """ Discover is meant to be the function used to explore the network when we @@ -286,6 +287,7 @@ def discover( deviceInstanceRangeHighLimit, ), global_broadcast=global_broadcast, + sleep_ms=whois_sleep_ms, ) for each in _res: found.append(each) @@ -301,6 +303,7 @@ def discover( deviceInstanceRangeLowLimit, deviceInstanceRangeHighLimit ), global_broadcast=global_broadcast, + sleep_ms=whois_sleep_ms, ) for each in _res: found.append(each)