canChannel
Description
Use this object to create a connection to the CAN channel through the specified device connected to the Raspberry Pi® hardware. To transmit and receive data from Raspberry Pi hardware through the CAN bus, use the Object Functions.
Note
To generate C/C++ code for this object and its associated functions, you must have an Embedded Coder® license.
Creation
Syntax
Description
creates a CAN channel.ch = canChannel(raspiObj)
also specifies the channelName or
sets the BusSpeed and SilentMode
properties using one or more optional name-value arguments.ch = canChannel(raspiObj,device,Name=Value)
also specifies the channelName or
sets the BusSpeed and SilentMode
properties using one or more optional name-value arguments.ch = canChannel(raspiObj,interface,Name,Value)
Input Arguments
Name-Value Arguments
Properties
Object Functions
Use these object functions to transmit and receive messages from the CAN bus.
Examples
Tips
If you cannot create a
canChannelobject, thecanchannelobject creation fails, check if the CAN interface is connected to the internet.To check if the CAN interface is connected to the internet, type the following command in the MATLAB command window.
raspiObj.openShell
In the Raspberry Pi terminal, type this command.
$ ifconfig
You can check for
can0presence in all Raspberry Pi boards. ForPiCAN2 Duo, you can check ifcan1is in the output. If present, execute the following command in the Raspberry Pi terminal and then recreate thecanchannelobject in MATLAB.r.system(' sudo ip link set can0 down type can');To troubleshoot
PiCAN2,PiCAN2 Duo, andPiCAN3shields, see here.
Extended Capabilities
Version History
Introduced in R2021b