simple_can_simulator: support different interface for LIN messages 41/27741/2
authorScott Murray <scott.murray@konsulko.com>
Tue, 7 Jun 2022 20:25:40 +0000 (16:25 -0400)
committerScott Murray <scott.murray@konsulko.com>
Wed, 6 Jul 2022 18:32:43 +0000 (14:32 -0400)
Add a "--lin-interface" option to simple_can_simulator.py to allow
specifying a different CAN interface for the cruise control LIN
messages from the steering wheel in the demo setup.  This allows
pointing at the sllin0 interface in the full demo setup that is
configured with the agl-demo-preload feature.  Previously the
CAN messages for the LIN events were bridged to the primary CAN
interface, but this has proven unreliable in practice.

Bug-AGL: SPEC-4431

Signed-off-by: Scott Murray <scott.murray@konsulko.com>
Change-Id: I1bb0e429b849ed1e25cbd9ee8fb887e973d33081

recipes-demo/simple-can-simulator/files/simple_can_simulator.py

index 83f8870..3d6c85d 100755 (executable)
@@ -350,13 +350,18 @@ class StatusMessageSender(object):
 def main():
     parser = argparse.ArgumentParser(description='Simple CAN vehicle simulator.')
     parser.add_argument('interface', type=str, help='interface name (e.g. vcan0)')
+    parser.add_argument('--lin-interface', help='Separate LIN interface name (e.g. sllin0)')
     parser.add_argument('-v', '--verbose', help='increase output verbosity', action='store_true')
     args = parser.parse_args()
 
+    lin_interface = args.lin_interface
+    if lin_interface == None:
+        lin_interface = args.interface
+
     try:
         can_sock = CANSocket(args.interface)
         diag_can_sock = CANSocket(args.interface)
-        steeringwheel_can_sock = CANSocket(args.interface)
+        steeringwheel_can_sock = CANSocket(lin_interface)
     except OSError as e:
         sys.stderr.write('Could not listen on interface {0}\n'.format(args.interface))
         sys.exit(e.errno)