You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can find the Python tutorials on our site. You probably got here from [the getting started page](https://www.pozyx.io/Documentation/Tutorials/getting_started/Python)
32
+
You can find the Python tutorials on our site. You probably got here from [the getting started page](https://www.pozyx.io/Documentation/Tutorials/getting_started/Python) after all.
33
+
34
+
Documentation can be found [here](https://www.pozyx.io/Documentation/Datasheet/python).
32
35
33
-
There is currently a lack of documentation, unlike for the Arduino library. For now, these pointers and pages should be helpful:
34
-
* All functions that exist in the Arduino library, also exist in the Python library under the same name and functionality, so most of the [Arduino Library Documentation](https://www.pozyx.io/Documentation/Datasheet/arduino) is transformable to this. The major difference is that you don't ever again need to pass along the length of the data you're reading/writing. This is taken care of by the library:
35
-
* The Data and SingleRegister classes take care of this. eg. to read out the WhoAmI register, appending to the test code above.
36
+
* This was originally a port of the Pozyx's Arduino library, so most of the [Arduino Library Documentation](https://www.pozyx.io/Documentation/Datasheet/arduino) is transformable to this. The major difference is that you don't ever again need to pass along the length of the data you're reading/writing. This is taken care of by the library through the Data and SingleRegister classes like so:
36
37
```python
37
38
whoami = SingleRegister()
38
39
pozyx.regRead(POZYX_WHO_AM_I, whoami) # which is pozyx.getWhoAmI(whoami)
39
40
```
40
41
*`SingleRegister(value=0, size=1, signed=1)` is basically an instance `Data([0], 'B')`, which functions as a single uint8_t. If you want to make your custom data, for a single register you can adapt the size and signed parameters, and for larger data structures you can use your own data formats. `Data([0]*3, 'BHI')`, for example, creates a structure of 1 uint8_t, uint16_t and uint32_t. Writing and reading data using this example as a parameter will automatically read/write 7 bytes worth of data. To specify your own data formats, check the [struct package documentation for Python 3](https://docs.python.org/3.5/library/struct.html#format-characters) or [Python 2](https://docs.python.org/2/library/struct.html).
42
+
* A more pythonic library would be nice, but isn't in the works.
41
43
42
44
43
-
More usage examples can be found in the useful and examples folders of the repository.
45
+
More usage examples can be found in the [useful](https://github.com/pozyxLabs/Pozyx-Python-library/tree/master/useful) and [tutorials](https://github.com/pozyxLabs/Pozyx-Python-library/tree/master/tutorials) folders of the repository.
The unofficial release of the Python library (Beta version) to work with the pozyx indoor positioning system
4
+
5
+
This library works with both Python 2 and 3.
6
+
7
+
Prerequisites
8
+
-------------
9
+
* Download and install Python. On Windows, make your life easier and make sure Python is in your PATH. A recommended install is therefore the `Anaconda Suite <https://www.continuum.io/downloads>`_ by Continuum. If you're going to follow the tutorials, you'll need to install Python 3 for the python-osc support.
10
+
* Install the PySerial package. If you have pip installed, you can do this by writing ``pip install pyserial`` in your command line interface (cmd on Windows).
11
+
* **Windows only** install `ST's virtual COM driver <http://www.st.com/content/st_com/en/products/development-tools/software-development-tools/stm32-software-development-tools/stm32-utilities/stsw-stm32102.html>`_. After running this installer, please run the correct driver package for your system, located in "C:\\Program Files (x86)\\STMicroelectronics\\Software\\Virtual comport driver". Choose Win7 if you run Windows 7 or older. Choose Win8 for Windows 8 or newer. Run "dpinst_amd64.exe" on a 64-bit system, "dpinst_x86.exe"on a 32-bit system.
12
+
13
+
Installing this package
14
+
-----------------------
15
+
As it's not yet available on PyPi, you will have to install the library from source like this
16
+
17
+
* Download the library as a zip file, or clone it in a folder.
18
+
* After changing your command window's working directory to the extracted/cloned folder, perform ``python setup.py install``
19
+
20
+
PyPozyx is now installed. To check whether it is: if you followed all the steps correctly, and know which port your Pozyx is on, the following code should work:
21
+
22
+
.. code:: python
23
+
24
+
from pypozyx import PozyxSerial
25
+
port ='COMX'# on UNIX systems this will be '/dev/ttyACMX'
26
+
p = PozyxSerial(port)
27
+
28
+
29
+
If your port is correct and the serial connection to the Pozyx isn't used by other software, this will run without any errors.
30
+
31
+
But! How do I know what port my Pozyx is on?
32
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
33
+
34
+
* You can see the COM ports on your system easily using Python with: ``python -c "from pypozyx import *;list_serial_ports()"``
35
+
36
+
* **NEW** You can quickly find whether there's a recognized Pozyx device using: ``python -c "from pypozyx import *;print(get_first_pozyx_serial_port())"``
37
+
38
+
39
+
Documentation and examples
40
+
--------------------------
41
+
You can find the Python tutorials on our site. You probably got here from `the getting started page <https://www.pozyx.io/Documentation/Tutorials/getting_started/Python>`_
42
+
43
+
Documentation can be found `here <https://www.pozyx.io/Documentation/Datasheet/python>`_.
44
+
45
+
* This was originally a port of the Pozyx's Arduino library, so most of the `Arduino Library Documentation <https://www.pozyx.io/Documentation/Datasheet/arduino>`_ is transformable to this. The major difference is that you don't ever again need to pass along the length of the data you're reading/writing. This is taken care of by the library through the Data and SingleRegister classes like so:
46
+
47
+
.. code:: python
48
+
49
+
whoami = SingleRegister()
50
+
pozyx.regRead(POZYX_WHO_AM_I, whoami) # which is pozyx.getWhoAmI(whoami)
51
+
52
+
* `SingleRegister(value=0, size=1, signed=1)` is basically an instance `Data([0], 'B')`, which functions as a single uint8_t. If you want to make your custom data, for a single register you can adapt the size and signed parameters, and for larger data structures you can use your own data formats. `Data([0]*3, 'BHI')`, for example, creates a structure of 1 uint8_t, uint16_t and uint32_t. Writing and reading data using this example as a parameter will automatically read/write 7 bytes worth of data. To specify your own data formats, check the `struct package documentation for Python 3 <https://docs.python.org/3.5/library/struct.html#format-characters>`_ or `Python 2 <https://docs.python.org/2/library/struct.html>`_.
53
+
54
+
* A more pythonic library would be nice, but isn't in the works.
55
+
56
+
57
+
More usage examples can be found in the `useful <https://github.com/pozyxLabs/Pozyx-Python-library/tree/master/useful>`_ and `tutorials <https://github.com/pozyxLabs/Pozyx-Python-library/tree/master/tutorials>`_ folders of the repository.
0 commit comments