Skip to content

Commit cc8c987

Browse files
committed
Improve documentation.
Signed-off-by: Jan Kubovy <[email protected]>
1 parent 3302bb8 commit cc8c987

File tree

3 files changed

+57
-6
lines changed

3 files changed

+57
-6
lines changed

src/vss_tools/utils/vhal/property_constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ class VSSDatatypesToVhal:
7474
Mapping of vss datatypes corresponding to standard VHAL property type IDs. For those VSS datatypes, which don't
7575
correspond to standard VHAL properties, vendor type IDs were defined. See
7676
https://cs.android.com/android/platform/superproject/main/+/main:hardware/interfaces/automotive/vehicle/aidl_property/android/hardware/automotive/vehicle/VehiclePropertyType.aidl
77+
and https://source.android.com/docs/automotive/vhal/property-configuration#property-types
7778
"""
7879

7980
VSS_TO_VHAL_TYPE_MAP = {

src/vss_tools/utils/vhal/vehicle_mapping.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,24 @@
1717
class VehicleMappingItem:
1818
"""
1919
Represents a single vehicle mapping item.
20+
21+
:param name: Android name of the vehicle property
22+
:param property_id: Android area ID of the property (https://android.googlesource.com/platform/packages/services/Car/+/refs/heads/main/car-lib/src/android/car/VehicleAreaType.java)
23+
:param area_id: See https://source.android.com/docs/automotive/vhal/property-configuration
24+
:param access: See https://source.android.com/docs/automotive/vhal/property-configuration
25+
:param change_mode: Android change mode for the property (https://developer.android.com/reference/android/car/hardware/CarPropertyConfig#VEHICLE_PROPERTY_CHANGE_MODE_ONCHANGE)
26+
:param unit: Android property unit
27+
:param source: Corresponding fully-qualified VSS leaf name.
28+
:param formula: For mapping purpose, explains how to map a VSS property to Android property if direct correspondence wasn't found.
29+
:param comment: Internal comment about current mapping.
30+
:param config_string: Optional Android string to contain property specific configuration.
31+
:param datatype:
32+
:param type:
33+
:param min:
34+
:param max:
35+
:param allowed:
36+
:param default:
37+
:param deprecation:
2038
"""
2139

2240
name: str
@@ -42,26 +60,37 @@ class VehicleMappingItem:
4260
def vhal_group(self):
4361
"""
4462
VHAL group component of the property ID.
63+
- https://source.android.com/docs/automotive/vhal/property-configuration
64+
- https://cs.android.com/android/platform/superproject/main/+/main:hardware/interfaces/automotive/vehicle/aidl_property/android/hardware/automotive/vehicle/VehicleProperty.aidl
65+
- https://cs.android.com/android/platform/superproject/main/+/main:hardware/interfaces/automotive/vehicle/aidl_property/android/hardware/automotive/vehicle/VehiclePropertyGroup.aidl
4566
"""
4667
return (self.property_id & 0xF0000000) >> 28
4768

4869
@property
4970
def vhal_area(self):
5071
"""
5172
VHAL area component of the property ID.
73+
- https://source.android.com/docs/automotive/vhal/property-configuration
74+
- https://cs.android.com/android/platform/superproject/main/+/main:hardware/interfaces/automotive/vehicle/aidl_property/android/hardware/automotive/vehicle/VehicleProperty.aidl
75+
- https://cs.android.com/android/platform/superproject/main/+/main:hardware/interfaces/automotive/vehicle/aidl_property/android/hardware/automotive/vehicle/VehicleArea.aidl
76+
- https://cs.android.com/android/platform/superproject/main/+/main:packages/services/Car/car-lib/src/android/car/VehicleAreaType.java?q=vehicleareatype.java&ss=android%2Fplatform%2Fsuperproject%2Fmain
5277
"""
5378
return (self.property_id & 0x0F000000) >> 24
5479

5580
@property
5681
def vhal_type(self):
5782
"""
5883
VHAL type component of the property ID.
84+
- https://source.android.com/docs/automotive/vhal/property-configuration
85+
- https://cs.android.com/android/platform/superproject/main/+/main:hardware/interfaces/automotive/vehicle/aidl_property/android/hardware/automotive/vehicle/VehicleProperty.aidl
5986
"""
6087
return (self.property_id & 0x00FF0000) >> 16
6188

6289
@property
6390
def vhal_id(self):
6491
"""
6592
VHAL unique ID component of the property ID.
93+
- https://source.android.com/docs/automotive/vhal/property-configuration
94+
- https://cs.android.com/android/platform/superproject/main/+/main:hardware/interfaces/automotive/vehicle/aidl_property/android/hardware/automotive/vehicle/VehicleProperty.aidl
6695
"""
6796
return self.property_id & 0x0000FFFF

src/vss_tools/utils/vhal/vhal_mapper.py

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ def __get_next_vhal_property_id(self, node: VSSNode) -> int:
7272
286277632 (0x11104000) = UniqueID (0x00004000) | VehiclePropertyType.STRING (0x00100000) |
7373
VehicleArea.GLOBAL (0x01000000) | VehiclePropertyGroup.SYSTEM (0x10000000)
7474
75+
The ID - vspec static UID generator (https://github.com/COVESA/vss-tools/blob/master/docs/id.md) cannot be used
76+
since it needs 4-bytes.
77+
7578
:param node: VSS node that we want to generate a unique VHAL property ID for.
7679
:returns: 2 bytes unique ID value for the VSS node.
7780
"""
@@ -192,7 +195,7 @@ def load_vss_tree(self, node: VSSNode):
192195
r"([a-z])([A-Z])", r"\1_\2", node_name_flat.replace("Vehicle.", "").replace(".", "_")
193196
).upper(),
194197
property_id=mapping.property_id if mapping else self.__get_next_vhal_property_id(node),
195-
area_id=mapping.area_id if mapping else VhalMapper.__get_vhal_vehicle_area_id(node),
198+
area_id=mapping.area_id if mapping else self.__get_vhal_vehicle_area_id(node),
196199
access=mapping.access if mapping else VhalMapper.__get_vhal_access(node),
197200
change_mode=mapping.change_mode if mapping else self.__get_vhal_change_mode(node),
198201
unit=mapping.unit
@@ -348,21 +351,37 @@ def generate_aidl_file(self, output_filename=None) -> str:
348351
file.write(aidl_class)
349352
return aidl_class
350353

351-
@staticmethod
352-
def __get_vhal_vehicle_area_id(node: VSSNode) -> int:
354+
def __get_vhal_vehicle_area_id(self, node: VSSNode) -> int:
353355
"""
354356
Android VHAL area ID is described here:
355357
https://android.googlesource.com/platform/packages/services/Car/+/refs/heads/main/car-lib/src/android/car/VehicleAreaType.java
358+
and
359+
https://cs.android.com/android/platform/superproject/main/+/main:hardware/interfaces/automotive/vehicle/aidl_property/android/hardware/automotive/vehicle/VehicleArea.aidl
360+
361+
Area type is always generated as GLOBAL. As of now the resulting mapping file needs to be manually edited
362+
when GLOBAL is not fitting. Consequent runs will keep those edits.
363+
364+
A detection of area ID based on VSS tree may be implemented in the future.
365+
366+
Note that for vendor properties the area type VENDOR should be used.
356367
357368
:returns: VHAL Area ID.
358369
"""
359-
return VhalAreaType.VEHICLE_AREA_TYPE_GLOBAL.value
370+
return (
371+
VhalAreaType.VEHICLE_AREA_TYPE_VENDOR.value
372+
if self.__group == 2
373+
else VhalAreaType.VEHICLE_AREA_TYPE_GLOBAL.value
374+
)
360375

361376
@staticmethod
362377
def __get_vhal_access(node: VSSNode) -> int:
363378
"""
364379
Get vendor property access mode as defined in Android and VSS specification
365380
381+
In VSS documentation attributes and sensors have READ access, actuators have READ_WRITE access. Only WRITE
382+
access was not used in VSS documentation. As a result the properties in mapping will have READ access for VSS
383+
attributes and sensors, and READ_WRITE for VSS actuators.
384+
366385
:param node: VSS node (sensor, attribute or actuator).
367386
:returns: Read for sensor or attribute, read/write for actuator.
368387
"""
@@ -383,8 +402,10 @@ def __get_vhal_access(node: VSSNode) -> int:
383402

384403
def __get_vhal_change_mode(self, node: VSSNode) -> int:
385404
"""
386-
Get vendor property change mode as defined in Android specification. Assumption for VSS sensors: numeric
387-
datatypes have continuous mode, boolean and string datatypes have on_change mode.
405+
Get vendor property change mode as defined in Android specification. VSS attributes and actuators have
406+
STATIC change mode. Most VSS sensors also to have STATIC change mode except for those sensors, which could be
407+
mapped to Android properties with CONTINUOUS change mode. What properties should have CONTINUOUS change mode
408+
must be provided externally.
388409
389410
:param node: sensor, attribute or actuator
390411
:returns: change mode

0 commit comments

Comments
 (0)