Main Content

canFDChannel

Construct CAN FD channel connected to specified device

Description

canch = canFDChannel(vendor,device,chanindex) returns a CAN FD channel connected to a device from a specified vendor.

For Kvaser and Vector products, device is a character vector or string that combines the device model and a device index in the same argument, such as 'VN1610 1' or 'VN1610 2' to distinguish one device from another. You can also choose among two MathWorks® virtual devices, each with two virtual channels.

example

canch = canFDChannel(vendor,device) returns a CAN FD channel connected to a National Instruments™ or PEAK-System device.

For National Instruments, vendor is the character vector 'NI', and the devicenumber is the interface number defined in the NI Measurement & Automation Explorer.

For PEAK-System devices vendor is the character vector 'PEAK-System', and devicenumber is the device number defined for the channel.

example

Examples

collapse all

Create CAN FD channels for each of several vendors.

ch1 = canFDChannel('Vector','VN1610 1',1);
ch2 = canFDChannel('Kvaser','USBcan Pro 1',1);
ch3 = canFDChannel('NI','CAN0');
ch4 = canFDChannel('PEAK-System','PCAN_USBBUS1');
ch5 = canFDChannel('SocketCAN','can0')
ch6 = canFDChannel('MathWorks','Virtual 1',1)
ch6 = 

  Channel with properties:

   Device Information
            DeviceVendor: 'MathWorks'
                  Device: 'Virtual 1'
      DeviceChannelIndex: 1
      DeviceSerialNumber: 0
            ProtocolMode: 'CAN FD'

   Status Information
                 Running: 0
       MessagesAvailable: 0
        MessagesReceived: 0
     MessagesTransmitted: 0
    InitializationAccess: 1
        InitialTimestamp: [0×0 datetime]
           FilterHistory: 'Standard ID Filter: Allow All | Extended ID Filter: Allow All'

   Bit Timing Information
               BusStatus: 'N/A'
              SilentMode: 0
         TransceiverName: 'N/A'
        TransceiverState: 'N/A'
       ReceiveErrorCount: 0
      TransmitErrorCount: 0
     ArbitrationBusSpeed: []
            DataBusSpeed: []

   Other Information
                Database: []
                UserData: []

Input Arguments

collapse all

CAN device vendor, specified as 'MathWorks', 'Kvaser', 'NI', 'PEAK-System', 'SocketCAN', or 'Vector'.

Example: 'MathWorks'

Data Types: char | string

CAN FD device to connect channel to, specified as a character vector or string. Valid values depend on the specified vendor.

Example: 'Virtual 1'

Data Types: char | string

CAN FD device channel port or index, specified as a numeric value.

Example: 1

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Output Arguments

collapse all

CAN FD device channel, returned as a can.Channel object, with can.Channel Properties.

Tips

  • Use canFDChannelList to obtain a list of available device channels.

  • You cannot have more than one CAN FD channel configured on the same NI-XNET or PEAK-System device channel.

  • You cannot use the same variable to create multiple channels sequentially. Clear any channel in use before using the same variable to construct a new channel object.

  • You cannot create arrays of channel objects. Each object you create must exist as its own individual variable.

Version History

Introduced in R2018b