winIDEA SDK
fnet_lin.py
1# This script is licensed under BSD License, see file LICENSE.txt.
2#
3# (c) TASKING Germany GmbH, 2023
4
5"""
6This example shows basic FNet LIN controller initialization and usage.
7
8(c) iSYSTEM Labs, 2022
9"""
10import isystem.connect as ic
11
12winidea_id = ''
13
14
15try:
16 # connect to last winIDEA
17 connMgr = ic.ConnectionMgr()
18 connMgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
19
20 # initialize FNet LIN Controller
21 SessionCtrl = ic.CSessionCtrl(connMgr)
22 FNetCtrl = ic.CFNetCtrl(connMgr)
23 LINCtrl = FNetCtrl.LIN('CAN/LIN.LIN1')
24
25
26
27 optLINCfg = LINCtrl.cfg()
28 optLINCfg.reset()
29
30 optLINCfg.set_baudrate_bps(9600)
31
32 # configure the network
33 optNetworkCfg = optLINCfg.opt_network()
34 optNetworkCfg.set_name('Windows')
35 optNetworkCfg.add_description_file('Windows.ldf')
36
37
38
39 SessionCtrl.end() #end first for cfg to take effect
40 SessionCtrl.begin_prepare()
41
42
43
44 # use FNetTrigger 5 in the example
45 FTrig = 5
46
47 optLINOp = LINCtrl.op()
48 # qualifier - starts on FTrig, not enabled from start
49 LINCtrl.op_qualifier_enable(FTrig)
50 LINCtrl.op_qualifier_enable_on_start(False)
51
52 # don't record all received messages
53 optLINOp.set_record_all(False)
54 # configure Wake_up comparator in one call
55 optLINOp.set_wake_up(bRecord = True, nFTrig = FTrig)
56 # configure comparator in one call
57 optLINOp.set_comparator(nComparator = 0, bRecord = True, nFTrig = FTrig, nID = 0x7, nMask = 0xf)
58
59 # configure comparator 1 individually (JU) delay impl to later time
60# optComparator = optLINOp.opt_comparator(1)
61# optComparator.set_record(True) # record when matching
62# optComparator.set_FTrig(FTrig) # generate this trigger
63# optComparator.set_ID(12)
64# optComparator.set_mask(0xff)
65
66 # apply new operation settings and restart operation
67 FNetCtrl.op_apply()
68
69except Exception as ex:
70 print(ex)