Commit 8c67e035 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Support GUIs with zero PI or zero RI

parent c43840a9
......@@ -6,7 +6,14 @@
* Generated by TASTE/Kazoo on @_NOW_@
* DO NOT EDIT THIS FILE MANUALLY - MODIFY THE KAZOO TEMPLATE IF NECESSARY
*/
@@IF@@ @_List_Of_ASync_PIs'Length_@ > 1 or (@_List_Of_ASync_PIs'Length_@ = 1 and (@_List_Of_ASync_RIs'Length_@ = 0 or not @_Glue_@))
@@-- >1 means there is the Poll function, otherwise =1 if there are no Telecommands (RIs: no Poll function)
@@-- If glue flag was not set, the Poll function is also not there so if there is one PI and no Glue, we have the field
@@SET@@ Has_PI = TRUE
@@END_IF@@
@@IF@@ @_List_Of_ASync_RIs'Length_@ > 0
@@SET@@ Has_RI = TRUE
@@END_IF@@
#include <unistd.h>
#include <mqueue.h>
......@@ -15,11 +22,8 @@
#include "@_LOWER:Name_@_enums_def.h"
typedef struct _PI_Messages {
@@IF@@ @_List_Of_ASync_PIs'Length_@ > 1 or (@_List_Of_ASync_PIs'Length_@ = 1 and (@_List_Of_ASync_RIs'Length_@ = 0 or not @_Glue_@))
@@-- >1 means there is the Poll function, otherwise =1 if there are no Telecommands (RIs: no Poll function)
@@-- If glue flag was not set, the Poll function is also not there so if there is one PI and no Glue, we have the field
@@IF@@ @_Has_PI_@
T_@_LOWER:Name_@_PI_list msg_id;
@@END_IF@@
union {
@@TABLE@@
@@IF@@ @_ASync_PI_Param_Type_@ /= ""
......@@ -27,12 +31,12 @@ typedef struct _PI_Messages {
@@END_IF@@
@@END_TABLE@@
} msg_data;
@@END_IF@@
} PI_Messages;
typedef struct _RI_Messages {
@@IF@@ @_List_Of_ASync_RIs'Length_@ > 0
@@IF@@ @_Has_RI_@
T_@_LOWER:Name_@_RI_list msg_id;
@@END_IF@@
union {
@@TABLE@@
@@IF@@ @_ASync_RI_Param_Type_@ /= ""
......@@ -40,15 +44,16 @@ typedef struct _RI_Messages {
@@END_IF@@
@@END_TABLE@@
} msg_data;
@@END_IF@@
} RI_Messages;
@@IF@@ @_List_Of_PIs'Length_@ > 0
@@IF@@ @_Has_PI_@
// Queues of messages going from the binary to the user (PIs, or TMs)
static mqd_t @_LOWER:Name_@_PI_queue_id,
@_LOWER:Name_@_PI_Python_queue_id;
@@END_IF@@
@@IF@@ @_List_Of_PIs'Length_@ > 0
@@IF@@ @_Has_RI_@
// Queues of messages going from the user to the binary GUI (RIs, or TCs)
static mqd_t @_LOWER:Name_@_RI_queue_id;
@@END_IF@@
......@@ -73,7 +78,10 @@ void @_LOWER:Name_@_startup(void)
}
char *gui_queue_name = NULL;
int len = snprintf (gui_queue_name, 0, "%d_@_LOWER:Name_@_RI_queue", geteuid());
int len;
@@IF@@ @_Has_RI_@
len = snprintf (gui_queue_name, 0, "%d_@_LOWER:Name_@_RI_queue", geteuid());
gui_queue_name = (char *) malloc ((size_t) len + 1);
if (NULL != gui_queue_name) {
snprintf (gui_queue_name, len + 1, "%d_@_LOWER:Name_@_RI_queue", geteuid());
......@@ -83,6 +91,8 @@ void @_LOWER:Name_@_startup(void)
free (gui_queue_name);
gui_queue_name = NULL;
}
@@END_IF@@
@@IF@@ @_Has_PI_@
len = snprintf (gui_queue_name, 0, "%d_@_LOWER:Name_@_PI_queue", geteuid());
gui_queue_name = (char *) malloc ((size_t) len + 1);
......@@ -106,8 +116,10 @@ void @_LOWER:Name_@_startup(void)
free (gui_queue_name);
gui_queue_name = NULL;
}
@@END_IF@@
}
@@IF@@ @_Has_RI_@
// Function polling the message queue for incoming message from the user
void @_LOWER:Name_@_PI_Poll(void)
{
......@@ -146,6 +158,7 @@ void @_LOWER:Name_@_PI_Poll(void)
@@END_IF@@
return;
}
@@END_IF@@
@_Provided_Interfaces_@
......
......@@ -143,7 +143,7 @@ int create_exchange_queue(char* queue_name,
// It is not possible to have a queue of size 0. If this happens something has gone wrong
// when generating the PI_Message structure. We must abort, as it will fail at runtime
if (0 == max_msg_size) {
perror ("create_exchange_queue for was called with zero-size queue size, aborting");
perror ("create_exchange_queue for was called with zero-size queue size, aborting\n");
exit(-1);
}
......
Supports Markdown
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