Python library for Pozyx devices
Project description
A Python library to work with the pozyx indoor positioning system over USB.
This library works with both Python 2 and 3.
Prerequisites
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 by Continuum. If you’re going to follow the tutorials, you’ll need to install Python 3 for the python-osc support.
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).
Windows only install ST’s virtual COM driver. 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.
Installing this package
Just run pip install pypozyx
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:
from pypozyx import PozyxSerial
port = 'COMX' # on UNIX systems this will be '/dev/ttyACMX'
p = PozyxSerial(port)
If your port is correct and the serial connection to the Pozyx isn’t used by other software, this will run without any errors.
But! How do I know what port my Pozyx is on?
You can see the COM ports on your system easily using Python with: python -c "from pypozyx import *;list_serial_ports()"
NEW You can quickly find whether there’s a recognized Pozyx device using: python -c "from pypozyx import *;print(get_first_pozyx_serial_port())"
Documentation and examples
You can find the Python tutorials on our site. You probably got here from the getting started page
Documentation can be found here.
This was originally a port of the Pozyx’s Arduino library, so most of the Arduino Library Documentation 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:
whoami = SingleRegister()
pozyx.regRead(POZYX_WHO_AM_I, whoami) # which is pozyx.getWhoAmI(whoami)
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 or Python 2.
A more pythonic library would be nice, but isn’t in the works.
More usage examples can be found in the useful and tutorials folders of the repository.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Hashes for pypozyx-1.2.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 14520a07b18a76b2af5caefd0cc25a8dc1fd4f084e28a9e51954a80f5acf0586 |
|
MD5 | 698a6edcab2cd66a43bafe14f6836f9b |
|
BLAKE2b-256 | 733586a4441580c88e7a7f5ec07466f2da70872cf6286bf43b44dc2ec21fe9d3 |