mirror of
https://github.com/gryf/linak-ctrl.git
synced 2026-04-25 16:01:31 +02:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3abdbfaa6a | |||
| ab18c7d90f | |||
| 4ae101603e | |||
| 13d2f008ad | |||
| 8793e55695 | |||
| 32b49bd278 | |||
| 9a33f742e1 |
@@ -0,0 +1,3 @@
|
||||
.venv
|
||||
*.egg-info
|
||||
build
|
||||
+33
-5
@@ -2,6 +2,9 @@
|
||||
Linak-ctrl
|
||||
==========
|
||||
|
||||
.. image:: https://badge.fury.io/py/linak-ctrl.svg
|
||||
:target: https://badge.fury.io/py/linak-ctrl
|
||||
|
||||
Simple python script to control Linak powered desks and USB2LIN06 cable.
|
||||
|
||||
|
||||
@@ -14,6 +17,31 @@ Requirements
|
||||
* `pyusb`_
|
||||
|
||||
|
||||
Installation
|
||||
============
|
||||
|
||||
There are couple of different ways for installing ``linak-ctrl``. One of the
|
||||
preferred ways is to use virtualenv and pip:
|
||||
|
||||
.. code:: shell-session
|
||||
|
||||
$ git clone https://github.com/gryf/linak-ctrl
|
||||
$ cd linak-ctrl
|
||||
linak-ctrl $ python -m venv linak
|
||||
(linak) linak-ctrl $ pip install .
|
||||
(linak) linak-ctrl $ linak-ctrl status
|
||||
Position: 767, height: 78.80cm, moving: False
|
||||
|
||||
Or, you can install it system-wide:
|
||||
|
||||
.. code:: shell-session
|
||||
|
||||
# sudo pip install linak-ctrl
|
||||
|
||||
And finally, you could also install dependences from your system repositories,
|
||||
and use script directly, by placing it somewhere in your ``$PATH``.
|
||||
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
@@ -24,7 +52,7 @@ number, and in centimeters, and information if desk is moving.
|
||||
|
||||
.. code:: shell-session
|
||||
|
||||
$ linak_ctrl.py status
|
||||
$ linak_ctrl/__init__.py status
|
||||
Position: 767, height: 78.80cm, moving: False
|
||||
|
||||
Note, that height was measured manually and may differ depending if desk have
|
||||
@@ -35,7 +63,7 @@ information from USB2LIN06 device every 0.2 seconds:
|
||||
|
||||
.. code:: shell-session
|
||||
|
||||
$ linak_ctrl.py status -l
|
||||
$ linak_ctrl/__init__.py status -l
|
||||
Position: 2161, height: 100.25cm, moving: True
|
||||
Position: 2109, height: 99.45cm, moving: True
|
||||
Position: 2026, height: 98.17cm, moving: True
|
||||
@@ -53,14 +81,14 @@ my case). For example:
|
||||
|
||||
.. code:: shell-session
|
||||
|
||||
$ linak_ctrl.py move 1000
|
||||
$ linak_ctrl/__init__.py move 1000
|
||||
|
||||
For displaying debug information verbosity can be increased using ``--verbose``
|
||||
parameter:
|
||||
|
||||
.. code:: shell-session
|
||||
|
||||
$ linak_ctrl.py -v move 1000
|
||||
$ linak_ctrl/__init__.py -v move 1000
|
||||
Current position: 771
|
||||
Current position: 792
|
||||
Current position: 825
|
||||
@@ -73,7 +101,7 @@ Adding more `-v` will increase amount of information:
|
||||
|
||||
.. code:: shell-session
|
||||
|
||||
$ linak_ctrl.py -vv move 1000
|
||||
$ linak_ctrl/__init__.py -vv move 1000
|
||||
array('B', [4, 56, 17, 8, 3, 3, 0, 57, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0])
|
||||
Current position: 771
|
||||
array('B', [4, 56, 17, 0, 21, 3, 0, 129, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0])
|
||||
|
||||
+9
-1
@@ -111,6 +111,10 @@ class LinakDevice:
|
||||
def __init__(self):
|
||||
self._dev = usb.core.find(idVendor=LinakDevice.VEND,
|
||||
idProduct=LinakDevice.PROD)
|
||||
if not self._dev:
|
||||
raise ValueError(f'Device {LinakDevice.VEND}:'
|
||||
f'{LinakDevice.PROD:04d} '
|
||||
f'not found!')
|
||||
|
||||
# detach kernel driver, if attached
|
||||
if self._dev.is_kernel_driver_active(0):
|
||||
@@ -188,7 +192,11 @@ class LinakDevice:
|
||||
|
||||
|
||||
def main():
|
||||
device = LinakDevice()
|
||||
try:
|
||||
device = LinakDevice()
|
||||
except ValueError as ex:
|
||||
sys.stderr.write(ex.args[0] + '\n')
|
||||
sys.exit(1)
|
||||
|
||||
parser = argparse.ArgumentParser('An utility to interact with USB2LIN06 '
|
||||
'device.')
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
[build-system]
|
||||
requires = ["setuptools >= 77.0"]
|
||||
build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "linak-ctrl"
|
||||
version = "1.0.5"
|
||||
requires-python = ">= 3.10"
|
||||
description = "Control Linak powered desks using USB2LIN06 cable."
|
||||
dependencies = [
|
||||
"pyusb>=1.3.1"
|
||||
]
|
||||
readme = "README.rst"
|
||||
authors = [
|
||||
{name = "Roman Dobosz", email = "gryf73@gmail.com"}
|
||||
]
|
||||
license = "BSD-3-Clause"
|
||||
classifiers = [
|
||||
"Development Status :: 5 - Production/Stable",
|
||||
"Environment :: Console",
|
||||
"Intended Audience :: End Users/Desktop",
|
||||
"Operating System :: POSIX :: Linux",
|
||||
"Programming Language :: Python",
|
||||
"Programming Language :: Python :: 3",
|
||||
"Programming Language :: Python :: 3.10",
|
||||
"Programming Language :: Python :: 3.11",
|
||||
"Programming Language :: Python :: 3.12",
|
||||
"Programming Language :: Python :: 3.13",
|
||||
"Topic :: System :: Networking"
|
||||
]
|
||||
|
||||
[tool.setuptools]
|
||||
py-modules = ["linak_ctrl"]
|
||||
|
||||
[project.urls]
|
||||
Repository = "https://github.com/gryf/linak-ctrl"
|
||||
|
||||
[project.scripts]
|
||||
linak-ctrl = "linak_ctrl:main"
|
||||
|
||||
[tool.distutils.bdist_wheel]
|
||||
universal = true
|
||||
@@ -1,2 +0,0 @@
|
||||
pbr
|
||||
pyusb>=1.1.1
|
||||
@@ -1,34 +0,0 @@
|
||||
[metadata]
|
||||
name = linak-ctrl
|
||||
summary = Control Linak powered desks using USB2LIN06 cable.
|
||||
description-file = README.rst
|
||||
author = Roman Dobosz
|
||||
author-email = gryf73@gmail.com
|
||||
home-page = https://gihtub.com/gryf/linak-ctrl
|
||||
license = BSD
|
||||
classifier =
|
||||
Development Status :: 5 - Production/Stable
|
||||
Environment :: Console
|
||||
Intended Audience :: End Users/Desktop
|
||||
License :: OSI Approved :: BSD License
|
||||
Operating System :: POSIX :: Linux
|
||||
Programming Language :: Python
|
||||
Programming Language :: Python :: 3
|
||||
Programming Language :: Python :: 3.7
|
||||
Programming Language :: Python :: 3.8
|
||||
Programming Language :: Python :: 3.9
|
||||
Topic :: System :: Networking
|
||||
|
||||
[install]
|
||||
record = install.log
|
||||
|
||||
[options.entry_points]
|
||||
console_scripts =
|
||||
linak-ctrl= linak_ctrl:main
|
||||
|
||||
[options]
|
||||
install_requires =
|
||||
pyusb
|
||||
|
||||
[bdist_wheel]
|
||||
universal = 1
|
||||
Reference in New Issue
Block a user