2025-05-22 12:51:20 +00:00
<!DOCTYPE html>
< html class = "writer-html5" lang = "en" data-content_root = "./" >
< head >
< meta charset = "utf-8" / > < meta name = "viewport" content = "width=device-width, initial-scale=1" / >
< meta name = "viewport" content = "width=device-width, initial-scale=1.0" / >
< title > Pyhoff — pyhoff documentation< / title >
< link rel = "stylesheet" type = "text/css" href = "_static/pygments.css?v=b86133f3" / >
< link rel = "stylesheet" type = "text/css" href = "_static/css/theme.css?v=e59714d7" / >
< script src = "_static/jquery.js?v=5d32c60e" > < / script >
< script src = "_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c" > < / script >
< script src = "_static/documentation_options.js?v=5929fcd5" > < / script >
< script src = "_static/doctools.js?v=9bcbadda" > < / script >
< script src = "_static/sphinx_highlight.js?v=dc90522c" > < / script >
< script src = "_static/js/theme.js" > < / script >
< link rel = "index" title = "Index" href = "genindex.html" / >
< link rel = "search" title = "Search" href = "search.html" / >
< link rel = "next" title = "Pyhoff" href = "readme.html" / >
< / head >
< body class = "wy-body-for-nav" >
< div class = "wy-grid-for-nav" >
< nav data-toggle = "wy-nav-shift" class = "wy-nav-side" >
< div class = "wy-side-scroll" >
< div class = "wy-side-nav-search" >
< a href = "#" class = "icon icon-home" >
pyhoff
< / a >
< div role = "search" >
< form id = "rtd-search-form" class = "wy-form" action = "search.html" method = "get" >
< input type = "text" name = "q" placeholder = "Search docs" aria-label = "Search docs" / >
< input type = "hidden" name = "check_keywords" value = "yes" / >
< input type = "hidden" name = "area" value = "default" / >
< / form >
< / div >
< / div > < div class = "wy-menu wy-menu-vertical" data-spy = "affix" role = "navigation" aria-label = "Navigation menu" >
< p class = "caption" role = "heading" > < span class = "caption-text" > Contents:< / span > < / p >
< ul >
< li class = "toctree-l1" > < a class = "reference internal" href = "readme.html" > Pyhoff< / a > < / li >
2025-05-26 16:01:10 +00:00
< li class = "toctree-l1" > < a class = "reference internal" href = "modules.html" > Classes and Modules< / a > < / li >
2025-05-22 12:51:20 +00:00
< / ul >
< / div >
< / div >
< / nav >
< section data-toggle = "wy-nav-shift" class = "wy-nav-content-wrap" > < nav class = "wy-nav-top" aria-label = "Mobile navigation menu" >
< i data-toggle = "wy-nav-top" class = "fa fa-bars" > < / i >
< a href = "#" > pyhoff< / a >
< / nav >
< div class = "wy-nav-content" >
< div class = "rst-content" >
< div role = "navigation" aria-label = "Page navigation" >
< ul class = "wy-breadcrumbs" >
< li > < a href = "#" class = "icon icon-home" aria-label = "Home" > < / a > < / li >
< li class = "breadcrumb-item active" > Pyhoff< / li >
< li class = "wy-breadcrumbs-aside" >
< a href = "_sources/index.md.txt" rel = "nofollow" > View page source< / a >
< / li >
< / ul >
< hr / >
< / div >
< div role = "main" class = "document" itemscope = "itemscope" itemtype = "http://schema.org/Article" >
< div itemprop = "articleBody" >
< div class = "toctree-wrapper compound" >
< p class = "caption" role = "heading" > < span class = "caption-text" > Contents:< / span > < / p >
< ul >
< li class = "toctree-l1" > < a class = "reference internal" href = "readme.html" > Pyhoff< / a > < ul >
< li class = "toctree-l2" > < a class = "reference internal" href = "readme.html#description" > Description< / a > < / li >
< li class = "toctree-l2" > < a class = "reference internal" href = "readme.html#installation" > Installation< / a > < / li >
< li class = "toctree-l2" > < a class = "reference internal" href = "readme.html#usage" > Usage< / a > < / li >
< li class = "toctree-l2" > < a class = "reference internal" href = "readme.html#contributing" > Contributing< / a > < / li >
< li class = "toctree-l2" > < a class = "reference internal" href = "readme.html#developer-guide" > Developer Guide< / a > < / li >
< li class = "toctree-l2" > < a class = "reference internal" href = "readme.html#license" > License< / a > < / li >
< / ul >
< / li >
2025-05-26 16:01:10 +00:00
< li class = "toctree-l1" > < a class = "reference internal" href = "modules.html" > Classes and Modules< / a > < ul >
2025-05-22 12:51:20 +00:00
< li class = "toctree-l2" > < a class = "reference internal" href = "modules.html#bus-coupler" > Bus coupler< / a > < / li >
< li class = "toctree-l2" > < a class = "reference internal" href = "modules.html#beckhoff-bus-terminals" > Beckhoff bus terminals< / a > < / li >
< li class = "toctree-l2" > < a class = "reference internal" href = "modules.html#wago-bus-terminals" > WAGO bus terminals< / a > < / li >
2025-05-26 16:01:10 +00:00
< li class = "toctree-l2" > < a class = "reference internal" href = "modules.html#generic-bus-terminals" > Generic bus terminals< / a > < / li >
2025-05-22 12:51:20 +00:00
< li class = "toctree-l2" > < a class = "reference internal" href = "modules.html#base-classes" > Base classes< / a > < / li >
< li class = "toctree-l2" > < a class = "reference internal" href = "modules.html#modbus" > Modbus< / a > < / li >
< / ul >
< / li >
< / ul >
< / div >
< section id = "pyhoff" >
< h1 > Pyhoff< a class = "headerlink" href = "#pyhoff" title = "Link to this heading" > < / a > < / h1 >
< section id = "description" >
< h2 > Description< a class = "headerlink" href = "#description" title = "Link to this heading" > < / a > < / h2 >
< p > The pyhoff package allows you to read and write the most common
Beckhoff and WAGO bus terminals (“Busklemmen”) using the Ethernet bus
coupler (“Busskoppler”) BK9000, BK9050, BK9100, or WAGO 750_352
over Ethernet TCP/IP based on ModBus TCP.< / p >
< section id = "key-features" >
< h3 > Key Features< a class = "headerlink" href = "#key-features" title = "Link to this heading" > < / a > < / h3 >
< ul class = "simple" >
< li > < p > Supports a wide range of Beckhoff and WAGO analog and digital bus
terminals.< / p > < / li >
< li > < p > Very lightweight: no dependencies; compact code base< / p > < / li >
< li > < p > Easy to extend< / p > < / li >
< li > < p > Using standardized ModBus TCP.< / p > < / li >
< li > < p > Provides high-level abstractions for reading and writing data
from/to IO-terminals with minimal code< / p > < / li >
< / ul >
< / section >
< section id = "usage-scenarios" >
< h3 > Usage Scenarios< a class = "headerlink" href = "#usage-scenarios" title = "Link to this heading" > < / a > < / h3 >
< ul class = "simple" >
< li > < p > Industrial test setups.< / p > < / li >
< li > < p > Research automation setups.< / p > < / li >
< li > < p > Data acquisition and monitoring.< / p > < / li >
< / ul >
< / section >
< / section >
< section id = "installation" >
< h2 > Installation< a class = "headerlink" href = "#installation" title = "Link to this heading" > < / a > < / h2 >
< p > The package has no additional decencies. It can be installed with pip:< / p >
< div class = "highlight-bash notranslate" > < div class = "highlight" > < pre > < span > < / span > pip< span class = "w" > < / span > install< span class = "w" > < / span > pyhoff
< / pre > < / div >
< / div >
< / section >
< section id = "usage" >
< h2 > Usage< a class = "headerlink" href = "#usage" title = "Link to this heading" > < / a > < / h2 >
< p > It is easy to use as the following example code shows:< / p >
< div class = "highlight-python notranslate" > < div class = "highlight" > < pre > < span > < / span > < span class = "kn" > from< / span > < span class = "w" > < / span > < span class = "nn" > pyhoff.devices< / span > < span class = "w" > < / span > < span class = "kn" > import< / span > < span class = "o" > *< / span >
< span class = "c1" > # connect to the BK9050 by tcp/ip on default port 502< / span >
< span class = "n" > bk< / span > < span class = "o" > =< / span > < span class = "n" > BK9050< / span > < span class = "p" > (< / span > < span class = "s2" > " 172.16.17.1" < / span > < span class = "p" > )< / span >
< span class = "c1" > # add all bus terminals connected to the bus coupler< / span >
< span class = "c1" > # in the order of the physical arrangement< / span >
< span class = "n" > bk< / span > < span class = "o" > .< / span > < span class = "n" > add_bus_terminals< / span > < span class = "p" > (< / span > < span class = "n" > KL2404< / span > < span class = "p" > ,< / span > < span class = "n" > KL2424< / span > < span class = "p" > ,< / span > < span class = "n" > KL9100< / span > < span class = "p" > ,< / span > < span class = "n" > KL1104< / span > < span class = "p" > ,< / span > < span class = "n" > KL3202< / span > < span class = "p" > ,< / span >
< span class = "n" > KL3202< / span > < span class = "p" > ,< / span > < span class = "n" > KL4002< / span > < span class = "p" > ,< / span > < span class = "n" > KL9188< / span > < span class = "p" > ,< / span > < span class = "n" > KL3054< / span > < span class = "p" > ,< / span > < span class = "n" > KL3214< / span > < span class = "p" > ,< / span >
< span class = "n" > KL4004< / span > < span class = "p" > ,< / span > < span class = "n" > KL9010< / span > < span class = "p" > )< / span >
< span class = "c1" > # Set 1. output of the first KL2404-type bus terminal to hi< / span >
< span class = "n" > bk< / span > < span class = "o" > .< / span > < span class = "n" > select< / span > < span class = "p" > (< / span > < span class = "n" > KL2404< / span > < span class = "p" > ,< / span > < span class = "mi" > 0< / span > < span class = "p" > )< / span > < span class = "o" > .< / span > < span class = "n" > write_coil< / span > < span class = "p" > (< / span > < span class = "mi" > 1< / span > < span class = "p" > ,< / span > < span class = "kc" > True< / span > < span class = "p" > )< / span >
< span class = "c1" > # read temperature from the 2. channel of the 2. KL3202-type< / span >
< span class = "c1" > # bus terminal< / span >
< span class = "n" > t< / span > < span class = "o" > =< / span > < span class = "n" > bk< / span > < span class = "o" > .< / span > < span class = "n" > select< / span > < span class = "p" > (< / span > < span class = "n" > KL3202< / span > < span class = "p" > ,< / span > < span class = "mi" > 1< / span > < span class = "p" > )< / span > < span class = "o" > .< / span > < span class = "n" > read_temperature< / span > < span class = "p" > (< / span > < span class = "mi" > 2< / span > < span class = "p" > )< / span >
< span class = "nb" > print< / span > < span class = "p" > (< / span > < span class = "sa" > f< / span > < span class = "s2" > " t = < / span > < span class = "si" > {< / span > < span class = "n" > t< / span > < span class = "si" > :< / span > < span class = "s2" > .1f< / span > < span class = "si" > }< / span > < span class = "s2" > °C" < / span > < span class = "p" > )< / span >
< span class = "c1" > # Set 1. output of the 1. KL4002-type bus terminal to 4.2 V< / span >
< span class = "n" > bk< / span > < span class = "o" > .< / span > < span class = "n" > select< / span > < span class = "p" > (< / span > < span class = "n" > KL4002< / span > < span class = "p" > ,< / span > < span class = "mi" > 0< / span > < span class = "p" > )< / span > < span class = "o" > .< / span > < span class = "n" > set_voltage< / span > < span class = "p" > (< / span > < span class = "mi" > 1< / span > < span class = "p" > ,< / span > < span class = "mf" > 4.2< / span > < span class = "p" > )< / span >
< / pre > < / div >
< / div >
< / section >
< section id = "contributing" >
< h2 > Contributing< a class = "headerlink" href = "#contributing" title = "Link to this heading" > < / a > < / h2 >
< p > Other analog and digital IO terminals are easy to complement. Contributions are welcome!
Please open an issue or submit a pull request on GitHub.< / p >
< / section >
< section id = "developer-guide" >
< h2 > Developer Guide< a class = "headerlink" href = "#developer-guide" title = "Link to this heading" > < / a > < / h2 >
< p > To get started with developing the < code class = "docutils literal notranslate" > < span class = "pre" > pyhoff< / span > < / code > package, follow these steps:< / p >
< ol class = "arabic" >
< li > < p > < strong > Clone the Repository< / strong >
First, clone the repository to your local machine using Git:< / p >
< div class = "highlight-bash notranslate" > < div class = "highlight" > < pre > < span > < / span > git< span class = "w" > < / span > clone< span class = "w" > < / span > https://github.com/Nonannet/pyhoff.git
< span class = "nb" > cd< / span > < span class = "w" > < / span > pyhoff
< / pre > < / div >
< / div >
< / li >
< li > < p > < strong > Set Up a Virtual Environment< / strong >
It is recommended to use a virtual environment to manage dependencies. You can create one using < code class = "docutils literal notranslate" > < span class = "pre" > venv< / span > < / code > :< / p >
< div class = "highlight-bash notranslate" > < div class = "highlight" > < pre > < span > < / span > python< span class = "w" > < / span > -m< span class = "w" > < / span > venv< span class = "w" > < / span > venv
< span class = "nb" > source< / span > < span class = "w" > < / span > venv/bin/activate< span class = "w" > < / span > < span class = "c1" > # On Windows use `venv\Scripts\activate`< / span >
< / pre > < / div >
< / div >
< / li >
< li > < p > < strong > Install Dev Dependencies< / strong >
Install pyhoff from source plus the dependencies required for development using < code class = "docutils literal notranslate" > < span class = "pre" > pip< / span > < / code > :< / p >
< div class = "highlight-bash notranslate" > < div class = "highlight" > < pre > < span > < / span > pip< span class = "w" > < / span > install< span class = "w" > < / span > -e< span class = "w" > < / span > .< span class = "o" > [< / span > dev< span class = "o" > ]< / span >
< / pre > < / div >
< / div >
< / li >
< li > < p > < strong > Run Tests< / strong >
Ensure that everything is set up correctly by running the tests:< / p >
< div class = "highlight-bash notranslate" > < div class = "highlight" > < pre > < span > < / span > pytest
< / pre > < / div >
< / div >
< / li >
< / ol >
< / section >
< section id = "license" >
< h2 > License< a class = "headerlink" href = "#license" title = "Link to this heading" > < / a > < / h2 >
2025-05-26 16:01:10 +00:00
< p > This project is licensed under the MIT License - see the < a class = "reference download internal" download = "" href = "_downloads/9879d6db96fd29134fc802214163b95a/LICENSE" > < span class = "xref download myst" > LICENSE< / span > < / a > file for details.< / p >
2025-05-22 12:51:20 +00:00
< / section >
< / section >
< / div >
< / div >
< footer > < div class = "rst-footer-buttons" role = "navigation" aria-label = "Footer" >
< a href = "readme.html" class = "btn btn-neutral float-right" title = "Pyhoff" accesskey = "n" rel = "next" > Next < span class = "fa fa-arrow-circle-right" aria-hidden = "true" > < / span > < / a >
< / div >
< hr / >
< div role = "contentinfo" >
< p > © Copyright 2025, Nicolas Kruse.< / p >
< / div >
Built with < a href = "https://www.sphinx-doc.org/" > Sphinx< / a > using a
< a href = "https://github.com/readthedocs/sphinx_rtd_theme" > theme< / a >
provided by < a href = "https://readthedocs.org" > Read the Docs< / a > .
< / footer >
< / div >
< / div >
< / section >
< / div >
< script >
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
< / script >
< / body >
< / html >