summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan-Simon Moeller <jsmoeller@linuxfoundation.org>2018-06-12 11:58:19 +0000
committerGerrit Code Review <gerrit@automotivelinux.org>2018-06-12 11:58:19 +0000
commitbbeb0dc4465801f0b2c2bf1c3af2a17f819e51fc (patch)
tree5375f6587b0c55b0d6e41a7f4341db2e804436f2
parentce413b11b9efc36e4f0c0c41c8c14ef10f14be3d (diff)
parent7ad128e425934b74534b9ef8112ebb0eb83955a4 (diff)
Merge "agl-service-unicens: replace legacy sendmessage" into eeleel_5.1.0eel/5.1.05.1.0eel
-rw-r--r--htdocs/UNICENS.html11
-rw-r--r--ucs2-afb/ucs_apidef.h31
-rw-r--r--ucs2-afb/ucs_apidef.json41
-rw-r--r--ucs2-afb/ucs_binding.c95
4 files changed, 12 insertions, 166 deletions
diff --git a/htdocs/UNICENS.html b/htdocs/UNICENS.html
index dfcd0b2..46efeff 100644
--- a/htdocs/UNICENS.html
+++ b/htdocs/UNICENS.html
@@ -71,13 +71,10 @@
<li><button onclick="callbinder('UNICENS','writei2c', {node: 0x272, data:[0x07,0x03,0xFF]})">WriteI2c to 0x272 (mute)</button></li>
</ol>
<ol>
- <li><button onclick="callbinder('UNICENS','sendmessage', {node: 0x270, msgid: 0x5AC4, data:[0x01,0x02,0xFF]})">Send ControlMsg to 0x270</button></li>
- </ol>
- <ol>
- <li><button onclick="callbinder('UNICENS','sendmessageb64', {node: 0x270, msgid: 0x5AC4, data:'ESIzRA=='})">Send ControlMsgB64 to 0x270</button></li>
- <li><button onclick="callbinder('UNICENS','sendmessageb64', {node: 0x270, msgid: 0x5AC4})">Send ControlMsgB64 to 0x270 (no data)</button></li>
- <!--<li><button onclick="callbinder('UNICENS','sendmessageb64', {node: 0x270, msgid: 0x5AC4, data: null})">Send ControlMsgB64 to 0x270 (data: null)</button></li>-->
- <!--<li><button onclick="callbinder('UNICENS','sendmessageb64', {node: 0x270, msgid: 0x5AC4, data: ''})">Send ControlMsgB64 to 0x270 (data: '')</button></li>-->
+ <li><button onclick="callbinder('UNICENS','sendmessage', {node: 0x270, msgid: 0x5AC4, data:'ESIzRA=='})">Send ControlMsgB64 to 0x270</button></li>
+ <li><button onclick="callbinder('UNICENS','sendmessage', {node: 0x270, msgid: 0x5AC4})">Send ControlMsgB64 to 0x270 (no data)</button></li>
+ <!--<li><button onclick="callbinder('UNICENS','sendmessage', {node: 0x270, msgid: 0x5AC4, data: null})">Send ControlMsgB64 to 0x270 (data: null)</button></li>-->
+ <!--<li><button onclick="callbinder('UNICENS','sendmessage', {node: 0x270, msgid: 0x5AC4, data: ''})">Send ControlMsgB64 to 0x270 (data: '')</button></li>-->
</ol>
<br>
diff --git a/ucs2-afb/ucs_apidef.h b/ucs2-afb/ucs_apidef.h
index 6b8c23a..71739b6 100644
--- a/ucs2-afb/ucs_apidef.h
+++ b/ucs2-afb/ucs_apidef.h
@@ -49,22 +49,13 @@ static const char _afb_description_v2_UNICENS[] =
"\",\"format\":\"int32\"},\"style\":\"simple\"}],\"responses\":{\"200\":{"
"\"$ref\":\"#/components/responses/200\"}}}},\"/sendmessage\":{\"descript"
"ion\":\"Transmits a control message to a node.\",\"get\":{\"x-permission"
- "s\":{\"$ref\":\"#/components/x-permissions/monitor\"},\"parameters\":[{\""
- "in\":\"query\",\"name\":\"node\",\"required\":true,\"schema\":{\"type\":"
- "\"integer\",\"format\":\"int32\"}},{\"in\":\"query\",\"name\":\"msgid\","
- "\"required\":true,\"schema\":{\"type\":\"integer\",\"format\":\"int32\"}"
- "},{\"in\":\"query\",\"name\":\"data\",\"required\":true,\"schema\":{\"ty"
- "pe\":\"array\",\"format\":\"int32\"},\"style\":\"simple\"}],\"responses\""
- ":{\"200\":{\"$ref\":\"#/components/responses/200\"}}}},\"/sendmessageb64"
- "\":{\"description\":\"Transmits a control message to a node.\",\"get\":{"
- "\"x-permissions\":{\"$ref\":\"#/components/x-permissions/controller\"},\""
- "parameters\":[{\"in\":\"query\",\"name\":\"node\",\"required\":true,\"sc"
- "hema\":{\"type\":\"integer\",\"format\":\"int32\"}},{\"in\":\"query\",\""
- "name\":\"msgid\",\"required\":true,\"schema\":{\"type\":\"integer\",\"fo"
- "rmat\":\"int32\"}},{\"in\":\"query\",\"name\":\"data\",\"required\":fals"
- "e,\"schema\":{\"type\":\"string\",\"format\":\"byte\"},\"style\":\"simpl"
- "e\"}],\"responses\":{\"200\":{\"$ref\":\"#/components/responses/200\"}}}"
- "}}}"
+ "s\":{\"$ref\":\"#/components/x-permissions/controller\"},\"parameters\":"
+ "[{\"in\":\"query\",\"name\":\"node\",\"required\":true,\"schema\":{\"typ"
+ "e\":\"integer\",\"format\":\"int32\"}},{\"in\":\"query\",\"name\":\"msgi"
+ "d\",\"required\":true,\"schema\":{\"type\":\"integer\",\"format\":\"int3"
+ "2\"}},{\"in\":\"query\",\"name\":\"data\",\"required\":false,\"schema\":"
+ "{\"type\":\"string\",\"format\":\"byte\"},\"style\":\"simple\"}],\"respo"
+ "nses\":{\"200\":{\"$ref\":\"#/components/responses/200\"}}}}}}"
;
static const struct afb_auth _afb_auths_v2_UNICENS[] = {
@@ -79,7 +70,6 @@ static const struct afb_auth _afb_auths_v2_UNICENS[] = {
void ucs2_subscriberx(struct afb_req req);
void ucs2_writei2c(struct afb_req req);
void ucs2_sendmessage(struct afb_req req);
- void ucs2_sendmessageb64(struct afb_req req);
static const struct afb_verb_v2 _afb_verbs_v2_UNICENS[] = {
{
@@ -120,13 +110,6 @@ static const struct afb_verb_v2 _afb_verbs_v2_UNICENS[] = {
{
.verb = "sendmessage",
.callback = ucs2_sendmessage,
- .auth = &_afb_auths_v2_UNICENS[1],
- .info = "Transmits a control message to a node.",
- .session = AFB_SESSION_NONE_V2
- },
- {
- .verb = "sendmessageb64",
- .callback = ucs2_sendmessageb64,
.auth = &_afb_auths_v2_UNICENS[2],
.info = "Transmits a control message to a node.",
.session = AFB_SESSION_NONE_V2
diff --git a/ucs2-afb/ucs_apidef.json b/ucs2-afb/ucs_apidef.json
index 623d58e..b7550ff 100644
--- a/ucs2-afb/ucs_apidef.json
+++ b/ucs2-afb/ucs_apidef.json
@@ -202,47 +202,6 @@
"description": "Transmits a control message to a node.",
"get": {
"x-permissions": {
- "$ref": "#/components/x-permissions/monitor"
- },
- "parameters": [
- {
- "in": "query",
- "name": "node",
- "required": true,
- "schema": {
- "type": "integer",
- "format": "int32"
- }
- },
- {
- "in": "query",
- "name": "msgid",
- "required": true,
- "schema": {
- "type": "integer",
- "format": "int32"
- }
- },
- {
- "in": "query",
- "name": "data",
- "required": true,
- "schema": {
- "type": "array",
- "format": "int32"
- },
- "style": "simple"
- }
- ],
- "responses": {
- "200": {"$ref": "#/components/responses/200"}
- }
- }
- },
- "/sendmessageb64": {
- "description": "Transmits a control message to a node.",
- "get": {
- "x-permissions": {
"$ref": "#/components/x-permissions/controller"
},
"parameters": [
diff --git a/ucs2-afb/ucs_binding.c b/ucs2-afb/ucs_binding.c
index bc783aa..4b21934 100644
--- a/ucs2-afb/ucs_binding.c
+++ b/ucs2-afb/ucs_binding.c
@@ -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;