enableCAN
Add-On Required: This feature requires the MATLAB Support Package for Raspberry Pi Hardware add-on.
Syntax
Description
enableCAN(
enables the
raspiObj
)can0
interface for MCP2515 CAN controller.
enableCAN(
.
Enables CAN interface for the specified device. The CAN controller can only be set
to raspiObj
,devicename
)MCP2515
. To disable CAN, use the disableCAN
function.
enableCAN(
enables the CAN object for the specified interface and device. To disable CAN, use
the raspiObj
,devicename
,interfacename
)disableCAN
function.
enableCAN(
enables
the CAN object when the interface name, device name, and oscillator frequency is
set. To disable CAN, use the raspiObj
,devicename
,interfacename
, oscillatorFrequency
)disableCAN
function.
enableCAN(
enables
the CAN object for the specified interrupt pin, interface, device, and oscillator
frequency. To disable CAN, use the raspiObj
,devicename
,interfacename
, oscillatorFrequency
,interruptPin
)disableCAN
function.
Examples
Enable CAN Object
Create a Raspberry Pi® object. The available CAN interfaces do not show until you enable the CAN object.
raspiObj = raspi("192.168.1.101","pi","raspberry")
raspiObj = raspi with properties: DeviceAddress: '192.168.1.101' Port: 18734 BoardName: 'Raspberry Pi 3 Model B+' AvailableLEDs: {'led0'} AvailableDigitalPins: [4,5,6,12,13,14,15,16,17,18,19, 20,21,22,23,24,25,26,27] AvailableSPIChannels: {'CE0','CE1'} AvailableI2CBuses: {'i2c-0','i2c-1'} AvailableWebcams: {} I2CBusSpeed: 100000 AvailableCANInterfaces: {} supported peripherals
Enable the CAN interface with default properties.
enableCAN(raspiObj)
SPI channels are inaccessible if you enable the CAN interface for
MCP2515
controllers. Reboot the Raspberry Pi to apply the
changes.
system(raspiObj, 'sudo reboot').
Connection to SSH server at 192.168.1.101
is terminated. Clear
the hardware communication object and re-create it to establish the connection.
clear raspiObj raspiObj = raspi("192.168.1.101","pi","raspberry")
A CAN object is enabled.
raspiObj = raspi with properties: DeviceAddress: '192.168.1.101' Port: 18734 BoardName: 'Raspberry Pi 3 Model B+' AvailableLEDs: {'led0'} AvailableDigitalPins: [4,5,6,10,12,13,14,15,16,17,18,19, 20,21,22,23,24,25,26,27] AvailableSPIChannels: {'CE1'} AvailableI2CBuses: {'i2c-0','i2c-1'} AvailableWebcams: {} I2CBusSpeed: 100000 AvailableCANInterfaces: {"can0"} Supported peripherals
Input Arguments
Version History
Introduced in R2021b
See Also
read
| write
| disableCAN
| canChannel