summaryrefslogtreecommitdiffstats
path: root/recipes-demo-hmi/radio
AgeCommit message (Expand)AuthorFilesLines
2019-09-09radio: Update default presets locationScott Murray1-10/+6
2019-01-06radio: Add libqtappfw to DEPENDSScott Murray1-1/+1
2018-09-07Change libhomescreen-2017 to libhomescreenflounder_5.99.6flounder/5.99.65.99.6zheng_wenlong1-1/+1
2018-07-27radio: remove useless dependency on pulseaudioRonan Le Martret1-1/+1
2017-11-22Use ROOT_HOME variable, not /home/rootJosé Bollo1-7/+7
2017-11-14Update app DEPENDS for new HMI frameworkScott Murray1-0/+1
2017-11-05Allow SRCREV handling through poky-agl.confeel_4.99.2eel/4.99.24.99.2Jan-Simon Möller1-2/+2
2017-09-06Add missing dependencyRonan Le Martret1-1/+1
2017-09-04agl-service-radio: add recipe for newly standalone bindingMatt Ranostay1-1/+3
2017-05-29Unpin after Daring Dab RC1Jan-Simon Moeller1-1/+0
2017-05-25Add a bbappend with pinnning for all packages with AUTOREVdab_3.99.1dab/3.99.13.99.1Jan-Simon Möller1-0/+1
2017-05-25radio: update recipe for switch to radio bindingScott Murray1-8/+4
2017-03-03Switch to split out demo appsScott Murray4-0/+83
eption */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
#!/usr/bin/env python3
# Copyright (c) 2022 Aakash Solanki, tech2aks@gmail.com
# Copyright (c) 2024 Scott Murray <scott.murray@konsulko.com>
#
# SPDX-License-Identifier: MIT

import sys
from pathlib import Path
import yaml
import asyncio
import concurrent.futures
from kuksa_client.grpc.aio import VSSClient
from kuksa_client.grpc import Datapoint
from systemd.daemon import notify

# Defaults
hostname = "localhost"
port = 55555
config_filename = "/etc/xdg/AGL/agl-vss-helper.yaml"
token_filename = "/etc/xdg/AGL/agl-vss-helper/agl-vss-helper.token"
ca_cert_filename = "/etc/kuksa-val/CA.pem"
tls_server_name = "localhost"
verbose = False

async def main():
    client = VSSClient(hostname,
                       port,
                       root_certificates=Path(ca_cert_filename),
                       tls_server_name=tls_server_name,
                       token=token,
                       ensure_startup_connection=True)
    await client.connect()
    print(f"Connected to KUKSA.val databroker at {hostname}:{port}")
    if "initialize" in config and isinstance(config["initialize"], list):
        for entry in config["initialize"]:
            if "signal" in entry and "value" in entry:
                if verbose:
                    print(f"Setting {entry['signal']} to {entry['value']}")
                await client.set_current_values({ entry["signal"] : Datapoint(entry["value"]) })

    notify("READY=1")

    if "mock" in config and isinstance(config["mock"], list):
        if len(config["mock"]) != 0:
            print(f"Mocking actuators:")
            for signal in config["mock"]:
                print(f"  {signal}")
            async for updates in client.subscribe_target_values(config["mock"]):
                for signal in updates:
                    if updates[signal] is not None:
                        if verbose:
                            print(f"Actuating {signal} to {updates[signal].value}")
                        await client.set_current_values({ signal : Datapoint(updates[signal].value) })


#
# Initialization
#

try:
    config_file = open(config_filename, "r")
    config = yaml.safe_load(config_file)
except yaml.YAMLError as exc:
    print(f"Could not parse configuration: ${exc}")
except:
    print(f"Could not read configuration")

if "verbose" in config and isinstance(config["verbose"], bool):
    verbose = config["verbose"]
if "hostname" in config and isinstance(config["hostname"], string):
    hostname = config["hostname"]
if "port" in config and isinstance(config["port"], int):
    port = config["port"]
if "use-tls" in config and isinstance(config["use-tls"], bool):
    use_tls = config["use-tls"]
if "token-file" in config and isinstance(config["token-file"], string):
    token_filename = config["token-file"]
if "ca-certificate" in config and isinstance(config["ca-certificate"], string):
    ca_cert_filename = config["ca-certificate"]

if token_filename != "":
    if verbose:
        print(f"Reading authorization token {token_filename}")
    token_file = open(token_filename, "r")
    token = token_file.read()
else:
    token = ""

print("Starting")
try:
    asyncio.run(main())
except KeyboardInterrupt:
    print("Exiting")

notify("STOPPING=1")
sys.exit(0)