Upgrade KUKSA.val components to 0.4.0 releases
[AGL/meta-agl-demo.git] / recipes-connectivity / kuksa-val / kuksa-dbc-feeder / 0002-dbc2val-usability-improvements.patch
1 From b217a746ef7b92291320e4c1a66b52df0318495f Mon Sep 17 00:00:00 2001
2 From: Scott Murray <scott.murray@konsulko.com>
3 Date: Sat, 5 Aug 2023 13:58:16 -0400
4 Subject: [PATCH 2/3] dbc2val: usability improvements
5
6 Changes:
7 - Tweaked default configuration file search path to better match
8   Linux FHS and kuksa-val-server.  First look for a config.ini in
9   /etc/kuksa-dbc-feeder, then /etc/dbc_feeder.ini.
10 - Add catching of exceptions around CAN device opening so that the
11   script can exit cleanly with an error message if the device is
12   not available.
13 - Fixed shutdown behavior with some tweaks to actually stop the
14   reader and KUKSA.val client library threads.  This makes the
15   script actually exit on SIGTERM as opposed to hanging.
16
17 Upstream-Status: pending
18
19 Signed-off-by: Scott Murray <scott.murray@konsulko.com>
20
21 ---
22  dbc2val/dbcfeeder.py | 15 +++++++++++++--
23  1 file changed, 13 insertions(+), 2 deletions(-)
24
25 diff --git a/dbc2val/dbcfeeder.py b/dbc2val/dbcfeeder.py
26 index 966dba7..e7fd319 100755
27 --- a/dbc2val/dbcfeeder.py
28 +++ b/dbc2val/dbcfeeder.py
29 @@ -188,7 +188,11 @@ class Feeder:
30  
31                  # use socketCAN
32                  log.info("Using socket CAN device '%s'", canport)
33 +            try:
34                  self._reader.start_listening(bustype="socketcan", channel=canport)
35 +            except:
36 +                log.error("Could not open {}, exiting".format(canport))
37 +                sys.exit(-1)
38  
39              receiver = threading.Thread(target=self._run_receiver)
40              receiver.start()
41 @@ -212,6 +216,11 @@ class Feeder:
42                  threads.append(transmitter)
43          else:
44              log.info("No val2dbc mappings found or val2dbc disabled!!")
45 +
46 +        # Spin so signal handlers will work
47 +        while not self._shutdown:
48 +            time.sleep(0.1)
49 +
50          # Wait for all of them to finish
51          for thread in threads:
52              thread.join()
53 @@ -363,8 +372,10 @@ def parse_config(filename):
54          configfile = filename
55      else:
56          config_candidates = [
57 -            "/config/dbc_feeder.ini",
58 +            "/etc/kuksa-dbc-feeder/config.ini",
59 +            "/etc/kuksa-dbc-feeder/dbc_feeder.ini",
60              "/etc/dbc_feeder.ini",
61 +            "/config/dbc_feeder.ini",
62              "config/dbc_feeder.ini",
63          ]
64          for candidate in config_candidates:
65 @@ -577,7 +588,7 @@ def main(argv):
66      elif "can" in config and "dbc_default_file" in config["can"]:
67          dbc_default = config["can"]["dbc_default_file"]
68      else:
69 -        dbc_default = "dbc_default_values.json"
70 +        dbc_default = ""
71  
72      if args.dbc2val:
73          use_dbc2val = True
74 -- 
75 2.41.0
76