Skip to main content

work with equipment over buses like Serial/i2c/... as client and server

Project description

Ver/TestedPython Ver/Os
repo/Created Commit/Last Tests/GitHubWorkflowStatus Tests/GitHubWorkflowStatus
repo/Size Commit/Count/t Commit/Count/y Commit/Count/m

bus_user (current v0.4.15/Ver/Pypi Latest)

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

  1. all cmds must be as params (preferred) in equipment or as special command
  2. [<CMD_NAME>] - read param value or run special command
    [IDN] - read value IDN
    [DUMP] - run special command
  3. [<CMD_NAME> ] - write value in parameter or run special cmd with param
    [VOUT 12.3] - set value into parameter VOUT
  4. [<CMD_NAME> ?] - get available values to write into parameter
    [MODE ?] - return [0 1 2 3]
  5. 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

  1. [SerialClient]:
    • keep all found ports in base class!
  2. 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
  3. SerialServer values:
    • as Callable
    • ValueUnit
    • ValueVariants
    • list_results
  4. 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


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.15.tar.gz (31.4 kB view details)

Uploaded Source

Built Distribution

bus_user-0.4.15-py3-none-any.whl (24.7 kB view details)

Uploaded Python 3

File details

Details for the file bus_user-0.4.15.tar.gz.

File metadata

  • Download URL: bus_user-0.4.15.tar.gz
  • Upload date:
  • Size: 31.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for bus_user-0.4.15.tar.gz
Algorithm Hash digest
SHA256 0bad8917f37e0e0a21b5758eade4563d6c618f7984ab4276ea94d554be4139bd
MD5 6f970eacf88528fe778e160399c0e1c9
BLAKE2b-256 cae0cfc69e604bd0c30e95660fa07215594f6bf914e952d965d805ac863aa9e1

See more details on using hashes here.

File details

Details for the file bus_user-0.4.15-py3-none-any.whl.

File metadata

  • Download URL: bus_user-0.4.15-py3-none-any.whl
  • Upload date:
  • Size: 24.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for bus_user-0.4.15-py3-none-any.whl
Algorithm Hash digest
SHA256 04719889ceaddd22acefac5044bc55a0c04afef791568094af7ea979691b944d
MD5 9e2e7f1dc1bdb2e984cbaf115a9dbf54
BLAKE2b-256 bb805beee8efa7c977da3ed79d767b8601834d6d113e05b3008677bad0d0552d

See more details on using hashes here.

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