Skip to main content

A Python library for ThingSet functionality

Project description

Python ThingSet

To use from Python

To install

pip install python-thingset

To get a value

from python_thingset import ThingSet

with ThingSet(backend="can", can_bus="vcan0") as ts:
    response = ts.get(0xF03, 0x01)

    print(response)                             # 0x85 (CONTENT): native_posix
    print(f"0x{response.status_code:02X}")      # 0x85
    print(response.status_string)               # CONTENT
    print(response.data)                        # native_posix

    for v in response.values:
        print(v)                                # Build/rBoard (0xF03): native_posix
        print(v.name, f"0x{v.id:02X}", v.value) # Build/rBoard 0xF03 native_posix

To fetch multiple values

from python_thingset import ThingSet

with ThingSet(backend="can", can_bus="vcan0") as ts:
    response = ts.fetch(0xF, [0xF03, 0xF01], 0x01)

    print(response)                             # 0x85 (CONTENT): ['native_posix', '947c30f8']
    print(f"0x{response.status_code:02X}")      # 0x85
    print(response.status_string)               # CONTENT
    print(response.data)                        # ['native_posix', '947c30f8']

To fetch all child IDs of a parent

from python_thingset import ThingSet

with ThingSet(backend="can", can_bus="vcan0") as ts:
    response = ts.fetch(0xF, [], 0x01)

    print(response)                             # 0x85 (CONTENT): [3841, 3842, 3843, 3845, 3849]
    print(f"0x{response.status_code:02X}")      # 0x85
    print(response.status_string)               # CONTENT
    print(response.data)                        # [3841, 3842, 3843, 3845, 3849]

To execute a function

from python_thingset import ThingSet

with ThingSet(backend="can", can_bus="vcan0") as ts:
    response = ts.exec(0x20, ["some-text"], 0x1)

    print(response)                             # 0x84 (CHANGED): 0
    print(f"0x{response.status_code:02X}")      # 0x84
    print(response.status_string)               # CHANGED
    print(response.data)                        # 0

To update a value

from python_thingset import ThingSet

with ThingSet(backend="can", can_bus="vcan0") as ts:
    response = ts.update(0x4F, 1, 0x1, 0x0)

    print(response)                             # 0x84 (CHANGED): 0
    print(f"0x{response.status_code:02X}")      # 0x84
    print(response.status_string)               # CHANGED
    print(response.data)                        # 0

To use from terminal

Serial examples

thingset get SomeGroup -p /dev/pts/5
thingset get SomeGroup/rOneValue -p /dev/pts/5

thingset fetch SomeGroup -p /dev/pts/5
thingset fetch SomeGroup rOneValue rAnotherValue -p /dev/pts/5

thingset update sSomePersistedValue 3 -p /dev/pts/5
thingset update AnotherGroup/sPersistedValue 3 -p /dev/pts/5

thingset exec xSomeFunction aFunctionArgument -p /dev/pts/5
thingset exec AnotherGroup/xAnotherFunction -p /dev/pts/5
thingset exec AnotherGroup/xYetAnotherFunction 1.2 3.4 5.6 -p /dev/pts/5

thingset schema -p /dev/pts/5
thingset schema SomeGroup -p /dev/pts/5
thingset schema "" -p /dev/pts/5

CAN examples

thingset get f -c vcan0 -t 2f
thingset get f03 -c vcan0 -t 2f

thingset fetch f -c vcan0 -t 2f
thingset fetch f f01 f02 -c vcan0 -t 2f

thingset update 0 6f 3 -c vcan0 -t 2f

thingset exec 44 aFunctionArgument -c vcan0 -t 2f
thingset exec 55 -c vcan0 -t 2f
thingset exec 66 1.2 2.3 3.55 -c vcan0 -t 2f

thingset schema -c vcan0 -t 2f
thingset schema f -c vcan0 -t 2f

Socket examples

thingset get f -i 127.0.0.1
thingset get f03 -i 127.0.0.1

thingset fetch f -i 127.0.0.1
thingset fetch f f01 f02 -i 127.0.0.1

thingset update 0 6f 3 -i 127.0.0.1

thingset exec 44 aFunctionArgument -i 127.0.0.1
thingset exec 55 -i 127.0.0.1
thingset exec 66 1.2 2.3 3.55 -i 127.0.0.1

thingset schema -i 127.0.0.1
thingset schema f -i 127.0.0.1

To build

rm -rf dist/
python -m build
python -m twine upload --repository pypi dist/*

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

python_thingset-0.2.5.tar.gz (21.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

python_thingset-0.2.5-py3-none-any.whl (23.8 kB view details)

Uploaded Python 3

File details

Details for the file python_thingset-0.2.5.tar.gz.

File metadata

  • Download URL: python_thingset-0.2.5.tar.gz
  • Upload date:
  • Size: 21.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for python_thingset-0.2.5.tar.gz
Algorithm Hash digest
SHA256 1350098d1dc800effdccb15ede4f744e25cdc4cea81a2c5d1e88ddc7a2e4b8b5
MD5 f23ded489c46f1f29e725cc7a5c0c6f5
BLAKE2b-256 5b3c7273e79612e7747ce37b32164843f29bc53c9ebe529c0538f54be7b89457

See more details on using hashes here.

File details

Details for the file python_thingset-0.2.5-py3-none-any.whl.

File metadata

File hashes

Hashes for python_thingset-0.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 49e1b19f57c253ee09dae5a13bf15b28e0651dd2244e46f3080877b69664ecc4
MD5 4f3d72665f7cf38ca2211678e06e4eea
BLAKE2b-256 84f7e2cfd360bb3644db47b04a4ea99ee2973c65dd0240d36aaf27f9f71faaef

See more details on using hashes here.

Supported by

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