unpack
Unpack signal data from CAN message
Description
Examples
Unpack Data from a CAN Message
Unpack the data value from a CAN message.
Unpack a 16-bit integer value.
message = canMessage(500,false,8); pack(message,int16(1000),0,16,'LittleEndian') value = unpack(message,0,16,'LittleEndian','int16')
value = int16 1000
Unpack a 32-bit single value.
pack(message,single(-40),0,32,'LittleEndian') value = unpack(message,0,32,"LittleEndian",'single')
value = single -40
Unpack a 64-bit double value.
pack(message,3.14,0,64,'LittleEndian') value = unpack(message,0,64,'LittleEndian','double')
value = 3.1400
Input Arguments
message
— CAN message
CAN message object
CAN message, specified as a CAN message object, from which to unpack the data.
Example: canMessage
startbit
— Signal starting bit in data
single | double
Signal starting bit in the data, specified as a single or double value.
This is the least significant bit position in the signal data. Accepted
values for startbit
are from 0
through
63
, inclusive.
Example: 0
Data Types: single
| double
signalsize
— Length of signal in bits
numeric value
Length of the signal in bits, specified as a numeric value. Accepted
values for signalsize
are from 1
through 64
, inclusive.
Example: 16
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
byteorder
— Signal byte order format
'LittleEndian'
| 'BigEndian'
Signal byte order format, specified as 'LittleEndian'
or 'BigEndian'
.
Example: 'LittleEndian'
Data Types: char
| string
datatype
— Data type of unpacked value
char vector | string
Data type of unpacked value, specified as a character vector or string.
The supported values are 'uint8'
,
'int8'
, 'uint16'
,
'int16'
, 'uint32'
,
'int32'
, 'uint64'
,
'int64'
, 'single'
, and
'double'
.
Example: 'double'
Data Types: char
| string
Output Arguments
value
— Value of message data
numeric value
Value of message data, returned as a numeric value of the specified data type.
Version History
Introduced in R2009a
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.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: United States.
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- 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)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)