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.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- 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)