From: hadaq Date: Wed, 21 Oct 2009 13:39:43 +0000 (+0000) Subject: ctr X-Git-Tag: v6.0~318 X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=8ce4e0acbccbe7011900331b6a29f54dec9ad1cc;p=trbnettools.git ctr --- diff --git a/libtrbnet/trbcmd.c b/libtrbnet/trbcmd.c index 1cbccc9..b45ed0e 100644 --- a/libtrbnet/trbcmd.c +++ b/libtrbnet/trbcmd.c @@ -16,7 +16,7 @@ static int hexMode = HEXMODE; -static const char trbcmd_version[] = "$Revision: 2.32 $"; +static const char trbcmd_version[] = "$Revision: 2.33 $"; /* ---- User Buffer Size ----------------------------------------------- */ @@ -44,29 +44,36 @@ void usage(const char *progName) "as hexadecimal-numbers\n"); printf(" -V Version number\n"); printf("\nCommands:\n"); - printf(" r -> read register\n"); - printf(" w -> write register\n"); - printf(" rm -> read " - "register-memory\n"); - printf(" wm -> write to " - "register-memory from ASCII-file ('-' = stdin)\n"); - printf(" i -> read unique ID\n"); - printf(" s -> set trb-address\n"); - printf(" T -> send trigger\n"); - printf(" TR -> send trigger to " - "RICH only\n"); - printf(" I -> read IPU data\n"); - printf(" reload -> reload FPGA\n"); - printf(" reset -> reset " - "TRBNetwork\n"); - printf(" f -> flush FIFO of " - "channel\n"); - printf(" R -> " - "read register of the FPGA" - " \n"); - printf(" W -> " - "write to register of the FPGA" - " \n"); + printf(" r -> " + "read register\n"); + printf(" w -> " + "write register\n"); + printf(" rm -> " + "read register-memory\n"); + printf(" wm -> " + "write to register-memory from ASCII-file ('-' = stdin)\n"); + printf(" i -> " + "read unique ID\n"); + printf(" s -> " + "set trb-address\n"); + printf(" T -> " + "send trigger\n", '%'); + printf(" TR -> " + "send trigger to RICH only\n", '%'); + printf(" I -> " + "read IPU data\n", '%'); + printf(" reload -> " + "reload FPGA\n"); + printf(" reset -> " + "reset TRBNetwork\n"); + printf(" f -> " + "flush FIFO of channel\n"); + printf(" R -> " + "read register of the FPGA\n"); + + printf(" W -> " + "write to register of the FPGA\n"); + } #define CMD_SIZE 256 @@ -84,6 +91,7 @@ int main(int argc, char ** argv) uint16_t reg_address = 0; int loop = 1; int loopCtr = 0; + uint16_t trgCtr = 0; /* counter for the %ctr option */ int opt; /* LowMem Settings, i.e. 3 MBye maximum */ @@ -632,8 +640,16 @@ int main(int argc, char ** argv) type = strtoul(cmd[1], NULL, hexMode == 1 ? 16 : 0) & 0x0f; random = strtoul(cmd[2], NULL, hexMode == 1 ? 16 : 0); info = strtoul(cmd[3], NULL, hexMode == 1 ? 16 : 0); - number = strtoul(cmd[4], NULL, hexMode == 1 ? 16 : 0); - + if (strncmp(cmd[4], "%ctr", CMD_SIZE) == 0) { + if (scriptFile == NULL) { + usage(basename(argv[0])); + exit(EXIT_FAILURE); + } + number = trgCtr++; + } else { + number = strtoul(cmd[4], NULL, hexMode == 1 ? 16 : 0); + } + /* DEBUG Info */ if (trb_debug > 0) { fprintf(stderr, @@ -777,8 +793,17 @@ int main(int argc, char ** argv) type = strtoul(cmd[2], NULL, hexMode == 1 ? 16 : 0) & 0x0f; random = strtoul(cmd[3], NULL, hexMode == 1 ? 16 : 0); info = strtoul(cmd[4], NULL, hexMode == 1 ? 16 : 0); - number = strtoul(cmd[5], NULL, hexMode == 1 ? 16 : 0); - + + if (strncmp(cmd[5], "%ctr", CMD_SIZE) == 0) { + if (scriptFile == NULL) { + usage(basename(argv[0])); + exit(EXIT_FAILURE); + } + number = trgCtr++; + } else { + number = strtoul(cmd[5], NULL, hexMode == 1 ? 16 : 0); + } + /* DEBUG Info */ if (trb_debug > 0) { fprintf(stderr, @@ -837,8 +862,16 @@ int main(int argc, char ** argv) type = strtoul(cmd[1], NULL, hexMode == 1 ? 16 : 0) & 0x0f; random = strtoul(cmd[2], NULL, hexMode == 1 ? 16 : 0); info = strtoul(cmd[3], NULL, hexMode == 1 ? 16 : 0); - number = strtoul(cmd[4], NULL, hexMode == 1 ? 16 : 0); - + if (strncmp(cmd[4], "%ctr", CMD_SIZE) == 0) { + if (scriptFile == NULL) { + usage(basename(argv[0])); + exit(EXIT_FAILURE); + } + number = trgCtr; + } else { + number = strtoul(cmd[4], NULL, hexMode == 1 ? 16 : 0); + } + /* DEBUG Info */ if (trb_debug > 0) { fprintf(stderr,