summaryrefslogtreecommitdiffstats
path: root/src/steering_wheel_json.c
diff options
context:
space:
mode:
authorzheng_wenlong <wenlong_zheng@nexty-ele.com>2019-04-04 09:03:27 +0900
committerzheng_wenlong <wenlong_zheng@nexty-ele.com>2019-04-04 09:04:27 +0900
commitc404f25dcaa4e622a0fe9179bc79393a468093d1 (patch)
treecb53edb66a21a4463cdea12082fbd5b77a057035 /src/steering_wheel_json.c
parent1fed2c5a38fed8bc91bb6b8a08982303eb9c2e82 (diff)
Revert "Change steering to systemd service for ces2019"
This reverts commit 1fed2c5a38fed8bc91bb6b8a08982303eb9c2e82. Change-Id: Id83b437eef556b8d3fcd95503b9ff5b4d94bc7a5 Signed-off-by: zheng_wenlong <wenlong_zheng@nexty-ele.com>
Diffstat (limited to 'src/steering_wheel_json.c')
-rw-r--r--src/steering_wheel_json.c62
1 files changed, 20 insertions, 42 deletions
diff --git a/src/steering_wheel_json.c b/src/steering_wheel_json.c
index 5831983..9d72284 100644
--- a/src/steering_wheel_json.c
+++ b/src/steering_wheel_json.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2019 TOYOTA MOTOR CORPORATION
+ * Copyright (c) 2017 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 <stdlib.h>
#include <string.h>
#include <sys/stat.h>
-#include "wheel-service.h"
+#include "af-steering-wheel-binding.h"
#include "steering_wheel_json.h"
#include "prop_info.h"
#include "prop_search.h"
@@ -33,7 +33,6 @@ 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)
{
@@ -48,30 +47,10 @@ 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;
@@ -89,7 +68,7 @@ static int parse_propertys(json_object *obj_propertys)
wheel_info = malloc(ms);
if (wheel_info == NULL)
{
- DBG_ERROR("Not enogh memory");
+ ERRMSG("Not enogh memory");
return 1;
}
memset(wheel_info, 0 , ms);
@@ -103,7 +82,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)
{
- DBG_ERROR("not enogh memory");
+ ERRMSG("not enogh memory");
exit(1);
}
@@ -136,7 +115,7 @@ static int parse_json(json_object *obj)
else
{
++err;
- DBG_ERROR("json: Unknown key \"%s\"", key);
+ ERRMSG("json: Unknown key \"%s\"", key);
}
}
return err;
@@ -149,23 +128,23 @@ int wheel_define_init(const char *fname)
struct stat stbuf;
char *filebuf;
- fd_wheel_map = open(fname, O_RDONLY);
+ fd_wheel_map = afb_daemon_rootdir_open_locale(fname, O_RDONLY, NULL);
if (fd_wheel_map < 0)
{
- DBG_ERROR("wheel map is not access");
+ ERRMSG("wheel map is not access");
return -1;
}
FILE *fp = fdopen(fd_wheel_map,"r");
if (fp == NULL)
{
- DBG_ERROR("cannot read wheel map file");
+ ERRMSG("canno read wheel map file");
return -1;
}
if (fstat(fd_wheel_map, &stbuf) == -1)
{
- DBG_ERROR("cant get file state");
+ ERRMSG("cant get file state");
return -1;
}
@@ -176,7 +155,7 @@ int wheel_define_init(const char *fname)
jobj = json_tokener_parse(filebuf);
if (jobj == NULL)
{
- DBG_ERROR("cannot read data from file \"%s\"",fname);
+ ERRMSG("cannot data from file \"%s\"",fname);
free(filebuf);
return 1;
}
@@ -204,7 +183,7 @@ static int parse_gear_para_json(json_object *obj)
if (type == json_type_array)
{
int array_len = json_object_array_length(val);
- DBG_NOTICE("array_len:%d!", array_len);
+ NOTICEMSG("array_len:%d!", array_len);
for (int i = 0; i < array_len; i++)
{
obj_speed_para = json_object_array_get_idx(val, i);
@@ -257,12 +236,12 @@ static int parse_gear_para_json(json_object *obj)
}
else
{
- DBG_ERROR("json: Need array \"%s\"", key);
+ ERRMSG("json: Need array \"%s\"", key);
}
}
else
{
- DBG_ERROR("json: Unknown key \"%s\"", key);
+ ERRMSG("json: Unknown key \"%s\"", key);
}
}
return err;
@@ -275,24 +254,23 @@ 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 = open(fname, O_RDONLY);
+ fd_gear_para = afb_daemon_rootdir_open_locale(fname, O_RDONLY, NULL);
if (fd_gear_para < 0)
{
- DBG_ERROR("gear para is not access");
+ ERRMSG("gear para is not access");
return -1;
}
FILE *fp = fdopen(fd_gear_para,"r");
if (fp == NULL)
{
- DBG_ERROR("cannot read gear para file");
+ ERRMSG("canno read gear para file");
return -1;
}
if (fstat(fd_gear_para, &stbuf) == -1)
{
- DBG_ERROR("cant get file state.\n");
+ ERRMSG("cant get file state.\n");
return -1;
}
@@ -303,7 +281,7 @@ int wheel_gear_para_init(const char *fname)
jobj = json_tokener_parse(filebuf);
if (jobj == NULL)
{
- DBG_ERROR("cannot data from file \"%s\"",fname);
+ ERRMSG("cannot data from file \"%s\"",fname);
free(filebuf);
return 1;
}
@@ -348,13 +326,13 @@ struct json_object *property2json(struct prop_info_t *property)
break;
default:
- DBG_ERROR("Unknown value type:%d", property->var_type);
+ ERRMSG("Unknown value type:%d", property->var_type);
break;
}
if (valueObject == NULL)
{
- DBG_ERROR("fail json ValueObject");
+ ERRMSG("fail json ValueObject");
json_object_put(jobj);
return NULL;
}