From 1fed2c5a38fed8bc91bb6b8a08982303eb9c2e82 Mon Sep 17 00:00:00 2001 From: zheng_wenlong Date: Wed, 6 Feb 2019 17:12:28 +0900 Subject: Change steering to systemd service for ces2019 Change steering to systemd service for ces2019 Change-Id: I319fb56a302f4f980b43a1b90dee1f36820355fb Signed-off-by: zheng_wenlong --- src/steering_wheel_json.c | 62 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 42 insertions(+), 20 deletions(-) (limited to 'src/steering_wheel_json.c') diff --git a/src/steering_wheel_json.c b/src/steering_wheel_json.c index 9d72284..5831983 100644 --- a/src/steering_wheel_json.c +++ b/src/steering_wheel_json.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 TOYOTA MOTOR CORPORATION + * Copyright (c) 2017-2019 TOYOTA MOTOR CORPORATION * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ #include #include #include -#include "af-steering-wheel-binding.h" +#include "wheel-service.h" #include "steering_wheel_json.h" #include "prop_info.h" #include "prop_search.h" @@ -33,6 +33,7 @@ static int parse_property(struct wheel_info_t *wheel_info, int idx, json_object { int var_type = 0; char *name = NULL; + char *canid = NULL; if(obj_property) { @@ -47,10 +48,30 @@ static int parse_property(struct wheel_info_t *wheel_info, int idx, json_object const char *_varname = json_object_get_string(val); var_type = string2vartype(_varname); } + else if(strcmp("CANID", key) == 0) + { + canid = (char *)json_object_get_string(val); + } + else if(strcmp("BIT_POSITION", key) == 0) + { + const char * tmp = json_object_get_string(val); + wheel_info->property[idx].bit_pos = (uint8_t)strtoul(tmp, 0, 0); + } + else if(strcmp("BIT_SIZE", key) == 0) + { + const char * tmp = json_object_get_string(val); + wheel_info->property[idx].bit_size = (uint8_t)strtoul(tmp, 0, 0); + } + else if(strcmp("DLC", key) == 0) + { + const char * tmp = json_object_get_string(val); + wheel_info->property[idx].dlc = (uint8_t)strtoul(tmp, 0, 0); + } } wheel_info->property[idx].name = strdup(name); wheel_info->property[idx].var_type = (unsigned char)var_type; + wheel_info->property[idx].can_id = strdup(canid); } return 0; @@ -68,7 +89,7 @@ static int parse_propertys(json_object *obj_propertys) wheel_info = malloc(ms); if (wheel_info == NULL) { - ERRMSG("Not enogh memory"); + DBG_ERROR("Not enogh memory"); return 1; } memset(wheel_info, 0 , ms); @@ -82,7 +103,7 @@ static int parse_propertys(json_object *obj_propertys) wheel_info = realloc(wheel_info, sizeof(struct wheel_info_t) + ((size_t)array_len * sizeof(struct prop_info_t))); if (wheel_info == NULL) { - ERRMSG("not enogh memory"); + DBG_ERROR("not enogh memory"); exit(1); } @@ -115,7 +136,7 @@ static int parse_json(json_object *obj) else { ++err; - ERRMSG("json: Unknown key \"%s\"", key); + DBG_ERROR("json: Unknown key \"%s\"", key); } } return err; @@ -128,23 +149,23 @@ int wheel_define_init(const char *fname) struct stat stbuf; char *filebuf; - fd_wheel_map = afb_daemon_rootdir_open_locale(fname, O_RDONLY, NULL); + fd_wheel_map = open(fname, O_RDONLY); if (fd_wheel_map < 0) { - ERRMSG("wheel map is not access"); + DBG_ERROR("wheel map is not access"); return -1; } FILE *fp = fdopen(fd_wheel_map,"r"); if (fp == NULL) { - ERRMSG("canno read wheel map file"); + DBG_ERROR("cannot read wheel map file"); return -1; } if (fstat(fd_wheel_map, &stbuf) == -1) { - ERRMSG("cant get file state"); + DBG_ERROR("cant get file state"); return -1; } @@ -155,7 +176,7 @@ int wheel_define_init(const char *fname) jobj = json_tokener_parse(filebuf); if (jobj == NULL) { - ERRMSG("cannot data from file \"%s\"",fname); + DBG_ERROR("cannot read data from file \"%s\"",fname); free(filebuf); return 1; } @@ -183,7 +204,7 @@ static int parse_gear_para_json(json_object *obj) if (type == json_type_array) { int array_len = json_object_array_length(val); - NOTICEMSG("array_len:%d!", array_len); + DBG_NOTICE("array_len:%d!", array_len); for (int i = 0; i < array_len; i++) { obj_speed_para = json_object_array_get_idx(val, i); @@ -236,12 +257,12 @@ static int parse_gear_para_json(json_object *obj) } else { - ERRMSG("json: Need array \"%s\"", key); + DBG_ERROR("json: Need array \"%s\"", key); } } else { - ERRMSG("json: Unknown key \"%s\"", key); + DBG_ERROR("json: Unknown key \"%s\"", key); } } return err; @@ -254,23 +275,24 @@ int wheel_gear_para_init(const char *fname) struct stat stbuf; char *filebuf; - fd_gear_para = afb_daemon_rootdir_open_locale(fname, O_RDONLY, NULL); +// fd_gear_para = afb_daemon_rootdir_open_locale(fname, O_RDONLY, NULL); + fd_gear_para = open(fname, O_RDONLY); if (fd_gear_para < 0) { - ERRMSG("gear para is not access"); + DBG_ERROR("gear para is not access"); return -1; } FILE *fp = fdopen(fd_gear_para,"r"); if (fp == NULL) { - ERRMSG("canno read gear para file"); + DBG_ERROR("cannot read gear para file"); return -1; } if (fstat(fd_gear_para, &stbuf) == -1) { - ERRMSG("cant get file state.\n"); + DBG_ERROR("cant get file state.\n"); return -1; } @@ -281,7 +303,7 @@ int wheel_gear_para_init(const char *fname) jobj = json_tokener_parse(filebuf); if (jobj == NULL) { - ERRMSG("cannot data from file \"%s\"",fname); + DBG_ERROR("cannot data from file \"%s\"",fname); free(filebuf); return 1; } @@ -326,13 +348,13 @@ struct json_object *property2json(struct prop_info_t *property) break; default: - ERRMSG("Unknown value type:%d", property->var_type); + DBG_ERROR("Unknown value type:%d", property->var_type); break; } if (valueObject == NULL) { - ERRMSG("fail json ValueObject"); + DBG_ERROR("fail json ValueObject"); json_object_put(jobj); return NULL; } -- cgit 1.2.3-korg