Commit 3b13d05c authored by winckel's avatar winckel

Modified ITTI message number format from binay to ASCII.

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4866 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent 67ebeb01
......@@ -158,8 +158,10 @@ static int itti_dump_send_message(int sd, itti_dump_queue_item_t *message)
/* Preparing the header */
new_message->socket_header.message_size = size;
new_message->socket_header.message_type = ITTI_DUMP_MESSAGE_TYPE;
new_message->signal_header.message_number = message->message_number;
/* Adds message number in unsigned decimal ASCII format */
snprintf(new_message->signal_header.message_number_char, sizeof(new_message->signal_header.message_number_char),
MESSAGE_NUMBER_CHAR_FORMAT, message->message_number);
new_message->signal_header.message_number_char[sizeof(new_message->signal_header.message_number_char) - 1] = '\n';
/* Appends message payload */
memcpy(&new_message[1], message->data, message->data_size);
......@@ -184,15 +186,17 @@ static int itti_dump_send_message(int sd, itti_dump_queue_item_t *message)
static int itti_dump_fwrite_message(itti_dump_queue_item_t *message)
{
itti_socket_header_t header;
itti_dump_message_t new_message_header;
if ((dump_file != NULL) && (message != NULL)) {
header.message_size = message->message_size + sizeof(itti_dump_message_t) + sizeof(itti_message_types_t);
header.message_type = message->message_type;
new_message_header.socket_header.message_size = message->message_size + sizeof(itti_dump_message_t) + sizeof(itti_message_types_t);
new_message_header.socket_header.message_type = message->message_type;
snprintf(new_message_header.signal_header.message_number_char, sizeof(new_message_header.signal_header.message_number_char),
MESSAGE_NUMBER_CHAR_FORMAT, message->message_number);
new_message_header.signal_header.message_number_char[sizeof(new_message_header.signal_header.message_number_char) - 1] = '\n';
fwrite (&header, sizeof(itti_socket_header_t), 1, dump_file);
fwrite (&message->message_number, sizeof(message->message_number), 1, dump_file);
fwrite (&new_message_header, sizeof(itti_dump_message_t), 1, dump_file);
fwrite (message->data, message->data_size, 1, dump_file);
fwrite (&itti_dump_message_type_end, sizeof(itti_message_types_t), 1, dump_file);
// #if !defined(RTAI)
......
......@@ -38,6 +38,8 @@
#define CHARS_TO_UINT32(c1, c2, c3, c4) (((c4) << 24) | ((c3) << 16) | ((c2) << 8) | (c1))
#define MESSAGE_NUMBER_CHAR_FORMAT "%11u"
/* Intertask message types */
enum itti_message_types_e
{
......@@ -66,7 +68,7 @@ typedef struct {
} itti_socket_header_t;
typedef struct {
uint32_t message_number;
char message_number_char[12]; /* 9 chars are needed to store an unsigned 32 bits value in decimal, but must be a multiple of 32 bits to avoid alignment issues */
} itti_signal_header_t;
......
......@@ -115,7 +115,7 @@ static int socket_read_itti_message(socket_data_t *socket_data,
g_assert_not_reached();
}
buffer->message_number = itti_signal_header.message_number;
sscanf (itti_signal_header.message_number_char, MESSAGE_NUMBER_CHAR_FORMAT, &buffer->message_number);
// buffer_dump(buffer, stdout);
/* Update the number of signals received since last GUI update */
......@@ -127,7 +127,7 @@ static int socket_read_itti_message(socket_data_t *socket_data,
socket_notify_gui_update(socket_data);
}
g_debug("Successfully read new signal %u from socket", itti_signal_header.message_number);
g_debug("Successfully read new signal %u from socket", buffer->message_number);
return total_data_read + sizeof(itti_signal_header);
}
......
......@@ -223,7 +223,7 @@ int ui_messages_read(char *file_name)
g_assert_not_reached ();
}
buffer->message_number = itti_signal_header->message_number;
sscanf (itti_signal_header->message_number_char, MESSAGE_NUMBER_CHAR_FORMAT, &buffer->message_number);
ui_signal_add_to_list (buffer, ((read_messages % 1000) == 0) ? (gpointer) 1 : NULL);
......@@ -305,7 +305,8 @@ static void ui_message_write_callback(const gpointer buffer, const gchar *signal
message_header.message_size = sizeof(itti_socket_header_t) + sizeof(itti_signal_header) + message_size + sizeof(itti_message_types_t);
message_header.message_type = ITTI_DUMP_MESSAGE_TYPE;
itti_signal_header.message_number = message_number;
sprintf(itti_signal_header.message_number_char, MESSAGE_NUMBER_CHAR_FORMAT, message_number);
itti_signal_header.message_number_char[sizeof(itti_signal_header.message_number_char) - 1] = '\n';
message_number++;
fwrite (&message_header, sizeof(message_header), 1, messages_file);
......
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