-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
44 lines (34 loc) · 1.05 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import argparse
import impl.config as config
from ecu_template.ecu import ECU
from impl.can_handler import CanHandlerImpl
from impl.ecu_model import setup_ecu_model
from impl.uds_handler import UDSHandlerImpl
from impl.xcp_handler import XCPHandlerImpl
def loop(_ecu: ECU):
_ecu.start()
try:
while True:
pass
except KeyboardInterrupt:
print("Shutting down...")
_ecu.stop()
def main():
argparser = argparse.ArgumentParser()
argparser.add_argument("interface", default="vcan0", type=str, nargs="?")
argparser.add_argument("canfd", default=False, type=bool, nargs="?")
args = argparser.parse_args()
ecu_model = setup_ecu_model()
ecu = ECU(
interface=args.interface,
canfd=args.canfd,
can_handler=CanHandlerImpl(ecu_model),
uds_handler=UDSHandlerImpl(ecu_model),
uds_config=config.UDS,
can_filters=config.CAN_FILTERS,
xcp_handler=XCPHandlerImpl(ecu_model),
xcp_config=config.XCP,
)
loop(ecu)
if __name__ == "__main__":
main()