Home | History | Annotate | Download | only in automotive
      1 <html devsite>
      2   <head>
      3     <title>Vehicle Properties</title>
      4     <meta name="project_path" value="/_project.yaml" />
      5     <meta name="book_path" value="/_book.yaml" />
      6   </head>
      7   <body>
      8   <!--
      9       Copyright 2017 The Android Open Source Project
     10 
     11       Licensed under the Apache License, Version 2.0 (the "License");
     12       you may not use this file except in compliance with the License.
     13       You may obtain a copy of the License at
     14 
     15           http://www.apache.org/licenses/LICENSE-2.0
     16 
     17       Unless required by applicable law or agreed to in writing, software
     18       distributed under the License is distributed on an "AS IS" BASIS,
     19       WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     20       See the License for the specific language governing permissions and
     21       limitations under the License.
     22   -->
     23 
     24 
     25 <p>The vehicle HAL interface defines the properties OEMs can implement and
     26 contains property metadata (for example, whether the property is an int and
     27 which change modes are allowed). The vehicle HAL interface is based on accessing
     28 (read, write, subscribe) a property, which is an abstraction for a specific
     29 function.</p>
     30 
     31 <h2 id=interfaces>HAL interfaces</h2>
     32 <p>The vehicle HAL uses the following interfaces:</p>
     33 <ul>
     34 <li><code>vehicle_prop_config_t const *(*list_properties)(..., int*
     35 num_properties)</code>
     36 <br>List configuration of all properties supported by the vehicle HAL. Only
     37 supported properties are used by vehicle network service.
     38 </li>
     39 <li><code>(*get)(..., vehicle_prop_value_t *data)</code>
     40 <br>Read the current value of the property. For zoned property, each zone may
     41 have different value.</li>
     42 <li><code>(*set)(..., const vehicle_prop_value_t *data)</code>
     43 <br>Write a value to property. Result of write is defined per property.</li>
     44 <li><code>(*subscribe)(..., int32_t prop, float sample_rate, int32_t
     45 zones)</code>
     46 <ul>
     47 <li>Start monitoring a property value change. For zoned property, subscription
     48 applies to requested zones. Zones = 0 is used to request all zones supported.
     49 </li>
     50 <li>Vehicle HAL should call separate callback when the property's value changes
     51 (=on change) or in const interval (=continuous type).</li>
     52 </ul></li>
     53 <li><code>(*release_memory_from_get)(struct vehicle_hw_device* device,
     54 vehicle_prop_value_t *data)</code>
     55 <br>Release memory allocated from get call.</li>
     56 </ul>
     57 
     58 <p>The vehicle HAL uses the following callback interfaces:</p>
     59 <ul>
     60 <li><code>(*vehicle_event_callback_fn)(const vehicle_prop_value_t
     61 *event_data)</code>
     62 <br>Notifies vehicle property's value change. Should be done only for
     63 subscribed properties.</li>
     64 <li><code>(*vehicle_error_callback_fn)(int32_t error_code, int32_t property,
     65 int32_t operation)</code>
     66 <br>Return global vehicle HAL level error or error per property. Global error
     67 causes HAL restart, which can lead to restarting other components (including
     68 applications).</li>
     69 </ul>
     70 
     71 <h2 id=properties>Vehicle properties</h2>
     72 <p>Properties can be read-only, write-only (used to pass information to vehicle
     73 HAL level), or read and write (support of most properties is optional). Each
     74 property is uniquely identified by an int32 key and has a predefined type
     75 (<code>value_type</code>):</p>
     76 
     77 <ul>
     78 <li><code>INT32</code> (and array), <code>INT64</code>, <code>BOOLEAN</code>,
     79 <code>FLOAT</code> (and array), string, bytes.</li>
     80 <li>Zoned type has zone in addition to value.</li>
     81 </ul>
     82 
     83 <h2 id-=zone_type>Zone types</h2>
     84 <p>The vehicle HAL defines three zone types:</p>
     85 <ul>
     86 <li><code>vehicle_zone</code>
     87 <br>Zone based on rows.</li>
     88 <li><code>vehicle_seat</code>
     89 <br>Zone based on seats.</li>
     90 <li><code>vehicle_window</code>
     91 <br>Zone based on windows.</li>
     92 </ul>
     93 <p>Each zoned property should use pre-defined zone type. If necessary, you can
     94 use a custom zone type for each property (for details, see
     95 <a href=#prop_custom>Handling custom properties</a>).</p>
     96 
     97 <h2 id=prop_config>Configuring a property</h2>
     98 <p>Use <code>vehicle_prop_config_t</code> to provide configuration information
     99 for each property. Information includes:</p>
    100 <ul>
    101 <li><code>access</code> (r, w, rw)</li>
    102 <li><code>change_mode</code> (represents how property is monitored: on change vs
    103 continuous)</li>
    104 <li><code>min_value</code> (int32, float, int64), <code>max_value</code> (int32,
    105 float, int64)</li>
    106 <li><code>min_sample_rate</code>, <code>max_sample_rate</code></li>
    107 <li><code>permission_model</code></li>
    108 <li><code>prop</code> (Property ID, int)</li>
    109 <li><code>value_type</code></li>
    110 <li><code>zone_flags</code> (represents supported zones as bit flags)</li>
    111 </ul>
    112 <p>In addition, some properties have specific configuration flags to represent
    113 capability.</p>
    114 
    115 <h2 id=zone_prop>Handling zone properties</h2>
    116 <p>A zoned property is equivalent to a collection of multiple properties where
    117 each sub property is accessible by specified zone value.</p>
    118 <ul>
    119 <li><code>get</code> call for zoned property always includes zone in request, so
    120 only the current value for the requested zone should be returned.</li>
    121 <li><code>set</code> call for zoned property always includes zone in request, so
    122 only the requested zone should be changed.</li>
    123 <li><code>subscribe</code> call includes flags of all zones subscribed. Events
    124 from un-subscribed zones should not be reported.</li>
    125 </ul>
    126 
    127 <h3 id=get>Get calls</h3>
    128 <p>During initialization, the value for the property may not be available yet as
    129 the matching vehicle network message has not yet been received. In such cases,
    130 the <code>get</code> call should return <code>-EAGAIN</code>. Some properties
    131 (such as HVAC) have separate on/off power property. Calling <code>get</code> for
    132 such a property (when powered off) should return a special value
    133 <code>(VEHICLE_INT_OUT_OF_RANGE_OFF/VEHICLE_FLOAT_OUT_OF_RANGE_OFF)</code>
    134 rather than returning an error.</p>
    135 <p>In addition, some properties (such as HVAC temperature) can have a value to
    136 indicate it is in max power mode rather than in specific temperature value. In
    137 such cases, use special values to represent such state.</p>
    138 <ul>
    139 <li>VEHICLE_INT_OUT_OF_RANGE_MAX/MIN</li>
    140 <li>VEHICLE_FLOAT_OUT_OF_RANGE_MAX/MIN</li>
    141 </ul>
    142 
    143 <p>Example: get HVAC Temperature</p>
    144 <img src="../images/vehicle_hvac_get.png" alt="Vehicle HAL get HVAC example">
    145 <p class="img-caption"><strong>Figure 1</strong>. Get HVAC temperature (CS =
    146 CarService, VNS = VehicleNetworkService, VHAL = Vehicle HAL)</p>
    147 
    148 <h3 id=set>Set calls</h3>
    149 <p>A <code>set</code> call is an asynchronous operation involving event
    150 notification after a requested change is made. In a typical operation, a
    151 <code>set</code> call leads to making a change request across vehicle network.
    152 When the change is performed by the electronic control unit (ECU) owning the
    153 property, the updated value is returned through vehicle network and the vehicle
    154 HAL sends an updated value as an event to vehicle network service (VNS).</p>
    155 <p>Some <code>set</code> calls may require initial data to be ready but during
    156 initialization, such data may not be available yet. In such cases, the
    157 <code>set</code> call should return <code>-EAGAIN</code>. Some properties with
    158 separate power on /off should return <code>-ESHUTDOWN</code> when the property
    159 is powered off and set cannot be done.</p>
    160 <p>Until <code>set</code> is made effective, <code>get</code> does not
    161 necessarily return the same value as what is set. The exception is a property
    162 with change mode of <code>VEHICLE_PROP_CHANGE_MODE_ON_SET.</code> This property
    163 notifies change only when it is set by external component outside Android (for
    164 example, clock properties such as <code>VEHICLE_PROPERTY_UNIX_TIME</code>).</p>
    165 
    166 <p>Example: set HVAC Temperature</p>
    167 <img src="../images/vehicle_hvac_set.png" alt="Vehicle HAL set HVAC example">
    168 <p class="img-caption"><strong>Figure 2</strong>. Set HVAC temperature (CD =
    169 CarService, VNS = VehicleNetworkService, VHAL = Vehicle HAL)</p>
    170 
    171 <h2 id=prop_custom>Handling custom properties</h2>
    172 <p>To support partner-specific needs, the vehicle HAL allows custom properties
    173 that are restricted to system apps. Use the following guidelines when working
    174 with custom properties:</p>
    175 <ul>
    176 <li>Key should be in [<code>VEHICLE_PROPERTY_CUSTOM_START,
    177 VEHICLE_PROPERTY_CUSTOM_END</code>] range. Other ranges are reserved for future
    178 extension; using such ranges can cause conflicts in future Android releases.</li>
    179 <li>Use only defined <code>value_type</code>. BYTES type allows passing raw
    180 data, so this is enough in most cases. Sending big data frequently through
    181 custom properties can slow down the whole vehicle network access, so be careful
    182 when you add a big payload.</li>
    183 <li>Add access policy into <code>vendor_vns_policy.xml</code> (otherwise, all
    184 access will be rejected).</li>
    185 <li>Access via <code>VendorExtensionManager</code> (for Java components) or
    186 via Vehicle Network Service API (for native). Do not modify other car APIs as it
    187 can lead to compatibility issues in the future.</li>
    188 </ul>
    189 
    190 <h2 id=prop_hvac>Handling HVAC properties</h2>
    191 <p>You can use the vehicle HAL to control HVAC by setting HVAC-related
    192 properties. Most HVAC properties are zoned properties, but a few are non-zoned
    193 (global) properties. Example properties defined include:</p>
    194 <ul>
    195 <li><code>VEHICLE_PROPERTY_HVAC_TEMPERATURE_SET</code>
    196 <br>Set temperature per zone.</li>
    197 <li><code>VEHICLE_PROPERTY_HVAC_RECIRC_ON</code>
    198 <br>Control recirculation per zone).</li>
    199 </ul>
    200 <p>For full list of HVAC properties, search for
    201 <code>VEHICLE_PROPERTY_HVAC_*</code> in <code>vehicle.h</code>.</p>
    202 
    203 <h2 id=prop_sensor>Handling sensor properties</h2>
    204 <p>Vehicle HAL sensor properties represent real sensor data or policy
    205 information such as driving status. Some sensor information (such as driving
    206 status and day/night mode) is accessible by any app without restriction as the
    207 data is mandatory to build a safe vehicle application. Other sensor information
    208 (such as vehicle speed) is more sensitive and requires specific permissions that
    209 users can manage.</p>
    210 <p>Supported sensor properties include:</p>
    211 <ul>
    212 <li><code>DRIVING_STATUS</code>
    213 <br>Should support. Represents allowed operations in the current driving state.
    214 This information is used to block unsafe applications while driving.</li>
    215 <li><code>NIGHT_MODE</code>
    216 <br>Should support. Determines day/night mode of display.</li>
    217 <li><code>GEAR_SELECTION/CURRENT_GEAR</code>
    218 <br>Gear selected by driver vs. actual gear.</li>
    219 <li><code>VEHICLE_SPEED</code>
    220 <br>Vehicle speed. Protected with permission.</li>
    221 <li><code>ODOMETER</code>
    222 <br>Current odometer reading. Protected with permission.
    223 </li>
    224 <li><code>FUEL_LEVEL</code>
    225 <br>Current fuel level in %.</li>
    226 <li><code>FUEL_LEVEL_LOW</code>
    227 <br>Fuel level is low or not (boolean).</li>
    228 </ul>
    229 
    230   </body>
    231 </html>
    232