work with equipment over buses like Serial/i2c/... as client and server
Project description
bus_user (current v0.4.12/)
DESCRIPTION_SHORT
work with equipment over buses like Serial/i2c/... as client and server
DESCRIPTION_LONG
NOTE: IT SEEMS THIS IS OLD DATA! see tests for actual usage!
!. MOST APPROPRIATE COMMAND PROTOCOL other protocols mot recommended
- all cmds must be as params (preferred) in equipment or as special command
- [<CMD_NAME>] - read param value or run special command
[IDN] - read value IDN
[DUMP] - run special command - [<CMD_NAME> ] - write value in parameter or run special cmd with param
[VOUT 12.3] - set value into parameter VOUT - [<CMD_NAME> ?] - get available values to write into parameter
[MODE ?] - return [0 1 2 3] - all command sent must return answer
[OK] - if no value was asked [] - if asked some value, returned without measurement unit [FAIL] - any common not specified error [FAIL 0123] - any specified error without description [FAIL 02 VALUE OUT OF RANGE] - any specified error with description (full variant)
Features
- [SerialClient]:
- keep all found ports in base class!
- Serial:
- Client+Server
- connect with Type__AddressAutoAcceptVariant FIRST_FREE/FIRST_FREE__ANSWER_VALID
- set/get params by SlashOrSpacePath addressing
- handle BackSpace send manually from terminal
- SerialServer values:
- as Callable
- ValueUnit
- ValueVariants
- list_results
- SerialServer cmd:
- NONE is equivalent for SUCCESS
- no need params (like line_parsed as before)
- help - for show all variants (Units/Variants/Callables)!
License
See the LICENSE file for license rights and limitations (MIT).
Release history
See the HISTORY.md file for release history.
Installation
pip install bus-user
Import
from bus_user import *
USAGE EXAMPLES
See tests, sourcecode and docstrings for other examples.
1. example1.py
# NOTICE:
# 1. If bus cmd return several lines (DUMP for example) - you will get all of them in list!
# 2. All answers you will get as string and you must parse it by youself!
# errors will be get within it.
from bus_user import *
# SHOW (optional) COMMANDS EXPLICITLY by annotations without values!
# ------------------------------------------------------------------
class MySerialDevice(SerialClient):
IDN: Callable[[Any], TYPE__RW_ANSWER]
ADDR: Callable[[Any], TYPE__RW_ANSWER]
DUMP: Callable[[Any], TYPE__RW_ANSWER]
# USE in code
# -----------
dev = MySerialDevice()
if dev.connect():
answer1 = dev.IDN() # return answer for sent string in port "IDN"
answer2 = dev.VIN() # return answer for sent string in port "VIN"
answer3 = dev.VIN(12) # return answer for sent string in port "VIN 12"
answer4 = dev.VIN("12") # return answer for sent string in port "VIN 12"
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 Distribution
bus_user-0.4.12.tar.gz
(30.7 kB
view details)
Built Distribution
bus_user-0.4.12-py3-none-any.whl
(24.1 kB
view details)
File details
Details for the file bus_user-0.4.12.tar.gz
.
File metadata
- Download URL: bus_user-0.4.12.tar.gz
- Upload date:
- Size: 30.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2d2c5f161a7a2a1f2dc2b65f479499dbe804a53dba1678ab7f1b6ba14d818247 |
|
MD5 | c4c881e59fc89f8de7eb61f5a234ada0 |
|
BLAKE2b-256 | fda01fdf178e088a0e870422d477ba73a1170c074d8005721a2e48325074cd8d |
File details
Details for the file bus_user-0.4.12-py3-none-any.whl
.
File metadata
- Download URL: bus_user-0.4.12-py3-none-any.whl
- Upload date:
- Size: 24.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6aaa000b1ccc8f5d53a60054e29ffb4818e03e85e434fffb374d02667b635d44 |
|
MD5 | 797a2ebbc269026dadbf54469ebdb52f |
|
BLAKE2b-256 | 308724ce33947d1ac659a6a5e3526cb81a9cd98aa0d87265619b1c4fb56efe65 |