static int hexMode = HEXMODE;
-static const char trbcmd_version[] = "$Revision: 2.78 $";
+static const char trbcmd_version[] = "$Revision: 2.79 $";
#define BACKLOG 10
static uint16_t tcp_port = 55555;
"clear bits of a register\n");
fprintf(stdout, " loadbit <trbaddress> <register> <bitmask> <val> -> "
"load bits of a register\n");
-
+ fprintf(stdout, " nettrace <trbaddress> -> "
+ "trace TRBNet-Path of an endpoint\n");
fprintf(stdout, " reload <trbaddress> -> "
"reload FPGA\n");
fprintf(stdout, " reset -> "
buffer, BUFFER_SIZE);
if (status == -1) {
logError(ERROR, "read_register failed: %s\n", trb_strerror());
+ return -1;
} else {
for (i = 0; i < status; i += 2) {
fprintf(stdout, "0x%04x 0x%08x\n", buffer[i], buffer[i + 1]);
buffer, BUFFER_SIZE);
if (status == -1) {
logError(ERROR, "read_register failed: %s\n", trb_strerror());
+ return -1;
} else {
for (i = 0; i < status; i += 3) {
fprintf(stdout, "0x%04x 0x%08x 0x%04x\n",
if (status == -1) {
logError(ERROR, "clearbit of register failed: %s\n",
trb_strerror());
-
return -1;
}
trb_strerror());
return -1;
}
+
+ } else if (strncmp(cmd[0], "nettrace", CMD_SIZE) == 0) {
+
+ /*******************************************/
+ /* Nettrace */
+ /*******************************************/
+ int status = 0;
+
+ if (cmdLen != 2) {
+ logError(ERROR, "Invalid command, try -h option\n");
+ return -1;
+ }
+
+ trb_address = strtoul(cmd[1], NULL, hexMode == 1 ? 16 : 0);
+
+ /* DEBUG Info */
+ if (trb_debug > 0) {
+ fprintf(stderr,
+ "Command: NETTRACE: trb_address: 0x%04x\n",
+ trb_address);
+ }
+
+ status = trb_nettrace(trb_address, buffer, BUFFER_SIZE);
+ if (status == -1) {
+ logError(ERROR, "nettrace of trbaddress 0x%04x failed: %s\n",
+ trb_address, trb_strerror());
+ return -1;
+ }
+
+ for (i = 0; i < status; i += 2) {
+ fprintf(stdout, "0x%04x 0x%08x\n", buffer[i], buffer[i + 1]);
+ }
+
} else {
/*******************************************/
-const char trbnet_version[] = "$Revision: 4.16 $ Local";
+const char trbnet_version[] = "$Revision: 4.17 $ Local";
#include <stdlib.h>
#include <signal.h>
write32_to_FPGA(CHANNEL_3_SENDER_DATA, 0x00000000);
write32_to_FPGA(CHANNEL_3_SENDER_CONTROL, CMD_REGISTER_READ);
#else
+
+
/* Send command to pexor driver */
pexorDescriptor.trb_address = trb_address;
pexorDescriptor.reg_address = reg_address;
return 0;
}
+
+int trb_nettrace(uint16_t trb_address,
+ uint32_t *data,
+ unsigned int dsize)
+{
+ static const size_t NUM_ENDPOINTS = 1024;
+ uint32_t *buffer = NULL;
+ int status = 0;
+ unsigned int i;
+ unsigned int ctr;
+
+ trb_errno = TRB_NONE;
+
+ if (lockPorts(1) == -1) return -1;
+
+ buffer = (uint32_t *) malloc(sizeof(uint32_t) * NUM_ENDPOINTS * 2);
+ if (buffer == NULL) abort();
+
+ /* DEBUG INFO */
+ if (trb_debug > 0) {
+ fprintf(stderr, "nettrace started.\n");
+ }
+
+ if (trb_register_read(0xfffe, 0xa5, buffer, NUM_ENDPOINTS * 2) == -1) {
+ unlockPorts(1);
+ free(buffer);
+ return -1;
+ }
+ trb_register_read_mem(trb_address, 0, 0, 1, buffer, NUM_ENDPOINTS * 2);
+
+ status = trb_register_read(0xfffe, 0xa5, buffer, NUM_ENDPOINTS * 2);
+ if (unlockPorts(1) == -1) return -1;
+
+ if (status == -1) {
+ free(buffer);
+ return -1;
+ }
+
+ ctr = 0;
+ for (i = 0; (i + 1) < status; i += 2) {
+ if (buffer[i + 1] == 0) {
+ fprintf(stderr, "hallo\n");
+ continue;
+ }
+ if (ctr + 1 >= dsize) {
+ trb_errno = TRB_USER_BUFFER_OVF;
+ free(buffer);
+ return -1;
+ }
+ data[ctr++] = buffer[i];
+ data[ctr++] = buffer[i + 1];
+ }
+
+ free(buffer);
+ return ctr;
+}