read
Description
reads a timetable of CAN messages equal to message = read(ch,numMessages)numMessages received on the
CAN channel ch.
Note
To generate C/C++ code for this function, you must have an Embedded Coder® license.
Examples
Create a Raspberry Pi® object.
raspiObj = raspi("192.168.1.101","pi","raspberry");
Create a canChannel object.
ch = canChannel(raspiObj,"can0");
Read messages as a timetable.
read(ch)
ans =
1×7 timetable
Time ID Extended Name Data Length Signals Error
____________________ ___ ________ __________ ___________________ ______ ____________ _____
08-Apr-2021 11:36:32 291 false {0×0 char} {[0 1 2 3 4 5 6 7]} 8 {0×0 struct} falseCreate a Raspberry Pi object.
raspiObj = raspi("192.168.1.101","pi","raspberry");
Create a canChannel object.
ch = canChannel(raspiObj,"can0")Specify the length of message to read.
read(ch,5)
ans =
5×7 timetable
Time ID Extended Name Data Length Signals Error
____________________ ____ ________ __________ ___________________ ______ ____________ _____
08-Apr-2021 11:37:42 291 false {0×0 char} {[0 1 2 3 4 5 6 7]} 8 {0×0 struct} false
08-Apr-2021 11:37:42 1110 true {0×0 char} {[7 6 5 4 3 2 1 0]} 8 {0×0 struct} false
08-Apr-2021 11:37:42 291 false {0×0 char} {[0 1 2 3 4 5 6 7]} 8 {0×0 struct} false
08-Apr-2021 11:37:42 1110 true {0×0 char} {[7 6 5 4 3 2 1 0]} 8 {0×0 struct} false
08-Apr-2021 11:37:42 291 false {0×0 char} {[0 1 2 3 4 5 6 7]} 8 {0×0 struct} false
Create a Raspberry Pi object.
raspiObj = raspi("192.168.1.101","pi","raspberry");
Create a canChannel object.
ch = canChannel(raspiObj,"can0")ch = Channel with properties: Interface: 'can0' ProtocolMode: 'CAN' BusSpeed: 500000 SilentMode: 0 Database: [] Show all properties
Attach a database.
ch.Database = canDatabase('test.dbc')
ch = Channel with properties: Interface: 'can0' ProtocolMode: 'CAN' BusSpeed: 500000 SilentMode: 0 Database: [1×1 can.Database] Show all properties
Read the can channel object.
read(ch,5)
ans =
5×8 timetable
Time ID Extended Name Data Length Signals Error Remote
____________________ ____ ________ _______________________ ___________________ ______ ____________ _____ ______
08-Apr-2021 11:39:24 291 false {'StandardTestMessage'} {[0 1 2 3 4 5 6 7]} 8 {1×1 struct} false false
08-Apr-2021 11:39:24 1110 true {'ExtendedTestMessage'} {[7 6 5 4 3 2 1 0]} 8 {1×1 struct} false false
08-Apr-2021 11:39:24 291 false {'StandardTestMessage'} {[0 1 2 3 4 5 6 7]} 8 {1×1 struct} false false
08-Apr-2021 11:39:24 1110 true {'ExtendedTestMessage'} {[7 6 5 4 3 2 1 0]} 8 {1×1 struct} false false
08-Apr-2021 11:39:24 291 false {'StandardTestMessage'} {[0 1 2 3 4 5 6 7]} 8 {1×1 struct} false false Input Arguments
Connection to the CAN channel, specified as an object.
Maximum number of messages to read, specified as a positive numeric value. The
maximum value of numMessages is 255.
Data Types: numeric
Output Arguments
CAN messages from the channel, returned as a timetable of messages. If you have the
Vehicle Network Toolbox™ the message output contains additional information about CAN messages. If
you use the Database property, the Name and
Signals information of messages will also be filled.
Note
The message does not support Remote frames.
Extended Capabilities
To generate C/C++ code for this function, you must have an Embedded Coder license. For more information on selecting the right product stack according to your development goals, see Product Stack for Raspberry Pi Blockset.
Version History
Introduced in R2021b
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Seleziona un sito web
Seleziona un sito web per visualizzare contenuto tradotto dove disponibile e vedere eventi e offerte locali. In base alla tua area geografica, ti consigliamo di selezionare: .
Puoi anche selezionare un sito web dal seguente elenco:
Come ottenere le migliori prestazioni del sito
Per ottenere le migliori prestazioni del sito, seleziona il sito cinese (in cinese o in inglese). I siti MathWorks per gli altri paesi non sono ottimizzati per essere visitati dalla tua area geografica.
Americhe
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)