Commit 27e02555 authored by Léo-Paul Géneau's avatar Léo-Paul Géneau 👾

debug

parent 04817df9
......@@ -265,6 +265,17 @@ static JSValue js_drone_init(JSContext *ctx, JSValueConst thisVal,
return JS_UNDEFINED;
}
static void print_queue(StrQueue *pQueue) {
struct strNode *current;
int i = 0;
current = pQueue->head;
while (current != NULL) {
printf("index %d str %s\n", i, current->str);
current = current->next;
i++;
}
}
static JSValue readDroneDataStr(JSContext *ctx, StrQueue *pQueue, bool keepAtLeastAnElement)
{
JSValue res;
......@@ -277,15 +288,18 @@ static JSValue readDroneDataStr(JSContext *ctx, StrQueue *pQueue, bool keepAtLea
pQueue->head = current->next;
delete_str_node(current);
} else {
pQueue->tail = NULL;
if (!keepAtLeastAnElement) {
pQueue->head = NULL;
pQueue->head = (pQueue->tail = NULL);
delete_str_node(current);
}
}
} else {
res = JS_NewString(ctx, "");
}
if (keepAtLeastAnElement) {
printf("Queue after reading\n");
print_queue(pQueue);
}
return res;
}
......@@ -335,6 +349,8 @@ static void addStrToQueue(const char *str, StrQueue *pQueue)
pQueue->tail->next = newNode;
pQueue->tail = newNode;
}
printf("Queue after addition\n");
print_queue(pQueue);
}
static JSValue add_jsstr_to_queue(JSContext *ctx, JSValueConst jsStr,
......@@ -527,6 +543,9 @@ static void pubsub_update_variables(UA_UInt32 id, const UA_DataValue *var, bool
}
return;
} else if (pubsubIdsArray[i].message == id) {
if ((*(UA_String*) var->value.data).length == 0) {
printf("It is a NULL string from %d\n", s->id);
}
setDroneDataStr(var->value.data, &(s->receiveMessageQueue));
return;
} else if (pubsubIdsArray[i].log == id) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment