-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchannel_config.py
44 lines (30 loc) · 956 Bytes
/
channel_config.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 canlib.canlib as clb
def setUpChannel(channel: int = 0, openFlags=clb.Open.ACCEPT_VIRTUAL, outputControl=clb.Driver.NORMAL):
"""Function which initializes the CAN protocol
Args:
channel (int): Channel number. Defaults to 0.
openFlage (int): Accepts all input flags
outputControl (int): clb Output Control Drivers
Returns:
Channel Object: Initialized channel
"""
ch = clb.openChannel(channel, openFlags)
ch.setBusOutputControl(outputControl)
ch.busOn()
return ch
def tearDownChannel(ch):
"""Closes the CAN channel
Args:
ch: Channel Object
"""
ch.busOff()
ch.close()
def start_channel(channel_number: int):
"""Sets up channel
Args:
channel_number (int): Desired channel number
Returns:
Channel Object: Channel object with the desired channel number
"""
ch = setUpChannel(channel=channel_number)
return ch