CAN Bus
The CAN bus interface allows you to decode traffic sent over the CAN transciever lines (tx/rx) or alternatively you can choose to decode the raw CAN differential lines. In order to decode the traffic a number of parameters need to be set based on your knowledge how the CAN bus should be operating.
Creating an CAN Bus
To create an CAN bus one of the following CAN nets needs to be instantiated: - TX - RX - CAN High (Physical CAN Signal) - CAN Low (Physical CAN SIgnal) - Differential (Physical CAN Signal measured with a differential probe)
from lager import Net, NetType, CAN
tx = Net.get('CAN.TX',
type=NetType.Logic,
setup_function=setup_nets,
teardown_function=teardown_nets)
can = CAN(tx=tx)
can.enable()
~ lager bus can --source CAN.TX --dut 1
Baud
This sets the assumed BAUD rate of the CAN bus being decoded.
from lager import Net, NetType, CAN
tx = Net.get('CAN.TX',
type=NetType.Logic,
setup_function=setup_nets,
teardown_function=teardown_nets)
can = CAN(tx=tx)
can.set_baud(50000)
~ lager bus can --baud 500000 --dut 1
Signal Type
This sets the CAN bus signal that is being decoded.
from lager import Net, NetType, CAN
tx = Net.get('CAN.TX',
type=NetType.Logic,
setup_function=setup_nets,
teardown_function=teardown_nets)
can = CAN(tx=tx)
can.set_signal_type_tx()
~ lager bus can --signal-type tx --dut 1
Signal Threshold
This sets the assumed voltage threshold a rising or falling CAN signal should pass through.
from lager import Net, NetType, CAN
can = Net.get('CAN.TX',
type=NetType.Logic,
setup_function=setup_nets,
teardown_function=teardown_nets)
can = CAN(scl=scl,sda=sda)
can.set_signal_threshold(1.5)
~ lager bus can --level 1.5 --dut 1