Skip to content

Commit d6852e8

Browse files
authored
Hotfix release 1.2.6 (#61)
* Fix switch of operation modes values (closes #48) The Operation mode registry (0x22) contains 0 when the jumper sets the device as a Tag and contains 1 when the jumper sets the device as an anchor. Therefore, the constants are switched in the library to match the behavior of the device. * Hotfix/filter data (#60) * Fix data storing FilterData always returns 0 when reading data from reg due to improper self.data initialization. * Fix improper method name in call * Fix bit operation priority The + operator is called prior to the shift operator wich produce invalid result * Added full discovery as tool, version bump, structured tools a bit
1 parent b6c5b4c commit d6852e8

File tree

8 files changed

+58
-19
lines changed

8 files changed

+58
-19
lines changed

pypozyx/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
7373
"""
7474

75-
__version__ = '1.2.5'
75+
__version__ = '1.2.6'
7676

7777
VERSION = __version__
7878
version = __version__

pypozyx/definitions/constants.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ class PozyxConstants:
5555
LED_OFF = False
5656

5757
# Pozyx device modes
58-
ANCHOR_MODE = 0
59-
TAG_MODE = 1
58+
TAG_MODE = 0
59+
ANCHOR_MODE = 1
6060

6161
# The GPIO modes
6262
GPIO_DIGITAL_INPUT = 0

pypozyx/lib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,7 @@ def getPositionFilterStrength(self, remote_id=None):
852852
POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
853853
"""
854854
filter_data = FilterData()
855-
status = self.getPositionFilter(filter_data, remote_id=remote_id)
855+
status = self.getPositionFilterData(filter_data, remote_id=remote_id)
856856

857857
if status != POZYX_SUCCESS:
858858
warn("Wasn't able to get filter data, returning -1 as strength")

pypozyx/structures/device.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -308,15 +308,16 @@ def __init__(self, filter_type=0, filter_strength=0):
308308
self.filter_strength = filter_strength
309309
# TODO add type validation?
310310

311-
self.value = self.filter_type + self.filter_strength << 4
311+
self.value = self.filter_type + (self.filter_strength << 4)
312312
self.load([self.value])
313313

314-
def load(self, data=None, convert=False):
315-
self.data = [0] if data is None else data
314+
def load(self, data=[0], convert=False):
315+
self.data = data
316+
self.value = data[0]
317+
self.update_data()
316318

317319
self.filter_type = self.data[0] & 0xF
318320
self.filter_strength = self.data[0] >> 4
319-
self.value = self.filter_type + self.filter_strength << 4
320321

321322
def update_data(self):
322323
try:
Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
1-
from pypozyx import PozyxConstants, UWBSettings, SingleRegister, DeviceList, DeviceCoordinates, Coordinates
2-
3-
4-
def all_discovery_uwb_settings():
5-
for channel in PozyxConstants.ALL_UWB_CHANNELS:
6-
for bitrate in PozyxConstants.ALL_UWB_BITRATES:
7-
for prf in PozyxConstants.ALL_UWB_PRFS:
8-
for plen in [PozyxConstants.UWB_PLEN_64, PozyxConstants.UWB_PLEN_1536]:
9-
yield UWBSettings(channel, bitrate, prf, plen, 33)
1+
from pypozyx import SingleRegister, DeviceList, DeviceCoordinates, Coordinates
102

113

124
def all_device_coordinates_in_device_list(pozyx, remote_id=None):
135
list_size = SingleRegister()
146
status = pozyx.getDeviceListSize(list_size, remote_id=remote_id)
157

168
if list_size.value == 0:
9+
# TODO investigate if valid?
1710
return
1811

1912
device_list = DeviceList(list_size=list_size.value)
@@ -24,3 +17,4 @@ def all_device_coordinates_in_device_list(pozyx, remote_id=None):
2417
pozyx.getDeviceCoordinates(device_id, coordinates, remote_id=remote_id)
2518
yield DeviceCoordinates(device_id, 0, pos=coordinates)
2619

20+

pypozyx/tools/discovery.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
from pypozyx import PozyxConstants, UWBSettings, SingleRegister, DeviceList
2+
3+
4+
def all_discovery_uwb_settings():
5+
for channel in PozyxConstants.ALL_UWB_CHANNELS:
6+
for bitrate in PozyxConstants.ALL_UWB_BITRATES:
7+
for prf in PozyxConstants.ALL_UWB_PRFS:
8+
for plen in PozyxConstants.ALL_UWB_PLENS:
9+
yield UWBSettings(channel, bitrate, prf, plen, 33)
10+
11+
12+
def get_device_list(pozyx):
13+
""""""
14+
device_list_size = SingleRegister()
15+
pozyx.getDeviceListSize(device_list_size)
16+
device_list = DeviceList(list_size=device_list_size[0])
17+
pozyx.getDeviceIds(device_list)
18+
return device_list
19+
20+
21+
def discover_all_devices(pozyx):
22+
original_uwb_settings = UWBSettings()
23+
pozyx.getUWBSettings(original_uwb_settings)
24+
25+
for uwb_settings in all_discovery_uwb_settings():
26+
pozyx.setUWBSettings(uwb_settings)
27+
28+
pozyx.clearDevices()
29+
pozyx.doDiscoveryAll(slots=3, slot_duration=0.1)
30+
31+
device_list = get_device_list(pozyx)
32+
if device_list:
33+
print("Found on {}".format(uwb_settings))
34+
for device_id in device_list:
35+
print("\t- {}".format(device_id))
36+
37+
pozyx.setUWBSettings(original_uwb_settings)
38+
39+
40+
if __name__ == '__main__':
41+
from pypozyx import PozyxSerial, get_first_pozyx_serial_port
42+
pozyx = PozyxSerial(get_first_pozyx_serial_port())
43+
44+
discover_all_devices(pozyx)

pypozyx/tools/version_check.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import json
33
import pypozyx
44
import warnings
5-
import time
65

76

87
class Version(object):

useful/system_analysis.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010

1111
from pypozyx import PozyxSerial, get_first_pozyx_serial_port, PozyxConstants, POZYX_SUCCESS, UWBSettings, PozyxRegisters
1212
from pypozyx.structures.device_information import DeviceDetails
13-
from pypozyx.tools.discover_all_devices import all_discovery_uwb_settings, all_device_coordinates_in_device_list
13+
from pypozyx.tools.discovery import all_discovery_uwb_settings
14+
from pypozyx.tools.device_list import all_device_coordinates_in_device_list
1415

1516

1617
class Device(object):

0 commit comments

Comments
 (0)