-static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/memnet.c,v 6.18 2004-08-13 10:30:00 hadaq Exp $";
+static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/memnet.c,v 6.19 2007-01-26 15:56:04 hadaq Exp $";
#define _POSIX_C_SOURCE 199309L
#define SYSLOG_NAMES
#include <unistd.h>
+#include <getopt.h>
#include <stddef.h>
unsigned long priority;
unsigned long queueSize;
char verbosity[PARAM_MAX_VALUE_LEN];
+ char shmnum[PARAM_MAX_VALUE_LEN];
} TheArgs;
static jmp_buf terminateJmp;
{
syslog(LOG_ERR, "Usage: %s [-a (agentCtrl)] -o outPath", progName);
syslog(LOG_ERR, "Usage: [-w bandwidth] [-p priority] [-q queueSize]");
+ syslog(LOG_ERR, "Usage: [--shmnum unique number for shared memory]" );
}
static void argsDump(TheArgs *my)
syslog(LOG_DEBUG, "isStandalone: %d", my->isStandalone);
syslog(LOG_DEBUG, "queueSize: %d", my->queueSize);
syslog(LOG_DEBUG, "verbosity: %s", my->verbosity);
+ if(my->shmnum != 0){
+ syslog (LOG_DEBUG, "shmnum: %d", my->shmnum);
+ }
}
static void argsDefault(TheArgs *my)
my->isStandalone = 1;
my->queueSize = 1 * 1024 * 1024;
strcpy(my->verbosity, "info");
+ strcpy(my->shmnum, "");
}
static int argsFromCL(TheArgs *my, int argc, char *argv[])
{
extern char *optarg;
int i;
-
- while ((i = getopt(argc, argv, "aw:q:o:p:v:")) != -1) {
- switch (i) {
- case 'w':
- my->bandWidth = atoi(optarg);
- break;
- case 'o':
- strcpy(my->outPath, optarg);
- break;
- case 'a':
- my->isStandalone = 0;
- break;
- case 'p':
- my->priority = atoi(optarg);
- break;
- case 'q':
- my->queueSize = atoi(optarg);
- break;
- case 'v':
- strcpy(my->verbosity, optarg);
- break;
- default:
- return -1;
- break;
- }
- }
+ int option_index = 0;
+
+ while (1)
+ {
+ static struct option long_options[] =
+ {
+ {"shmnum", 1, 0, 'z'},
+ {0, 0, 0, 0}
+ };
+
+ i = getopt_long (argc, argv, "aw:q:o:p:v:z:",
+ long_options, &option_index);
+
+ if (i == -1)
+ break;
+
+ switch (i) {
+ case 'w':
+ my->bandWidth = atoi(optarg);
+ break;
+ case 'o':
+ strcpy(my->outPath, optarg);
+ break;
+ case 'a':
+ my->isStandalone = 0;
+ break;
+ case 'p':
+ my->priority = atoi(optarg);
+ break;
+ case 'q':
+ my->queueSize = atoi(optarg);
+ break;
+ case 'v':
+ strcpy(my->verbosity, optarg);
+ break;
+ case 'z':
+ strcpy(my->shmnum, optarg);
+ break;
+ default:
+ return -1;
+ break;
+ }
+ }
return 0;
}
ShmTrans *shmTrans;
int exitStat;
+ char shmname[PARAM_MAX_VALUE_LEN] = "subevtqueue";
+
openlog(argv[0], LOG_PID | LOG_PERROR, LOG_LOCAL0);
setlogmask(LOG_UPTO(LOG_INFO));
-
argsDefault(theArgs);
argsFromParam(theArgs, argc, argv);
if (0 > argsFromCL(theArgs, argc, argv)) {
argsDump(theArgs);
+ /* give unique name to shared memory*/
+ strcat(shmname, theArgs->shmnum);
+
if (strcmp(theArgs->outPath, "") == 0) {
usage(argv[0]);
exit(EXIT_FAILURE);
exitStat = EXIT_FAILURE;
goto bailOut0;
}
- if (NULL == (shmTrans = ShmTrans_create("subevtqueue", 2 * theArgs->queueSize))) {
- syslog(LOG_ERR, "creating shared memory \"subevtqueue\": %s"), strerror(errno);
+ if (NULL == (shmTrans = ShmTrans_create(shmname, 2 * theArgs->queueSize))) {
+ syslog(LOG_ERR, "creating shared memory \"%s\": %s"), shmname, strerror(errno);
exitStat = EXIT_FAILURE;
goto bailOut1;
}
-static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/readout.c,v 6.30 2006-04-11 17:39:31 hadaq Exp $";
+static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/readout.c,v 6.31 2007-01-26 15:57:00 hadaq Exp $";
#define _POSIX_C_SOURCE 199309L
#define SYSLOG_NAMES
#include <unistd.h>
#include "grmblfx.h"
+#include <getopt.h>
#include <errno.h>
#include <stdlib.h>
unsigned long priority;
unsigned long queueSize;
char verbosity[PARAM_MAX_VALUE_LEN];
- char subsystem[PARAM_MAX_VALUE_LEN];
+ char subsystem[PARAM_MAX_VALUE_LEN];
+ char shmnum[PARAM_MAX_VALUE_LEN];
} TheArgs;
static jmp_buf terminateJmp;
{
syslog(LOG_ERR, "Usage: %s [-a (agentCtrl)] [-p priority]", progName);
syslog(LOG_ERR, "Usage: [-q queueSize] [-w waterMark]");
+ syslog(LOG_ERR, "Usage: [--shmnum unique number for shared memory]" );
}
static void argsDump(TheArgs *my)
syslog(LOG_DEBUG, "queueSize: %d", my->queueSize);
syslog(LOG_DEBUG, "verbosity: %s", my->verbosity);
syslog(LOG_DEBUG, "subsystem: %s", my->subsystem);
+ if(my->shmnum != 0){
+ syslog (LOG_DEBUG, "shmnum: %d", my->shmnum);
+ }
}
static void argsDefault(TheArgs *my)
my->queueSize = 1 * 1024 * 1024;
strcpy(my->verbosity, "info");
strcpy(my->subsystem, "unknown");
+ strcpy(my->shmnum, "");
}
static int argsFromCL(TheArgs *my, int argc, char *argv[])
{
- extern char *optarg;
+ extern char *optarg;
int i;
-
- while ((i = getopt(argc, argv, "w:ap:q:s:v:")) != -1) {
- switch (i) {
- case 'w':
- my->waterMark = atoi(optarg);
- break;
- case 'a':
- my->isStandalone = 0;
- break;
- case 'p':
- my->priority = atoi(optarg);
- break;
- case 'q':
- my->queueSize = atoi(optarg);
- break;
- case 's':
- strcpy(my->subsystem, optarg);
- break;
- case 'v':
- strcpy(my->verbosity, optarg);
- break;
- default:
- return -1;
- break;
- }
- }
+ int option_index = 0;
+
+ while (1)
+ {
+ static struct option long_options[] =
+ {
+ {"shmnum", 1, 0, 'z'},
+ {0, 0, 0, 0}
+ };
+
+ i = getopt_long (argc, argv, "w:ap:q:s:v:z:",
+ long_options, &option_index);
+
+ if (i == -1)
+ break;
+
+ switch (i) {
+ case 'w':
+ my->waterMark = atoi(optarg);
+ break;
+ case 'a':
+ my->isStandalone = 0;
+ break;
+ case 'p':
+ my->priority = atoi(optarg);
+ break;
+ case 'q':
+ my->queueSize = atoi(optarg);
+ break;
+ case 's':
+ strcpy(my->subsystem, optarg);
+ break;
+ case 'v':
+ strcpy(my->verbosity, optarg);
+ break;
+ case 'z':
+ strcpy(my->shmnum, optarg);
+ break;
+
+ default:
+ return -1;
+ break;
+ }
+ }
return 0;
}
unsigned long *subevtsRead;
unsigned long *subevtsDataErr;
+ char shmname[PARAM_MAX_VALUE_LEN] = "subevtqueue";
+
openlog(argv[0], LOG_PID | LOG_PERROR, LOG_LOCAL0);
setlogmask(LOG_UPTO(LOG_INFO));
- LVme_registerLogMsg(syslog);
-
argsDefault(theArgs);
argsFromParam(theArgs, argc, argv);
if (0 > argsFromCL(theArgs, argc, argv)) {
argsDump(theArgs);
+ /* give unique name to shared memory*/
+ strcat(shmname, theArgs->shmnum);
+
+ printf("shared memory name: %s\n",shmname);
+
if (NULL == (worker = Worker_initBegin(argv[0], sigHandler, theArgs->priority, theArgs->isStandalone))) {
syslog(LOG_ERR, "connecting to agent: %s", strerror(errno));
goto bailOut0;
syslog(LOG_ERR, "initializing hardware: %s", strerror(errno));
goto bailOut1;
}
- if (NULL == (shmTrans = ShmTrans_open("subevtqueue", 2 * theArgs->queueSize))) {
- syslog(LOG_ERR, "opening shared memory \"%s\": %s", "subevtqueue", strerror(errno));
+ if (NULL == (shmTrans = ShmTrans_open(shmname, 2 * theArgs->queueSize))) {
+ syslog(LOG_ERR, "opening shared memory \"%s\": %s", shmname, strerror(errno));
goto bailOut2;
}
trigAccepted = Worker_addStatistic(worker, "trigAccepted");