OSDN Git Service

Moved init and release.
authorJamie Howarth <jhowart7@ford.com>
Wed, 16 Mar 2016 22:13:37 +0000 (18:13 -0400)
committerKeun-young Park <keunyoung@google.com>
Wed, 23 Mar 2016 20:43:18 +0000 (13:43 -0700)
Moved the init release calls in the vehicle-hal-tool.

I assume the correct sequence for a set is :-

VehicleNetworkService -> VehicleHAL vehicle_device_open
VehicleNetworkService -> VehicleHAL vehicle_device_init
VehicleNetworkService -> VehicleHAL vehicle_device_set
VehicleNetworkService -> VehicleHAL vehicle_device_release

bug: 27816048

Change-Id: I3ac37eaf69027824bc6247f25a99f27527c1a2b9

tests/vehicle/vehicle-hal-tool.c

index 3c3922f..c93790a 100755 (executable)
@@ -396,7 +396,6 @@ void subscribe_to_property(
     float sample_rate,
     uint32_t wait_in_seconds) {
     // Init the device with a callback.
-    device->init(device, vehicle_event_callback, vehicle_error_callback);
     int ret_code = device->subscribe(device, prop, 0, 0);
     if (ret_code != 0) {
         printf("Could not subscribe: %d\n", ret_code);
@@ -412,11 +411,6 @@ void subscribe_to_property(
     if (ret_code != 0) {
         printf("Error unsubscribing the HAL, still continuining to uninit HAL ...");
     }
-
-    ret_code = device->release(device);
-    if (ret_code != 0) {
-        printf("Error uniniting HAL, exiting anyways.");
-    }
 }
 
 int main(int argc, char* argv[]) {
@@ -438,6 +432,8 @@ int main(int argc, char* argv[]) {
     vehicle_hw_device_t *vehicle_device = (vehicle_hw_device_t *) (device);
     printf("HAL Loaded!\n");
 
+    vehicle_device->init(vehicle_device, vehicle_event_callback, vehicle_error_callback);
+
     // If this is a list properties command - we check for -l command.
     int list_properties = 0;
     // Type of the property (see #defines in vehicle.h).
@@ -529,5 +525,10 @@ int main(int argc, char* argv[]) {
         }
         subscribe_to_property(vehicle_device, property, sample_rate, wait_time_in_sec);
     }
+
+    ret_code = vehicle_device->release(vehicle_device);
+    if (ret_code != 0) {
+        printf("Error uniniting HAL, exiting anyways.");
+    }
     return 0;
 }