X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=ucs2-afb%2Fucs_binding.c;h=bf0fd8e8957cff48d3cc2a953630c6cb107e00b1;hb=b79d0efc90f30918d64024bc0807c023e44c5325;hp=bc783aa360091a00bea1916e48b0828e6a91e6ba;hpb=216ae6b4e1c6eac62dea123816ccb1314c8362c9;p=apps%2Fagl-service-unicens.git diff --git a/ucs2-afb/ucs_binding.c b/ucs2-afb/ucs_binding.c index bc783aa..bf0fd8e 100644 --- a/ucs2-afb/ucs_binding.c +++ b/ucs2-afb/ucs_binding.c @@ -41,7 +41,7 @@ #include "ucs_binding.h" #include "ucs_interface.h" -#include "wrap-json.h" +#include #define MAX_FILENAME_LEN (100) #define RX_BUFFER (64) @@ -754,100 +754,7 @@ PUBLIC void ucs2_writei2c (struct afb_req request) { } } -/* write a single control message */ -STATIC void ucs2_sendmessage_cmd(struct afb_req request, json_object *j_obj) { - - static uint8_t ctrl_data[CTRL_MAX_DATA_SZ]; - uint8_t ctrl_data_sz = 0; - uint16_t node_addr = 0; - uint16_t msg_id = 0; - json_object *j_tmp; - - if (json_object_object_get_ex(j_obj, "node", &j_tmp)) { - node_addr = (uint16_t)json_object_get_int(j_tmp); - AFB_NOTICE("node_address: 0x%02X", node_addr); - if (node_addr == 0) { - afb_req_fail_f(request, "query-params","param node invalid type"); - goto OnErrorExit; - } - } - else { - afb_req_fail_f(request, "query-params","param node missing"); - goto OnErrorExit; - } - - if (json_object_object_get_ex(j_obj, "msgid", &j_tmp)) { - if (json_object_get_type(j_tmp) == json_type_int) { - msg_id = (uint16_t)json_object_get_int(j_tmp); - AFB_NOTICE("msgid: 0x%02X", msg_id); - } - else { - afb_req_fail_f(request, "query-params","param msgid invalid type"); - goto OnErrorExit; - } - } - else { - afb_req_fail_f(request, "query-params","param msgid missing"); - goto OnErrorExit; - } - - if (json_object_object_get_ex(j_obj, "data", &j_tmp)) { - if (json_object_get_type(j_tmp)==json_type_array) { - int size = json_object_array_length(j_tmp); - if ((size > 0) && (size <= CTRL_MAX_DATA_SZ)) { - int32_t i; - int32_t val; - struct json_object *j_elem; - - for (i = 0; i < size; i++) { - j_elem = json_object_array_get_idx(j_tmp, i); - val = json_object_get_int(j_elem); - if ((val < 0) && (val > 0xFF)){ - i = 0; - break; - } - ctrl_data[i] = (uint8_t)json_object_get_int(j_elem); - } - - if (i != size) { /* check if size matches */ - afb_req_fail_f(request, "query-params", - "parameter data is ambiguous"); - goto OnErrorExit; - } - - ctrl_data_sz = (uint8_t)i; - } - } - } - - if (UCSI_SendAmsMessage(&ucsContextS->ucsiData, /* UCSI_Data_t *pPriv*/ - msg_id, - node_addr, - &ctrl_data[0], - ctrl_data_sz)) { - afb_req_success(request, NULL, "sendmessage started successful"); - } - else { - AFB_NOTICE("sendmessage: scheduling command failed"); - afb_req_fail_f(request, "query-command-queue","command queue overload"); - goto OnErrorExit; - } - -OnErrorExit: - return; -} - -PUBLIC void ucs2_sendmessage(struct afb_req request) { - struct json_object *j_obj; - - j_obj = ucs2_validate_command(request, "sendmessage"); - - if (j_obj) { - ucs2_sendmessage_cmd(request, j_obj); - } -} - -PUBLIC void ucs2_sendmessageb64(struct afb_req req) { +PUBLIC void ucs2_sendmessage(struct afb_req req) { uint8_t *data_ptr = NULL; size_t data_sz = 0; int ret, node_addr, msg_id = 0;