printf(" -H hex-mode: all following arguments will be interpreted "
"as hexadecimal\n numbers\n");
printf("Commands:\n");
- printf(" r <trbaddress> <register> -> read register\n");
- printf(" w <trbaddress> <register> <data> -> write register\n");
- printf(" rm <trbaddress> <register> <size> <mode> "
- "-> read register-memory\n");
- printf(" wm <trbaddress> <register> <mode> <file> "
- "-> write to register-memory from ASCII-file ('-' = stdin)\n");
- printf(" i <trbaddress> -> read unique ID\n");
- printf(" s <uid> <endpoint> <trbaddress> -> set trb-address\n");
- printf(" T <input> <type> <random> <info> <number> -> trigger by "
- "slowcontrol\n");
- printf(" I <type> <random> <info> <number> -> read IPU data "
- "slowcontrol\n");
- printf(" f <channel> -> flush FIFO of "
+ printf(" r <trbaddress> <register> -> read register\n");
+ printf(" w <trbaddress> <register> <data> -> write register\n");
+ printf(" rm <trbaddress> <register> <size> <mode> -> read "
+ "register-memory\n");
+ printf(" wm <trbaddress> <register> <mode> <file> -> write to "
+ "register-memory from ASCII-file ('-' = stdin)\n");
+ printf(" i <trbaddress> -> read unique ID\n");
+ printf(" s <uid> <endpoint> <trbaddress> -> set trb-address\n");
+ printf(" T <type> <random> <info> <number> -> send trigger\n");
+ printf(" TR <input> <type> <random> <info> <number> -> send trigger to "
+ "RICH only\n");
+ printf(" I <type> <random> <info> <number> -> read IPU data\n");
+ printf(" f <channel> -> flush FIFO of "
"channel\n");
- printf(" R <register> -> "
+ printf(" R <register> -> "
"read register of the FPGA"
" \n");
- printf(" W <register> <value> -> "
+ printf(" W <register> <value> -> "
"write to register of the FPGA"
" \n");
}
while ((repeat == -1) || (cmdCtr++ < repeat)) {
- if (strcmp(argv[optind], "w") == 0) {
+ if (strcmp(argv[optind], "w") == 0) {
- /*******************************************/
- /* Register Write */
- /*******************************************/
+ /*******************************************/
+ /* Register Write */
+ /*******************************************/
- uint32_t value = 0;
+ uint32_t value = 0;
- if (argc - optind != 4) {
- usage(basename(argv[0]));
- exit(EXIT_FAILURE);
- }
+ if (argc - optind != 4) {
+ usage(basename(argv[0]));
+ exit(EXIT_FAILURE);
+ }
- trb_address = strtoul(argv[optind + 1], NULL, hexMode == 1 ? 16 : 0);
- reg_address = strtoul(argv[optind + 2], NULL, hexMode == 1 ? 16 : 0);
- value = strtoul(argv[optind + 3], NULL, hexMode == 1 ? 16 : 0);
+ trb_address = strtoul(argv[optind + 1], NULL, hexMode == 1 ? 16 : 0);
+ reg_address = strtoul(argv[optind + 2], NULL, hexMode == 1 ? 16 : 0);
+ value = strtoul(argv[optind + 3], NULL, hexMode == 1 ? 16 : 0);
- /* DEBUG Info */
- if (trb_debug > 0) {
- fprintf(stderr,
- "Command: WRITE: trb_address: 0x%04x, reg_address: 0x%04x, "
- "value: 0x%08x\n",
- trb_address, reg_address, value);
- }
+ /* DEBUG Info */
+ if (trb_debug > 0) {
+ fprintf(stderr,
+ "Command: WRITE: trb_address: 0x%04x, reg_address: 0x%04x, "
+ "value: 0x%08x\n",
+ trb_address, reg_address, value);
+ }
- if (trb_register_write(trb_address, reg_address, value) == -1) {
- trb_error("write failed");
- exit(EXIT_FAILURE);
- }
- } else if (strcmp(argv[optind], "r") == 0) {
+ if (trb_register_write(trb_address, reg_address, value) == -1) {
+ trb_error("write failed");
+ exit(EXIT_FAILURE);
+ }
+ } else if (strcmp(argv[optind], "r") == 0) {
- /*******************************************/
- /* Register Read */
- /*******************************************/
+ /*******************************************/
+ /* Register Read */
+ /*******************************************/
- int status = 0;
- uint32_t data[256];
+ int status = 0;
+ uint32_t data[256];
- if (argc - optind != 3) {
- usage(argv[0]);
- exit(EXIT_FAILURE);
- }
+ if (argc - optind != 3) {
+ usage(argv[0]);
+ exit(EXIT_FAILURE);
+ }
- trb_address = strtoul(argv[optind + 1], NULL, hexMode == 1 ? 16 : 0);
- reg_address = strtoul(argv[optind + 2], NULL, hexMode == 1 ? 16 : 0);
+ trb_address = strtoul(argv[optind + 1], NULL, hexMode == 1 ? 16 : 0);
+ reg_address = strtoul(argv[optind + 2], NULL, hexMode == 1 ? 16 : 0);
- /* DEBUG Info */
- if (trb_debug > 0) {
- fprintf(stderr,
- "Command: READ: trb_address: 0x%04x, "
- "reg_address: 0x%04x\n",
- trb_address, reg_address);
- }
+ /* DEBUG Info */
+ if (trb_debug > 0) {
+ fprintf(stderr,
+ "Command: READ: trb_address: 0x%04x, "
+ "reg_address: 0x%04x\n",
+ trb_address, reg_address);
+ }
- status = trb_register_read(trb_address, reg_address, data, 256);
- if (status == -1) {
- trb_error("read failed");
- exit(EXIT_FAILURE);
- }
+ status = trb_register_read(trb_address, reg_address, data, 256);
+ if (status == -1) {
+ trb_error("read failed");
+ exit(EXIT_FAILURE);
+ }
- for (i = 0; i < status; i += 2) {
- fprintf(stdout, "%s%04x %s%08x\n",
- hexMode == 1 ? "" : "0x",
- data[i],
- hexMode == 1 ? "" : "0x",
- data[i + 1]);
- }
- } else if (strcmp(argv[optind], "rm") == 0) {
+ for (i = 0; i < status; i += 2) {
+ fprintf(stdout, "%s%04x %s%08x\n",
+ hexMode == 1 ? "" : "0x",
+ data[i],
+ hexMode == 1 ? "" : "0x",
+ data[i + 1]);
+ }
+ } else if (strcmp(argv[optind], "rm") == 0) {
- /*******************************************/
- /* Register Read Memory */
- /*******************************************/
+ /*******************************************/
+ /* Register Read Memory */
+ /*******************************************/
- uint32_t *data = NULL;
- uint16_t size = 0;
- uint8_t option = 0;
- int status;
- unsigned int i;
+ uint32_t *data = NULL;
+ uint16_t size = 0;
+ uint8_t option = 0;
+ int status;
+ unsigned int i;
- if (argc - optind != 5) {
- usage(argv[0]);
- exit(EXIT_FAILURE);
- }
+ if (argc - optind != 5) {
+ usage(argv[0]);
+ exit(EXIT_FAILURE);
+ }
- trb_address = strtoul(argv[optind + 1], NULL, hexMode == 1 ? 16 : 0);
- reg_address = strtoul(argv[optind + 2], NULL, hexMode == 1 ? 16 : 0);
- size = strtoul(argv[optind + 3], NULL, hexMode == 1 ? 16 : 0);
- option = strtoul(argv[optind + 4], NULL, hexMode == 1 ? 16 : 0);
-
- /* DEBUG Info */
- if (trb_debug > 0) {
- fprintf(stderr,
- "Command: READ_MEM: trb_address: 0x%04x, "
- "reg_address: 0x%04x, "
- "size: 0x%04x, "
- "option: %d\n",
- trb_address, reg_address, size, option);
- }
+ trb_address = strtoul(argv[optind + 1], NULL, hexMode == 1 ? 16 : 0);
+ reg_address = strtoul(argv[optind + 2], NULL, hexMode == 1 ? 16 : 0);
+ size = strtoul(argv[optind + 3], NULL, hexMode == 1 ? 16 : 0);
+ option = strtoul(argv[optind + 4], NULL, hexMode == 1 ? 16 : 0);
+
+ /* DEBUG Info */
+ if (trb_debug > 0) {
+ fprintf(stderr,
+ "Command: READ_MEM: trb_address: 0x%04x, "
+ "reg_address: 0x%04x, "
+ "size: 0x%04x, "
+ "option: %d\n",
+ trb_address, reg_address, size, option);
+ }
- if ((data = malloc(sizeof(uint32_t) * size)) == NULL) abort();
+ if ((data = malloc(sizeof(uint32_t) * size)) == NULL) abort();
- status =
- trb_register_read_mem(trb_address, reg_address, option, data, size);
- if (status == -1) {
- trb_error("read_mem failed");
- if (data != NULL) free(data);
- exit(EXIT_FAILURE);
- }
+ status =
+ trb_register_read_mem(trb_address, reg_address, option, data, size);
+ if (status == -1) {
+ trb_error("read_mem failed");
+ if (data != NULL) free(data);
+ exit(EXIT_FAILURE);
+ }
- for (i = 0; i < status; i++) {
- fprintf(stdout, "%s%04x %s%08x\n",
- hexMode == 1 ? "" : "0x", reg_address + i,
- hexMode == 1 ? "" : "0x", data[i]);
- }
+ for (i = 0; i < status; i++) {
+ fprintf(stdout, "%s%04x %s%08x\n",
+ hexMode == 1 ? "" : "0x", reg_address + i,
+ hexMode == 1 ? "" : "0x", data[i]);
+ }
- if (data != NULL) free(data);
- } else if (strcmp(argv[optind], "wm") == 0) {
-
- /*******************************************/
- /* Register Write Memory */
- /*******************************************/
-
- FILE *file = NULL;
- uint32_t *data = NULL;
- unsigned int dataSize = 64;
- char *buffer = NULL;
- size_t len = 0;
- char *fileName = NULL;
- uint8_t option = 0;
- unsigned int size = 0;
- int status;
+ if (data != NULL) free(data);
+ } else if (strcmp(argv[optind], "wm") == 0) {
+
+ /*******************************************/
+ /* Register Write Memory */
+ /*******************************************/
+
+ FILE *file = NULL;
+ uint32_t *data = NULL;
+ unsigned int dataSize = 64;
+ char *buffer = NULL;
+ size_t len = 0;
+ char *fileName = NULL;
+ uint8_t option = 0;
+ unsigned int size = 0;
+ int status;
- if (argc - optind != 5) {
- usage(argv[0]);
- exit(EXIT_FAILURE);
- }
-
- trb_address = strtoul(argv[optind + 1], NULL, hexMode == 1 ? 16 : 0);
- reg_address = strtoul(argv[optind + 2], NULL, hexMode == 1 ? 16 : 0);
- option = strtoul(argv[optind + 3], NULL, hexMode == 1 ? 16 : 0);
- fileName = argv[optind + 4];
-
- /* Open inputFile and read Data into buffer */
- if (strcmp(fileName, "-") == 0) {
- file = stdin;
- } else {
- file = fopen(fileName, "r");
- if (file == NULL) {
- perror("Error opening file");
+ if (argc - optind != 5) {
+ usage(argv[0]);
exit(EXIT_FAILURE);
}
- }
- if ((data = malloc(sizeof(uint32_t) * dataSize)) == NULL) abort();
- while (getline(&buffer, &len, file) != -1) {
- if (size >= dataSize) {
- dataSize += 64;
- if ((data = realloc(data, sizeof(uint32_t) * dataSize)) == NULL) {
- abort();
+ trb_address = strtoul(argv[optind + 1], NULL, hexMode == 1 ? 16 : 0);
+ reg_address = strtoul(argv[optind + 2], NULL, hexMode == 1 ? 16 : 0);
+ option = strtoul(argv[optind + 3], NULL, hexMode == 1 ? 16 : 0);
+ fileName = argv[optind + 4];
+
+ /* Open inputFile and read Data into buffer */
+ if (strcmp(fileName, "-") == 0) {
+ file = stdin;
+ } else {
+ file = fopen(fileName, "r");
+ if (file == NULL) {
+ perror("Error opening file");
+ exit(EXIT_FAILURE);
}
}
- data[size++] = strtoul(buffer, NULL, hexMode == 1 ? 16 : 0);
- }
- if (buffer != NULL) free(buffer);
-
- /* DEBUG Info */
- if (trb_debug > 0) {
- fprintf(stderr,
- "Command: WRITE_MEM: trb_address: 0x%04x, "
- "reg_address: 0x%04x, "
- "option: %d, "
- "size: 0x%04x\n",
- trb_address, reg_address, option, size);
- }
+
+ if ((data = malloc(sizeof(uint32_t) * dataSize)) == NULL) abort();
+ while (getline(&buffer, &len, file) != -1) {
+ if (size >= dataSize) {
+ dataSize += 64;
+ if ((data = realloc(data, sizeof(uint32_t) * dataSize)) == NULL) {
+ abort();
+ }
+ }
+ data[size++] = strtoul(buffer, NULL, hexMode == 1 ? 16 : 0);
+ }
+ if (buffer != NULL) free(buffer);
+
+ /* DEBUG Info */
+ if (trb_debug > 0) {
+ fprintf(stderr,
+ "Command: WRITE_MEM: trb_address: 0x%04x, "
+ "reg_address: 0x%04x, "
+ "option: %d, "
+ "size: 0x%04x\n",
+ trb_address, reg_address, option, size);
+ }
- status = trb_register_write_mem(trb_address, reg_address, option,
- data, size);
- if (data != NULL) free(data);
+ status = trb_register_write_mem(trb_address, reg_address, option,
+ data, size);
+ if (data != NULL) free(data);
- if (status == -1) {
- trb_error("write register-memory failed");
- exit(EXIT_FAILURE);
- }
- } else if (strcmp(argv[optind], "i") == 0) {
+ if (status == -1) {
+ trb_error("write register-memory failed");
+ exit(EXIT_FAILURE);
+ }
+ } else if (strcmp(argv[optind], "i") == 0) {
- /*******************************************/
- /* ReadUId */
- /*******************************************/
+ /*******************************************/
+ /* ReadUId */
+ /*******************************************/
- uint32_t uidBuffer[128];
- unsigned int size;
+ uint32_t uidBuffer[512];
+ unsigned int size;
- if (argc - optind != 2) {
- usage(argv[0]);
- exit(EXIT_FAILURE);
- }
+ if (argc - optind != 2) {
+ usage(argv[0]);
+ exit(EXIT_FAILURE);
+ }
- trb_address = strtoul(argv[optind + 1], NULL, hexMode == 1 ? 16 : 0);
+ trb_address = strtoul(argv[optind + 1], NULL, hexMode == 1 ? 16 : 0);
- /* DEBUG Info */
- if (trb_debug > 0) {
- fprintf(stderr,
- "Command: READ_UID: trb_address: 0x%04x\n",
- trb_address);
- }
+ /* DEBUG Info */
+ if (trb_debug > 0) {
+ fprintf(stderr,
+ "Command: READ_UID: trb_address: 0x%04x\n",
+ trb_address);
+ }
- size = trb_read_uid(trb_address, uidBuffer, 128);
- if (size == -1) {
- trb_error("read_uid failed");
- exit(EXIT_FAILURE);
- }
+ size = trb_read_uid(trb_address, uidBuffer, 128);
+ if (size == -1) {
+ trb_error("read_uid failed");
+ exit(EXIT_FAILURE);
+ }
- for (i = 0; (i < size) && (i < 128); i += 3) {
- fprintf(stdout, "%s%08x%08x %s%02x\n",
- hexMode == 1 ? "" : "0x",
- uidBuffer[i],
- uidBuffer[i + 1],
- hexMode == 1 ? "" : "0x",
- uidBuffer[i + 2]);
- }
- } else if (strcmp(argv[optind], "s") == 0) {
-
- /*******************************************/
- /* SetAddress */
- /*******************************************/
+ for (i = 0; (i < size) && (i < 128); i += 4) {
+ fprintf(stdout, "0x%04x 0x%08x%08x 0x%02x\n",
+ uidBuffer[i + 3],
+ uidBuffer[i],
+ uidBuffer[i + 1],
+ uidBuffer[i + 2]);
+ }
+ } else if (strcmp(argv[optind], "s") == 0) {
- uint64_t uid = 0;
- uint8_t endpoint = 0;
- uint16_t trb_address = 0;
+ /*******************************************/
+ /* SetAddress */
+ /*******************************************/
- if (argc - optind != 4) {
- usage(argv[0]);
- exit(EXIT_FAILURE);
- }
+ uint64_t uid = 0;
+ uint8_t endpoint = 0;
+ uint16_t trb_address = 0;
- uid = strtoull(argv[optind + 1], NULL, hexMode == 1 ? 16 : 0);
- endpoint = strtoul(argv[optind + 2], NULL, hexMode == 1 ? 16 : 0);
- trb_address = strtoul(argv[optind + 3], NULL, hexMode == 1 ? 16 : 0);
-
- /* DEBUG Info */
- if (trb_debug > 0) {
- fprintf(stderr,
- "Command: SET_ADDRESS: "
- "uid: 0x%016llx, "
- "endpoint: 0x%02x, "
- "trb_address: 0x%04x\n",
- uid, endpoint, trb_address);
- }
-
- if (trb_set_address(uid, endpoint, trb_address) == -1) {
- trb_error("set_address failed");
- exit(EXIT_FAILURE);
- }
- } else if (strcmp(argv[optind], "T") == 0) {
+ if (argc - optind != 4) {
+ usage(argv[0]);
+ exit(EXIT_FAILURE);
+ }
- /*******************************************/
- /* Fake trigger function (ADCM specific) */
- /*******************************************/
+ uid = strtoull(argv[optind + 1], NULL, hexMode == 1 ? 16 : 0);
+ endpoint = strtoul(argv[optind + 2], NULL, hexMode == 1 ? 16 : 0);
+ trb_address = strtoul(argv[optind + 3], NULL, hexMode == 1 ? 16 : 0);
+
+ /* DEBUG Info */
+ if (trb_debug > 0) {
+ fprintf(stderr,
+ "Command: SET_ADDRESS: "
+ "uid: 0x%016llx, "
+ "endpoint: 0x%02x, "
+ "trb_address: 0x%04x\n",
+ uid, endpoint, trb_address);
+ }
- uint8_t input = 0;
- uint8_t type = 0;
- uint8_t random = 0;
- uint8_t info = 0;
- uint16_t number = 0;
+ if (trb_set_address(uid, endpoint, trb_address) == -1) {
+ trb_error("set_address failed");
+ exit(EXIT_FAILURE);
+ }
+ } else if (strcmp(argv[optind], "T") == 0) {
+
+ /*******************************************/
+ /* Send Trigger */
+ /*******************************************/
+
+ uint8_t type;
+ uint8_t random = 0;
+ uint8_t info = 0;
+ uint16_t number = 0;
+
+ if (argc - optind != 5) {
+ usage(argv[0]);
+ exit(EXIT_FAILURE);
+ }
+
+ type = strtoul(argv[optind + 2], NULL, hexMode == 1 ? 16 : 0) & 0x0f;
+ random = strtoul(argv[optind + 3], NULL, hexMode == 1 ? 16 : 0);
+ info = strtoul(argv[optind + 4], NULL, hexMode == 1 ? 16 : 0);
+ number = strtoul(argv[optind + 5], NULL, hexMode == 1 ? 16 : 0);
+
+ /* DEBUG Info */
+ if (trb_debug > 0) {
+ fprintf(stderr,
+ "Command: SEND_TRIGGER: "
+ "type: 0x%01x, "
+ "random: 0x%02x, "
+ "info: 0x%02x, "
+ "number: 0x%04x\n",
+ type, random, info, number);
+ }
- if (argc - optind != 6) {
- usage(argv[0]);
- exit(EXIT_FAILURE);
- }
+ if (trb_send_trigger(type, info, random, number) == -1) {
+ trb_error("send trigger failed");
+ exit(EXIT_FAILURE);
+ }
+ } else if (strcmp(argv[optind], "TR") == 0) {
+
+ /*********************************************/
+ /* Send Fake trigger function to RICH Subnet */
+ /*********************************************/
+
+ uint8_t input = 0;
+ uint8_t type = 0;
+ uint8_t random = 0;
+ uint8_t info = 0;
+ uint16_t number = 0;
+
+ if (argc - optind != 6) {
+ usage(argv[0]);
+ exit(EXIT_FAILURE);
+ }
- input = strtoul(argv[optind + 1], NULL, hexMode == 1 ? 16 : 0) & 0x03;
- type = strtoul(argv[optind + 2], NULL, hexMode == 1 ? 16 : 0) & 0x0f;
- random = strtoul(argv[optind + 3], NULL, hexMode == 1 ? 16 : 0);
- info = strtoul(argv[optind + 4], NULL, hexMode == 1 ? 16 : 0);
- number = strtoul(argv[optind + 5], NULL, hexMode == 1 ? 16 : 0);
-
- /* DEBUG Info */
- if (trb_debug > 0) {
- fprintf(stderr,
- "Command: SEND_TRIGGER: "
- "input: 0x%01x, "
- "type: 0x%01x, "
- "random: 0x%02x, "
- "info: 0x%02x, "
- "number: 0x%04x\n",
- input, type, random, info, number);
- }
+ input = strtoul(argv[optind + 1], NULL, hexMode == 1 ? 16 : 0) & 0x03;
+ type = strtoul(argv[optind + 2], NULL, hexMode == 1 ? 16 : 0) & 0x0f;
+ random = strtoul(argv[optind + 3], NULL, hexMode == 1 ? 16 : 0);
+ info = strtoul(argv[optind + 4], NULL, hexMode == 1 ? 16 : 0);
+ number = strtoul(argv[optind + 5], NULL, hexMode == 1 ? 16 : 0);
+
+ /* DEBUG Info */
+ if (trb_debug > 0) {
+ fprintf(stderr,
+ "Command: SEND_TRIGGER: "
+ "input: 0x%01x, "
+ "type: 0x%01x, "
+ "random: 0x%02x, "
+ "info: 0x%02x, "
+ "number: 0x%04x\n",
+ input, type, random, info, number);
+ }
- if (trb_send_trigger(input, type, info, random, number) == -1) {
- trb_error("send trigger failed");
- exit(EXIT_FAILURE);
- }
- } else if (strcmp(argv[optind], "I") == 0) {
-
- /*******************************************/
- /* IPU channel readout */
- /*******************************************/
-
- uint32_t buffer[4096];
- uint8_t type = 0;
- uint8_t random = 0;
- uint8_t info = 0;
- uint16_t number = 0;
- int size = 0;
+ if (trb_send_trigger_rich(input, type, info, random, number) == -1) {
+ trb_error("send trigger failed");
+ exit(EXIT_FAILURE);
+ }
+ } else if (strcmp(argv[optind], "I") == 0) {
+
+ /*******************************************/
+ /* IPU channel readout */
+ /*******************************************/
+
+ uint32_t buffer[4096];
+ uint8_t type = 0;
+ uint8_t random = 0;
+ uint8_t info = 0;
+ uint16_t number = 0;
+ int size = 0;
- if (argc - optind != 5) {
- usage(argv[0]);
- exit(EXIT_FAILURE);
- }
+ if (argc - optind != 5) {
+ usage(argv[0]);
+ exit(EXIT_FAILURE);
+ }
- type = strtoul(argv[optind + 1], NULL, hexMode == 1 ? 16 : 0) & 0x0f;
- random = strtoul(argv[optind + 2], NULL, hexMode == 1 ? 16 : 0);
- info = strtoul(argv[optind + 3], NULL, hexMode == 1 ? 16 : 0);
- number = strtoul(argv[optind + 4], NULL, hexMode == 1 ? 16 : 0);
-
- /* DEBUG Info */
- if (trb_debug > 0) {
- fprintf(stderr,
- "Command: READ_IPU_DATA: "
- "type: 0x%01x, "
- "random: 0x%02x, "
- "info: 0x%02x, "
- "number: 0x%04x\n",
- type, random, info, number);
- }
- size = trb_ipu_data_read(type, info, random, number, buffer, 4096);
- if (size == -1) {
- trb_error("ipu read data failed");
- exit(EXIT_FAILURE);
- }
+ type = strtoul(argv[optind + 1], NULL, hexMode == 1 ? 16 : 0) & 0x0f;
+ random = strtoul(argv[optind + 2], NULL, hexMode == 1 ? 16 : 0);
+ info = strtoul(argv[optind + 3], NULL, hexMode == 1 ? 16 : 0);
+ number = strtoul(argv[optind + 4], NULL, hexMode == 1 ? 16 : 0);
+
+ /* DEBUG Info */
+ if (trb_debug > 0) {
+ fprintf(stderr,
+ "Command: READ_IPU_DATA: "
+ "type: 0x%01x, "
+ "random: 0x%02x, "
+ "info: 0x%02x, "
+ "number: 0x%04x\n",
+ type, random, info, number);
+ }
+ size = trb_ipu_data_read(type, info, random, number, buffer, 4096);
+ if (size == -1) {
+ trb_error("ipu read data failed");
+ exit(EXIT_FAILURE);
+ }
- for (i = 0; i < size; i++) {
- fprintf(stdout, "0x%08x\n", buffer[i]);
- }
- } else if (strcmp(argv[optind], "f") == 0) {
+ for (i = 0; i < size; i++) {
+ fprintf(stdout, "0x%08x\n", buffer[i]);
+ }
+ } else if (strcmp(argv[optind], "f") == 0) {
- /*******************************************/
- /* Flush FIFO Channel */
- /*******************************************/
+ /*******************************************/
+ /* Flush FIFO Channel */
+ /*******************************************/
- int status;
- uint8_t channel = 0;
+ int status;
+ uint8_t channel = 0;
- if (argc - optind != 2) {
- usage(argv[0]);
- exit(EXIT_FAILURE);
- }
+ if (argc - optind != 2) {
+ usage(argv[0]);
+ exit(EXIT_FAILURE);
+ }
- channel = strtoul(argv[optind + 1], NULL, hexMode == 1 ? 16 : 0);
- if (trb_debug > 0) {
- fprintf(stderr, "Command: FIFO_FLUSH_CHANNEL #%d\n", channel);
- }
+ channel = strtoul(argv[optind + 1], NULL, hexMode == 1 ? 16 : 0);
+ if (trb_debug > 0) {
+ fprintf(stderr, "Command: FIFO_FLUSH_CHANNEL #%d\n", channel);
+ }
- status = trb_fifo_flush(channel);
- if (status == -1) {
- trb_error("flush channel failed");
- exit(EXIT_FAILURE);
- }
- } else if (strcmp(argv[optind], "R") == 0) {
+ status = trb_fifo_flush(channel);
+ if (status == -1) {
+ trb_error("flush channel failed");
+ exit(EXIT_FAILURE);
+ }
+ } else if (strcmp(argv[optind], "R") == 0) {
- /*******************************************/
- /* Read FIFO Register */
- /*******************************************/
+ /*******************************************/
+ /* Read FIFO Register */
+ /*******************************************/
- uint32_t value = 0;
- uint16_t reg_address = 0;
+ uint32_t value = 0;
+ uint16_t reg_address = 0;
- if (argc - optind != 2) {
- usage(argv[0]);
- exit(EXIT_FAILURE);
- }
- reg_address = strtoul(argv[optind + 1], NULL, hexMode == 1 ? 16 : 0);
+ if (argc - optind != 2) {
+ usage(argv[0]);
+ exit(EXIT_FAILURE);
+ }
+ reg_address = strtoul(argv[optind + 1], NULL, hexMode == 1 ? 16 : 0);
- read32_from_FPGA(reg_address, &value);
- fprintf(stdout, "%s%04x %s%04x\n",
- hexMode == 1 ? "" : "0x", reg_address,
- hexMode == 1 ? "" : "0x", value);
+ read32_from_FPGA(reg_address, &value);
+ fprintf(stdout, "%s%04x %s%04x\n",
+ hexMode == 1 ? "" : "0x", reg_address,
+ hexMode == 1 ? "" : "0x", value);
- } else if (strcmp(argv[optind], "W") == 0) {
+ } else if (strcmp(argv[optind], "W") == 0) {
- /*******************************************/
- /* Write FIFO Register */
- /*******************************************/
+ /*******************************************/
+ /* Write FIFO Register */
+ /*******************************************/
- uint32_t value = 0;
- uint16_t reg_address = 0;
+ uint32_t value = 0;
+ uint16_t reg_address = 0;
- if (argc - optind != 3) {
+ if (argc - optind != 3) {
+ usage(argv[0]);
+ exit(EXIT_FAILURE);
+ }
+ reg_address = strtoul(argv[optind + 1], NULL, hexMode == 1 ? 16 : 0);
+ value = strtoul(argv[optind + 2], NULL, hexMode == 1 ? 16 : 0);
+
+ write32_to_FPGA(reg_address, value);
+
+ /*
+ fprintf(stdout, "%s%04x %s%04x\n",
+ hexMode == 1 ? "" : "0x", reg_address,
+ hexMode == 1 ? "" : "0x", value);
+ */
+ } else {
usage(argv[0]);
exit(EXIT_FAILURE);
}
- reg_address = strtoul(argv[optind + 1], NULL, hexMode == 1 ? 16 : 0);
- value = strtoul(argv[optind + 2], NULL, hexMode == 1 ? 16 : 0);
-
- write32_to_FPGA(reg_address, value);
-
- /*
- fprintf(stdout, "%s%04x %s%04x\n",
- hexMode == 1 ? "" : "0x", reg_address,
- hexMode == 1 ? "" : "0x", value);
- */
- } else {
- usage(argv[0]);
- exit(EXIT_FAILURE);
- }
} /* end repeat loop */