Commit 713ec0c1 authored by Thanassis Tsiodras's avatar Thanassis Tsiodras

Install the MSC tracing-related tools

parent 1d30b24a
......@@ -10,6 +10,12 @@ make || exit 1
cp ./MSC-Antlr3/bin/msc2py.exe ${PREFIX}/share/asn1scc/ || exit 1
cp ./MSC-Antlr3/bin/taste-extract-asn-from-design.exe ${PREFIX}/share/asn1scc/ || exit 1
# Install the MSC tracing-related tools (tracerd.py, etc)
cd $DIR/../misc/AutoGUI || exit 1
TARGET=${PREFIX}/share/AutoGUI/
mkdir -p ${TARGET}
cp -u * ${TARGET}
# Update the path
PATH_CMD='export PATH=$PATH:$HOME/.local/bin'
UpdatePATH
# The directories containing the source files, separated by ':'
VPATH=.:../../auto-src
# To make "debug" the default configuration if invoked with just "make":
#
ifeq ($(CFG),)
CFG=debug
endif
# The source files: regardless of where they reside in the source tree,
# VPATH will locate them...
Group0_SRC = project2app.cpp telecmds.cpp
Group1_SRC = DataView.c asn1crt.c real.c queue_manager.c timeInMS.c debug_messages.c acn.c xer.c ber.c PrintTypes.c PrintTypesAsASN1.c
# Build a Dependency list and an Object list, by replacing the .cpp
# extension to .d for dependency files, and .o for object files.
Group0_DEP = $(patsubst %.cpp, deps/Group0_%.d, ${Group0_SRC})
Group1_DEP = $(patsubst %.c, deps/Group1_%.d, ${Group1_SRC})
Group0_OBJ = $(patsubst %.cpp, objs.$(CFG)/Group0_%.o, ${Group0_SRC})
Group1_OBJ = $(patsubst %.c, objs.$(CFG)/Group1_%.o, ${Group1_SRC})
# Your final binary
TARGET=applicationName
# What compiler to use for generating dependencies: it will be invoked with -MM
CCDEP = g++
CXXDEP = g++
CPPFLAGS = $(shell wx-config --cppflags || exit 1)
# What include flags to pass to the compiler
INCLUDEFLAGS= -I. -I../../auto-src ${CPPFLAGS}
# Separate compile options per configuration
ifeq ($(CFG),debug)
CXXFLAGS += -g -Wall ${INCLUDEFLAGS} -DwxUSE_UNICODE
else
CXXFLAGS += -O2 -Wall ${INCLUDEFLAGS} $(shell wx-config --cxxflags) -DwxUSE_UNICODE
endif
# A common link flag for all configurations
# hardcoded "-m32" to crash 64bit distros, since the native encodings won't verifiably
# work between 32bit linux binaries and 64bit GUIs.
LDFLAGS = $(shell wx-config --libs) -lrt
all: inform ConstraintErrors.inc bin.$(CFG)/${TARGET}
ConstraintErrors.inc: DataView.h
perl ./buildErrorCheck.pl DataView.h
inform:
ifneq ($(CFG),release)
ifneq ($(CFG),debug)
@echo "Invalid configuration "$(CFG)" specified."
@echo "You must specify a configuration when running make, e.g."
@echo "make CFG=debug"
@echo
@echo "Possible choices for configuration are 'release' and 'debug'"
@exit 1
endif
endif
@echo "Configuration "$(CFG)
@echo "------------------------"
bin.$(CFG)/${TARGET}: ${Group0_OBJ} ${Group1_OBJ} | inform
@mkdir -p bin.$(CFG)
$(CXX) -g -o $@ $^ ${LDFLAGS}
objs.$(CFG)/Group0_%.o: %.cpp
@mkdir -p objs.$(CFG)
$(CXX) -c $(CXXFLAGS) -o $@ $<
objs.$(CFG)/Group1_%.o: %.c
@mkdir -p objs.$(CFG)
$(CC) -c $(subst -Wall,,$(CXXFLAGS)) -o $@ $<
deps/Group0_%.d: %.cpp ConstraintErrors.inc
@mkdir -p deps
@echo Generating dependencies for $<
@set -e ; $(CXXDEP) -MM $(INCLUDEFLAGS) $< > $@.$$$$; \
sed 's,\($*\)\.o[ :]*,objs.$(CFG)\/Group0_\1.o $@ : ,g' < $@.$$$$ > $@; \
rm -f $@.$$$$
deps/Group1_%.d: %.c ConstraintErrors.inc
@mkdir -p deps
@echo Generating dependencies for $<
@set -e ; $(CCDEP) -MM $(INCLUDEFLAGS) $< > $@.$$$$; \
sed 's,\($*\)\.o[ :]*,objs.$(CFG)\/Group0_\1.o $@ : ,g' < $@.$$$$ > $@; \
rm -f $@.$$$$
clean:
@rm -rf deps objs.debug objs.release bin.debug bin.release
# Unless "make clean" is called, include the dependency files
# which are auto-generated. Don't fail if they are missing
# (-include), since they will be missing in the first invocation!
ifneq ($(MAKECMDGOALS),clean)
-include ${Group0_DEP} ${Group1_DEP}
endif
This diff is collapsed.
#!/usr/bin/perl -w
use strict;
open OUT, ">ConstraintErrors.inc";
open DATA, "grep 'efine ERR_' ../../auto-src/".$ARGV[0]."|";
my $first = 1;
while(<DATA>) {
chomp;
my $line = $_;
if (m/^#define\s+(ERR_\w+)\s+(\d+)/) {
my $errCode = $2;
if ($first) {
$first = 0;
print OUT "if (ErrCode == $errCode) {\n";
} else {
print OUT "} else if (ErrCode == $errCode) {\n";
}
$line =~ s#^\#define\s+ERR_asn1Scc(\w+)\s+\d+\s+/\*(.*?)\*/#$1 $2#;
$line =~ s# *##g;
print OUT " msg += string(\"$line\");\n";
}
}
close DATA;
if (!$first) {
print OUT "}\n";
}
close OUT;
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include "debug_messages.h"
// debug_printf is used for logging and error reporting
void debug_printf(DebugLevel level, const char *fmt, ...)
{
static int bFirstTime = 1;
static int bPrintsEnabled = 0;
static char message[4096];
if (bFirstTime) {
bFirstTime = 0;
bPrintsEnabled = (NULL != getenv("ASSERT_DEBUG"))?1:0;
}
if (level == LVL_ERROR)
printf("%s\n", "***** ERROR just happened: *****");
if (((level == LVL_INFO || level == LVL_WARN) && bPrintsEnabled) ||
level == LVL_ERROR ||
level == LVL_PANIC)
{
va_list ap;
va_start(ap, fmt);
vsnprintf(message, sizeof message, fmt, ap);
printf("%s", message);
va_end(ap);
}
if (level == LVL_PANIC)
exit(1);
}
#ifndef __DEBUG_MESSAGES_H__
#define __DEBUG_MESSAGES_H__
#ifdef __cplusplus
extern "C" {
#endif
// debug_printf is used for logging and error reporting
//
typedef enum tagDebugLevel {
LVL_INFO,
LVL_WARN,
LVL_ERROR,
LVL_PANIC
} DebugLevel;
void debug_printf(DebugLevel level, const char *fmt, ...);
#ifdef __cplusplus
}
#endif
#endif
/////////////////////////////////////////////////////////////////////////////
// Name: project2app.cpp
// Purpose:
// Author: GUI Designer
// Modified by:
// Created: 08/07/2008 14:39:30
// RCS-ID:
// Copyright:
// Licence:
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
////@begin includes
////@end includes
#include "project2app.h"
#include "telecmds.h"
////@begin XPM images
////@end XPM images
/*!
* Application instance implementation
*/
////@begin implement app
IMPLEMENT_APP( Project2App )
////@end implement app
/*!
* Project2App type definition
*/
IMPLEMENT_CLASS( Project2App, wxApp )
/*!
* Project2App event table definition
*/
BEGIN_EVENT_TABLE( Project2App, wxApp )
////@begin Project2App event table entries
////@end Project2App event table entries
END_EVENT_TABLE()
/*!
* Constructor for Project2App
*/
Project2App::Project2App()
{
Init();
}
/*!
* Member initialisation
*/
void Project2App::Init()
{
////@begin Project2App member initialisation
////@end Project2App member initialisation
}
/*!
* Initialisation for Project2App
*/
bool Project2App::OnInit()
{
////@begin Project2App initialisation
// Remove the comment markers above and below this block
// to make permanent changes to the code.
#if wxUSE_XPM
wxImage::AddHandler(new wxXPMHandler);
#endif
#if wxUSE_LIBPNG
wxImage::AddHandler(new wxPNGHandler);
#endif
#if wxUSE_LIBJPEG
wxImage::AddHandler(new wxJPEGHandler);
#endif
#if wxUSE_GIF
wxImage::AddHandler(new wxGIFHandler);
#endif
////@end Project2App initialisation
TeleCmds *frame = new TeleCmds(NULL);
frame->Show(TRUE);
SetTopWindow(frame);
return true;
}
/*!
* Cleanup for Project2App
*/
int Project2App::OnExit()
{
////@begin Project2App cleanup
return wxApp::OnExit();
////@end Project2App cleanup
}
/////////////////////////////////////////////////////////////////////////////
// Name: project2app.h
// Purpose:
// Author: GUI Designer
// Modified by:
// Created: 08/07/2008 14:39:30
// RCS-ID:
// Copyright:
// Licence:
/////////////////////////////////////////////////////////////////////////////
#ifndef _PROJECT2APP_H_
#define _PROJECT2APP_H_
/*!
* Includes
*/
////@begin includes
#include "wx/image.h"
////@end includes
/*!
* Forward declarations
*/
////@begin forward declarations
////@end forward declarations
/*!
* Control identifiers
*/
////@begin control identifiers
////@end control identifiers
/*!
* Project2App class declaration
*/
class Project2App: public wxApp
{
DECLARE_CLASS( Project2App )
DECLARE_EVENT_TABLE()
public:
/// Constructor
Project2App();
void Init();
/// Initialises the application
virtual bool OnInit();
/// Called on exit
virtual int OnExit();
////@begin Project2App event handler declarations
////@end Project2App event handler declarations
////@begin Project2App member function declarations
////@end Project2App member function declarations
////@begin Project2App member variables
////@end Project2App member variables
};
/*!
* Application instance declaration
*/
////@begin declare app
DECLARE_APP(Project2App)
////@end declare app
#endif
// _PROJECT2APP_H_
This diff is collapsed.
#ifndef _QUEUE_UTILITIES_H
#define _QUEUE_UTILITIES_H
/* Written by Cyril Colombo, 2006 */
#ifdef __cplusplus
extern "C" {
#endif
#include <mqueue.h> //Includes POSIX queue management system, see http://www.opengroup.org/
#include "timeInMS.h"
//
//This package allows to wrap POSIX management queues for the need of
//message passing in the frame of GUI management in the frae of the ASSERT
//project.
//
//Basically, this package allows :
// - To create a queue given caracteristics wanted for this queue, mainly
// its size. The queue can contain any type of data provided the biggest
// element size to be stored in the queue is properly provided at creation.
// e.g. : The queue may be used to store integers, floats and even structures.
// The maximum element size to be provided at creation of the queue will
// then be the size of the biggest type to be handled by the queue.
// The other size parameter (max_msg_nubmer) detemrnines the number of message
// to be handled.
//
//Warning : Storing a pointer in the queue may be dangerous, because nothing
// assure for sure that the adresse will reference the same data area
// on both the consumer and producer side.
//
// - To read and write elements inside the queue. Note that it is forseen that
// messages to be exchanged shall be some records, whose first field in an
// enumerated type (int) to be used as a dsicriminant for the rest of the
// message (functional part of the massage, that could be a structure of
// the usefull fonctional data).
//
// - To delete an existing queue.
//
//
// Exported function declaration
//
//This function creates a queue for message sharing
//
// queue_name : [in] Name of the queue to be created
// max_msg_nubmer : [in] Maximum number of messages to be put in the queue
// max_msg_size : [in] Maximum message size. Message can be of different type, so
// this corresponds to the size of the biggest message type
// p_queue_id : [out] Pointer on a message queue handling structure
//
// Returns : 0 on success, -1 otherwise
//
int create_exchange_queue(char* queue_name, long max_msg_nubmer, long max_msg_size, mqd_t* p_queue_id);
//
//This function retrieves a single message from a queue create_exchange_queue
//
// queue_id : [in] Handle to the queue adressed as returned by
// max_message_length : [in] Maximum size of an element to be stored in the queue
// (functional data plus discriminant) in bytes
// message_data_recieved: [out] Pointer on the functional data retrieved in the queue
// Note that this buffer only contains the functional part
// of the message and not the first field allowing to identify
// the message type.
// message_recieved_type: [out] Identifier of the type of message recieved.
//
// Returns : 0 on success, -1 otherwise
//
int retrieve_message_from_queue(mqd_t queue_id, long max_message_length, void* message_data_recieved, int* message_recieved_type);
//
//This function writes a single message from a queue create_exchange_queue
//
// queue_id : [in] Handle to the queue adressed as returned by
// message_data_length : [in] Size of the functional data (ie. without discriminant) to be written in bytes
// message_data_sent : [in] Pointer on the functional data to be written in the queue
// Note that this buffer only contains the functional part
// of the message and not the first field allowing to identify
// the message type.
// message_recieved_type: [in] Identifier of the type of message to be sent
//
// Returns : 0 on success, -1 otherwise
//
int write_message_to_queue(mqd_t queue_id, long message_data_length, void* message_data_sent, int message_sent_type);
//
//This function destroy an existing exchange queue
//
// queue_name : [in] Name of the queue to be created
// queue_id : [out] Pointer on the handle to the queue adressed as opened by oSpen_exchange_queue_for_reading
// Returns : 0 on success, -1 otherwise
//
int open_exchange_queue_for_reading(char* queue_name, mqd_t* queue_id);
int open_exchange_queue_for_writing(char* queue_name, mqd_t* queue_id);
//
//This function destroy an existing exchange queue
//
// queue_id : [in] Handle to the queue adressed as returned by create_exchange_queue
// queue_name : [in] Name of the queue to be created
//
// Returns : 0 on success, -1 otherwise
//
int delete_exchange_queue(mqd_t queue_id, char* queue_name);
#ifdef __cplusplus
}
#endif
#endif
#include "timeInMS.h"
long long getTimeInMilliseconds()
{
#ifdef __linux__
struct timespec tv;
clock_gettime(CLOCK_MONOTONIC, &tv);
long long val = 1000000000LL*(long long)tv.tv_sec + (long long)tv.tv_nsec;
return val;
#else
return 0LL;
#endif
}
#ifndef __TIMEINMS_H__
#define __TIMEINMS_H__
#if __STDC_VERSION__ >= 199901L
#ifndef _XOPEN_SOURCE
#define _XOPEN_SOURCE 600
#endif
#else
#ifndef _XOPEN_SOURCE
#define _XOPEN_SOURCE 500
#endif
#endif /* __STDC_VERSION__ */
#include <time.h>
long long getTimeInMilliseconds(void);
#endif
#!/usr/bin/env python
import os
import sys
import subprocess
import socket
import re
import signal
import errno
import cPickle
from tracerCommon import RenderParameterFields
g_messageId = 512
g_clientSocket = None
g_clientSocket2 = None
g_bNoParams = False
def Message(senderID, receiverID, timestamp, message, messageData, sender,
receiver):
''' Send a message to tracerd ; messageData is a list of tuples
(ASN.1 Type, FieldName Value)
'''
if not g_bNoParams:
message = RenderParameterFields(message, ",".join(
[tup[1] for tup in messageData]))
global g_messageId
newId = '0x%02x' % g_messageId
g_messageId += 1
s = 'messageSent| -t%s| %s| %s| %s|\n' % \
(timestamp, senderID, newId, message)
g_clientSocket.send(s)
#print s
g_clientSocket2.send("PICKLED!@#$TC"
"###{timestamp}"
"###{sender_hex}"
"###{msg}"
"###{data}"
"###{receiver_hex}"
"###TC!@#$END!@#$".format(
timestamp=int(timestamp),
sender_hex=sender,
receiver_hex=receiver,
msg=message,
data=cPickle.dumps(messageData)))
s = 'messageReceived| -t%s| %s| %s| %s|\n' % \
(timestamp, receiverID, newId, message)
#print s
g_clientSocket.send(s)
g_clientSocket2.send("PICKLED!@#$TM"
"###{timestamp}"
"###{receiver_hex}"
"###{msg}"
"###{data}"
"###{sender_hex}"
"###TC!@#$END!@#$".format(
timestamp=int(timestamp),
receiver_hex=receiver,
sender_hex=sender,
msg=message,
data=cPickle.dumps(messageData)))
def main():
if "-noParams" in sys.argv:
global g_bNoParams
g_bNoParams = True
sys.argv.remove("-noParams")
if len(sys.argv) != 4:
print "Usage:", sys.argv[0], "[-noParams] <application>"
print "where ipaddress and port point to the tracerd port."
sys.exit(1)
try:
#ipaddress, port = sys.argv[1:3]
ipaddress, port = "127.0.0.1", 27182
global g_clientSocket, g_clientSocket2
g_clientSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
g_clientSocket.connect((ipaddress, port))
g_clientSocket2 = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
g_clientSocket2.connect((ipaddress, port+1))
except:
print "Could not connect to tracerd..."
sys.exit(1)
else:
print 'Connected to tracerd'
os.putenv("TASTE_INNER_MSC", "1")
os.putenv("ASSERT_IGNORE_GUI_ERRORS", "1")
p = None
try:
p = subprocess.Popen(sys.argv[3], stdout=subprocess.PIPE)
messageData = {}
tasks = {}
for line in iter(p.stdout.readline, ''):
</