Skip to main content

No project description provided

Project description

PyDRS - Sirius Power Supplies communication.

Linting and Static Latest tag Latest release PyPI version fury.io Read the Docs

What is PyDRS?

PyDRS is a Python package based on the Basic Small Messages Protocol BSMP. It is used to communicate with and command Sirius Current Power Supplies and its peripherals of the Digital Regulation System (DRS). The tailored protocol specification for the power supplies can be found here DRS Communication Protocol.

Communication is established through RS-485, USB or Ethernet interfaces of the UDC (Universal Digital Controller) cards. For USB and Ethernet, there should be only used Application Layer of the BSMP protocol (defined as bsmp message), and for those cases the transport layer address bytes and checksum, shall be omitted.

In order to cover all DRS driven current power supplies whilst meeting models specificities, BSMP entities are standardized as follows:

  1. Common variables: Variables used by all power supplies models, for example, general status and operating mode parameters. These variables occupy the first 25 BSMP variable Id's.
  2. Specific variables: Each power supply model (chosen through the PS Model parameter) defines ID variables greater than 24 according to its application. Thus, when communicating with a power supply, its model should prior be known in order to correctly use the specifications of those BSMP variables. This includes measures of feedback and monitoring and also interlocks records.

Development packages are listed at requirements-dev.txt and runtime dependencies at requirements.txt.

Basic Small Messages Protocol Library

The BSMP - Basic Small Messages Protocol - is a stateless, synchronous and lightweight protocol. It was designed to be used in serial communication networks of small embedded devices which contain a device with the role of a master.

This protocol manipulates 4 simple things, which are called Entities:

  1. Variables
  2. Groups
  3. Curves
  4. Functions

Variables can be either writable or read-only and have a value of up to 128 bytes.

A Group contains a bunch of Variables that can be read from or written to with only one command.

A Curve can be seen as a very large Variable, with up to 65536 blocks of 65520 bytes each.

Finally, a Function is a very simple way to perform a Remote Procedure Call (RPC).

Prerequisites

Disclaimer: Although pydrs is tested up to Python 3.10.0 version you may check whether other apps you want to use with it may run Python 3.10 version. Also should be the case that any of these applications may require Microsoft C++ build tools visualcppbuildtools.

Dev Utility scripts

Linux shell script to clear cache

sh ./scripts/clean.sh

Installation Guide

User level:

User-level version must be installed from the PyPI repository, using the 'pip install pydrs' command, which will install PyDRS onto the current Python path version.

Optional: - Conda

Conda is an open source package management system and environment management system that runs on Windows, macOS and Linux.

It can be used to create a specific environment where PyDRS module can be installed. Use miniconda for a free minimal installer for conda or anaconda for a full version for Conda.

conda create --name pydrs python=3.6
conda activate pydrs
pip install -U pydrs

Developer level:

For a developer level firstly clone the project repository from GitHub to your_local_folder via git command:

 git clone https://github.com/lnls-sirius/pydrs.git

image

Proceed to the pydrs folder and then you can use pip command by two means at your choice:

image

1. Just copying the repository locally. (Local changes on the project won't take effect on current pydrs installation).

Python module can be installed from the cloned source code. By using the 'pip install.' command at the root of the repository, the module will be installed normally, i.e. cloned files will be copied to the active python 'site-packages' folder.

pip install .

image

2. Copying the repository locally with the update feature. (Local changes will immediately take effect on pydrs current installation).

The use of the '-e' flag in the local installation is recommended for situations where the code is under development and the changes are wanted to be used immediately. Installing it with the 'pip install -e.' command will link it to the repository folder, so package reinstallation won't be needed whenever a change in the active local repository occurs.

pip install -e .

image

Tests

pip install -r requirements.txt
pip install -r requirements_dev.txt
pip install -e . -v
coverage run -m unittest discover
coverage xml
coverage report

Usage

When all installation is done, python or ipython instance can be called.

14

Import pydrs

image

Create drs object.

image

Establish the connection.

image

Set the device address to communicate.

image

Use BSMP commands to control the device.

image

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pydrs-1.2.3.tar.gz (36.9 kB view hashes)

Uploaded Source

Built Distribution

pydrs-1.2.3-py3-none-any.whl (37.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page