vehicle_hw_device Struct Reference

vehicle_hw_device Struct Reference

#include < vehicle.h >

Data Fields

struct hw_device_t   common
int(*  init )(struct vehicle_hw_device *device, vehicle_event_callback_fn event_fn, vehicle_error_callback_fn err_fn)
int(*  release )(struct vehicle_hw_device *device)
vehicle_prop_config_t const *(*  list_properties )(struct vehicle_hw_device *device, int *num_properties)
int(*  get )(struct vehicle_hw_device *device, vehicle_prop_value_t *data)
void(*  release_memory_from_get )(struct vehicle_hw_device *device, vehicle_prop_value_t *data)
int(*  set )(struct vehicle_hw_device *device, const vehicle_prop_value_t *data)
int(*  subscribe )(struct vehicle_hw_device *device, int32_t prop, float sample_rate, int32_t zones)
int(*  unsubscribe )(struct vehicle_hw_device *device, int32_t prop)
int(*  dump )(struct vehicle_hw_device *device, int fd)

Detailed Description

Definition at line 1639 of file vehicle.h .

Field Documentation

struct hw_device_t common

Definition at line 1640 of file vehicle.h .

int(* dump)(struct vehicle_hw_device *device, int fd)

Print out debugging state for the vehicle hal. This will be called by the vehicle network service and will be included into the service' dump.

The passed-in file descriptor can be used to write debugging text using dprintf() or write(). The text should be in ASCII encoding only.

Performance requirements:

This must be a non-blocking call. The HAL should return from this call in 1ms, must return from this call in 10ms. This call must avoid deadlocks, as it may be called at any point of operation. Any synchronization primitives used (such as mutex locks or semaphores) should be acquired with a timeout.

Definition at line 1744 of file vehicle.h .

int(* get)(struct vehicle_hw_device *device, vehicle_prop_value_t *data)

Get a vehicle property value immediately. data should be allocated properly. The caller of the API OWNS the data field. Caller will set data->prop, data->value_type, and optionally zone value for zoned property. But HAL implementation needs to fill all entries properly when returning. For pointer type, HAL implementation should allocate necessary memory and caller is responsible for calling release_memory_from_get, which allows HAL to release allocated memory. For VEHICLE_PROP_CHANGE_MODE_STATIC type of property, get should return the same value always. For VEHICLE_PROP_CHANGE_MODE_ON_CHANGE type of property, it should return the latest value. If there is no data available yet, which can happen during initial stage, this call should return immediately with error code of -EAGAIN.

Definition at line 1681 of file vehicle.h .

After calling open on device the user should register callbacks for event and error functions.

Definition at line 1646 of file vehicle.h .

vehicle_prop_config_t const*(* list_properties)(struct vehicle_hw_device *device, int *num_properties)

Enumerate all available properties. The list is returned in "list".

num_properties number of properties contained in the retuned array.
array of property configs supported by this car. Note that returned data is const and caller cannot modify it. HAL implementation should keep this memory until HAL is released to avoid copying this again.

Definition at line 1663 of file vehicle.h .

int(* release)(struct vehicle_hw_device *device)

Before calling close the user should destroy the registered callback functions. In case the unsubscribe() call is not called on all properties before release() then release() will unsubscribe the properties itself.

Definition at line 1654 of file vehicle.h .

void(* release_memory_from_get)(struct vehicle_hw_device *device, vehicle_prop_value_t *data)

Release memory allocated to data in previous get call. get call for byte or string involves allocating necessary memory from vehicle hal. To be safe, memory allocated by vehicle hal should be released by vehicle hal and vehicle network service will call this when data from vehicle hal is no longer necessary. vehicle hal implementation should only release member of vehicle_prop_value_t like data-> or data-> but not data itself as data itself is allocated from vehicle network service. Once memory is freed, corresponding pointer should be set to NULL bu vehicle hal.

Definition at line 1693 of file vehicle.h .

int(* set)(struct vehicle_hw_device *device, const vehicle_prop_value_t *data)

Set a vehicle property value. data should be allocated properly and not NULL. The caller of the API OWNS the data field. timestamp of data will be ignored for set operation. Setting some properties require having initial state available. Depending on the vehicle hal, such initial data may not be available for short time after init. In such case, set call can return -EAGAIN like get call. For a property with separate power control, set can fail if the property is not powered on. In such case, hal should return -ESHUTDOWN error.

Definition at line 1706 of file vehicle.h .

int(* subscribe)(struct vehicle_hw_device *device, int32_t prop, float sample_rate, int32_t zones)

Subscribe to events. Depending on output of list_properties if the property is: a) on-change: sample_rate should be set to 0. b) supports frequency: sample_rate should be set from min_sample_rate to max_sample_rate. For on-change type of properties, vehicle network service will make another get call to check the initial state. Due to this, vehicle hal implementation does not need to send initial state for on-change type of properties.

zones All subscribed zones for zoned property. can be ignored for non-zoned property. 0 means all zones supported instead of no zone.

Definition at line 1723 of file vehicle.h .

int(* unsubscribe)(struct vehicle_hw_device *device, int32_t prop)

Cancel subscription on a property.

Definition at line 1727 of file vehicle.h .

The documentation for this struct was generated from the following file: