Package: kuksa-viss-client
Kuksa VISS Clientkuksa.valis a part of the opensource projecteclipse kuksa.
More aboutkuksa.valcan be found in therepository.Introductionkuksa_viss_clientis a command-line test client which can be used to interact with theKUKSA val serverInstalling and Starting the clientThe fastest way to start using the kuksa-viss-client is to install a pre-built version with pip.
Instructions on how to build and run locally can be found further down in this document.pip install kuksa-viss-clientAfter you have installed the kuksa-viss-client package via pip you can run the test client directly by executing$kuksa_viss_clientIf everything works as expected and the server can be contacted you will get an output similar to below.Welcometokuksavissclientversion<some_version>`-:+o/shhhs+:`./oo/+o/``.-:ohhs-`/o+-/o/`..:yho`+o//o/ohoohy`:o+/o/`+hh.sh++o:/oo+o+`/hy+o:/o+/oo-+hs.oo`oho`oo-.hh::oo.oho-+:-hh/.+o+-`oho`:shy-./o/ohy//+oyhho-`-/+oo+/:.Defaulttokensdirectory:/some/path/kuksa_certificates/jwt

connectjtowss://127.0.0.1:8090
Websocketconnectedsecurely.
TestClient>The next step is to authorize against the server.
The jwt tokens for testing can either be found underkuksa_certificates/jwtor you can also use following command insidekuksa_viss_clientto find the viapipinstalled certificate directory.TestClient>printTokenDirSelect one of the tokens and use theauthorizecommand like below.TestClient>authorize/some/path/kuksa_certificates/jwt/super-admin.json.tokenUsage InstructionsRefer help for further informationVSS Client> help -v

Documented commands (use 'help -v' for verbose/'help <topic>' for details):

Communication Set-up Commands
================================================================================
authorize           Authorize the client to interact with the server
connect             
disconnect          Disconnect from the VSS Server
getServerAddress    Gets the IP Address for the VSS Server
setServerAddress    Sets the IP Address for the VSS Server

Info Commands
================================================================================
info                Show summary info of the client
printTokenDir       Show token directory
version             Show version of the client

Kuksa Interaction Commands
================================================================================
getMetaData         Get MetaData of the path
getValue            Get the value of a path
setValue            Set the value of a path
updateMetaData      Update MetaData of a given path
updateVISSTree      Update VISS Tree EntryThis is an example showing how some of the commands can be used:Updating VSS StructureUsing the testclient, it is also possible to update and extend the VSS data structure. More details can be foundhere.Note: You can also usesetValueto change the value of an array, but the value should not contains any non-quoted spaces. Consider the following examples:Test Client> setValue Vehicle.OBD.DTCList ["dtc1","dtc2"]
{
    "action": "set", 
    "requestId": "f7b199ce-4d86-4759-8d9a-d6f8f935722d", 
    "ts": "2022-03-22T17:19:34.1647965974Z"
}

Test Client> setValue Vehicle.OBD.DTCList '["dtc1", "dtc2"]'
{
    "action": "set", 
    "requestId": "d4a19322-67d8-4fad-aa8a-2336404414be", 
    "ts": "2022-03-22T17:19:44.1647965984Z"
}

Test Client> setValue Vehicle.OBD.DTCList ["dtc1", "dtc2"]
usage: setValue [-h] Path Value
setValue: error: unrecognized arguments: dtc2 ]Building and Running a local versionFor development purposes it may be necessary to customize the code for the client and run a locally built version.
The commands below can be used for that purpose. this will assure that local*.pyfiles will be used when running the client.cdkuksa_viss_client
pipenvshell
pipenvlock
pipenvsync
python__main.py__After testing you can usequitto exit the client andexitto exit the pipenv shell. In subsequent runs some parts can be skipped:cdkuksa_viss_client
pipenvshell
python__main.py__Using DockerYou can build a docker image of the testclient using theDockerfile. Not the most effcient way to pack a small python script, but it is easy to get started. The Dockerfile needs to be executed on the parent directory (so it include the needed certificates andpippackage configuration).cd/some/dir/kuksa.val
dockerbuild-fkuksa_viss_client/Dockerfile-tkuksa-client:latest.To run the builded image:docker run --rm -it --net=host kuksa-client:latest--rmensures we do not keep the docker continer lying aroind after closing the vss-testclient and--net=hostmakes sure you can reach locally running kuksa.val-server or kuksa-val docker with port forwarding on the host using the default127.0.0.1address.Python SDKIf you would like to develop your ownkuksa.valclient,
you can use the python sdk to interact with thekuksa.valserver in a very easy way.Usageimport the sdk>>> import kuksa_viss_client
>>> kuksa_viss_client.__version__
'<your version, e.g. 0.1.7>'Setup a thread to connect with thekuksa.valserver.
The following properties for the connection can be configured:ipdefault: "127.0.0.1"portdefault: 8090insecuredefault:Falsecacertificatedefault: "../kuksa_certificates/CA.pem"certificatedefault: "../kuksa_certificates/Client.pem"keydefault: "../kuksa_certificates/Client.key">>> config = {} 
>>> client = kuksa_viss_client.KuksaClientThread(config)
>>> 
>>> # Start the client thread to connect with configured server
>>> client.start()
>>>
>>> # Close the connection and stop the client thread
>>> client.stop()You have the following methods to interact with thekuksa.valserver:# Do authorization by passing a jwt token or a token file
def authorize(self, token, timeout = 2)

# Update VISS Tree Entry 
def updateVISSTree(self, jsonStr, timeout = 5)

# Update Meta Data of a given path
def updateMetaData(self, path, jsonStr, timeout = 5)

# Get Meta Data of a given path
def getMetaData(self, path, timeout = 1)

# Set value to a given path
def setValue(self, path, value, timeout = 1)

# Get value to a given path
def getValue(self, path, timeout = 5)

# Subscribe value changes of to a given path.
# The given callback function will be called then, if the given path is updated:
#   updateMessage = await webSocket.recv()
#   callback(updateMessage)
def subscribe(self, path, callback, timeout = 5)