mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
added periodic debugging output to OPAL client: AsyncIP
ModelTime CpuTime Sequence no 1st Value git-svn-id: https://zerberus.eonerc.rwth-aachen.de:8443/svn/s2ss/trunk@253 8ec27952-4edc-4aab-86aa-e87bb2611832
This commit is contained in:
parent
9a088f3080
commit
b3268247c2
1 changed files with 59 additions and 0 deletions
|
@ -21,6 +21,8 @@
|
|||
#include <sys/wait.h>
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <time.h>
|
||||
|
||||
#if defined(__QNXNTO__)
|
||||
# include <process.h>
|
||||
|
@ -48,6 +50,10 @@
|
|||
#define ASYNC_SHMEM_SIZE atoi(argv[2])
|
||||
#define PRINT_SHMEM_NAME argv[3]
|
||||
|
||||
#ifdef DEBUG // TODO: workaround
|
||||
struct msg *msg_send = NULL;
|
||||
#endif /* DEBUG */
|
||||
|
||||
static void *SendToIPPort(void *arg)
|
||||
{
|
||||
unsigned int SendID = 1;
|
||||
|
@ -64,6 +70,10 @@ static void *SendToIPPort(void *arg)
|
|||
struct msg msg = MSG_INIT(0);
|
||||
int msg_size;
|
||||
|
||||
#ifdef DEBUG // TODO: workaround
|
||||
msg_send = &msg;
|
||||
#endif /* DEBUG */
|
||||
|
||||
OpalPrint("%s: SendToIPPort thread started\n", PROGNAME);
|
||||
|
||||
OpalGetNbAsyncSendIcon(&nbSend);
|
||||
|
@ -235,6 +245,23 @@ static void *RecvFromIPPort(void *arg)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void Tick(int sig, siginfo_t *si, void *ptr)
|
||||
{
|
||||
Opal_GenAsyncParam_Ctrl *IconCtrlStruct;
|
||||
unsigned long long CpuTime;
|
||||
double ModelTime;
|
||||
|
||||
if (!msg_send)
|
||||
return;
|
||||
|
||||
IconCtrlStruct = (Opal_GenAsyncParam_Ctrl*) si->si_value.sival_ptr;
|
||||
|
||||
OpalGetAsyncModelTime(IconCtrlStruct, &CpuTime, &ModelTime)
|
||||
|
||||
OpalPrint("%s: TICK! CpuTime: %llu\tModelTime: %f\tSequence: %hu\tValue: %f\n",
|
||||
PROGNAME, CpuTime, ModelTime, msg_send->sequence, msg_send->data[0].f);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int err;
|
||||
|
@ -275,11 +302,39 @@ int main(int argc, char *argv[])
|
|||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Initialize socket */
|
||||
if (InitSocket(IconCtrlStruct) != EOK) {
|
||||
OpalPrint("%s: ERROR: Initialization failed.\n", PROGNAME);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
/* Setup signals */
|
||||
struct sigaction sa_tick = {
|
||||
.sa_flags = SA_SIGINFO,
|
||||
.sa_sigaction = Tick
|
||||
};
|
||||
|
||||
sigemptyset(&sa_tick.sa_mask);
|
||||
sigaction(SIG, &sa_tick, NULL);
|
||||
|
||||
/* Setup timer */
|
||||
timer_t t;
|
||||
struct sigevent sev = {
|
||||
.sigev_notify = SIGEV_SIGNAL,
|
||||
.sigev_signo = SIG,
|
||||
.sigev_value.sival_ptr = &IconCtrlStruct
|
||||
};
|
||||
|
||||
struct itimerspec its = {
|
||||
.it_interval = { 1, 0 },
|
||||
.it_value = { 0, 1 }
|
||||
};
|
||||
|
||||
timer_create(CLOCK_REALTIME, &sev, &t);
|
||||
timer_settime(t, 0, &its, NULL);
|
||||
#endif /* DEBUG */
|
||||
|
||||
/* Start send/receive threads */
|
||||
if ((pthread_create(&tid_send, NULL, SendToIPPort, NULL)) == -1)
|
||||
OpalPrint("%s: ERROR: Could not create thread (SendToIPPort), errno %d\n", PROGNAME, errno);
|
||||
|
@ -297,5 +352,9 @@ int main(int argc, char *argv[])
|
|||
OpalCloseAsyncMem (ASYNC_SHMEM_SIZE, ASYNC_SHMEM_NAME);
|
||||
OpalSystemCtrl_UnRegister(PRINT_SHMEM_NAME);
|
||||
|
||||
#ifdef DEBUG
|
||||
timer_delete(t);
|
||||
#endif /* DEBUG */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue