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)

create_can_bus.py
 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()
Create CAN Bus
~  lager bus can --source CAN.TX --dut 1

Baud

This sets the assumed BAUD rate of the CAN bus being decoded.

set_can_baud.py
 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)
Set CAN Bus BAUD
~  lager bus can --baud 500000 --dut 1

Signal Type

This sets the CAN bus signal that is being decoded.

set_can_signal_type.py
 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()
Set CAN Bus Signal Type
~  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.

set_can_threshold.py
 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)
Set CAN Bus Threshold
~  lager bus can --level 1.5 --dut 1