#include <errno.h>
#include <ctype.h>
#include <signal.h>
+#include <stdarg.h>
#include <libgen.h>
#include <unistd.h>
static int hexMode = HEXMODE;
-static const char trbcmd_version[] = "$Revision: 2.54 $";
+static const char trbcmd_version[] = "$Revision: 2.55 $";
#define BACKLOG 10
static uint16_t tcp_port = 55555;
static int tcp_debug = 0; /* turn to 0 to suppress TCP/IP output */
-/* ---- User Buffer Size ----------------------------------------------- */
+/* ---- User Buffer Size ------------------------------------------------ */
static const size_t NUM_ENDPOINTS = 1024; /* Maximum of 16KByte */
static size_t USER_BUFFER_SIZE = 0;
+/* ---- Error Handling -------------------------------------------------- */
+
+static FILE *scriptFile = NULL;
+static unsigned int lineCtr = 0;
+
+typedef enum {
+ INVALID = 0,
+ DEBUG = 1,
+ WARNING = 2,
+ ERROR = 3
+} ErrType;
+
+static const char errTypeString[4][32] = {
+ ">INVALID",
+ ">DEBUG",
+ ">WARNING",
+ ">ERROR"
+};
+
+static void logError(int type, const char* format, ...)
+{
+ char fmt[512] = "";
+ va_list args;
+
+ va_start(args, format);
+
+ if (scriptFile != NULL) {
+ snprintf(fmt, 512, "%s: Line #%d: %s",
+ errTypeString[type], lineCtr, format);
+ } else {
+ snprintf(fmt, 512, "%s: %s", errTypeString[type], format);
+ }
+
+ vfprintf(stderr, fmt, args);
+ va_end(args);
+}
+
/* ------ MAIN ---------------------------------------------------------- */
void usage(const char *progName)
int start(int argc, char **argv)
{
- FILE *scriptFile = NULL;
char scriptFileName[256] = "";
char cmd[CMD_MAX_NUM][CMD_SIZE];
char *cmdLine = NULL;
if (strlen(scriptFileName) > 0) {
if (strncmp(scriptFileName, "-", 256) == 0) {
scriptFile = stdin;
- fprintf(stderr, "name: %s\n", "STDIN");
} else {
scriptFile = fopen(scriptFileName, "r");
if (scriptFile == NULL) {
- fprintf(stderr, "Error opening ScriptFile '%s': %s\n",
- scriptFileName, strerror(errno));
+ logError(ERROR, "opening ScriptFile '%s': %s\n",
+ scriptFileName, strerror(errno));
return -1;
}
}
}
-
+
/* Start repeat-loop */
while ((loop == -1) || (loopCtr++ < loop)) {
- unsigned int lineCtr = 0;
ssize_t scriptStatus = 0;
/* Start script-file-loop */
+ lineCtr = 0;
while (scriptStatus != -1) {
if (scriptFile == NULL) {
/* Get command from function-call */
continue;
} else {
/* Error reading line */
- fprintf(stderr, "Error reading script-file\n");
+ logError(ERROR, "reading rewind script-file\n");
return -1;
}
}
}
/* Split up cmdLine */
-
sscanf(cmdLine, "%s %s %s %s %s %s %s %s %s %s",
cmd[0], cmd[1], cmd[2], cmd[3], cmd[4],
cmd[5], cmd[6], cmd[7], cmd[8], cmd[9]);
uint32_t value = 0;
if (cmdLen != 4) {
- if (scriptFile != NULL) {
- fprintf(stderr, "Line #%d: Invalid command\n", lineCtr);
- } else {
- usage(basename(argv[0]));
- }
+ logError(ERROR, "Invalid command, try -h option\n");
return -1;
}
}
if (trb_register_write(trb_address, reg_address, value) == -1) {
- if (scriptFile != NULL) {
- fprintf(stderr, "Line #%d: ", lineCtr);
- }
- trb_error("write_register failed");
- if (trb_errno != TRB_ENDPOINT_NOT_REACHED) {
- return -1;
- }
+ logError(ERROR, "write_register failed %s\n");
+ return -1;
} else {
- /* Check Status-Bits */
- if ((trb_term.status_common != 0x01) ||
- (trb_term.status_channel != 0)) {
- if (scriptFile != NULL) {
- fprintf(stderr, "Line #%d: ", lineCtr);
- }
- fprintf(stderr, "WARNING Status-Bits:\n%s\n",
- trb_strterm(trb_term));
+ if (trb_errno == TRB_STATUS_WARNING) {
+ logError(WARNING, "Status-Bit(s) have been set:\n%s\n",
+ trb_strterm(trb_term));
}
}
int i;
if (cmdLen != 3) {
- if (scriptFile != NULL) {
- fprintf(stderr, "Line #%d: Invalid command\n", lineCtr);
- } else {
- usage(basename(argv[0]));
- }
+ logError(ERROR, "Invalid command, try -h option\n");
return -1;
}
status = trb_register_read(trb_address, reg_address,
data, NUM_ENDPOINTS * 2);
if (status == -1) {
- if (scriptFile != NULL) {
- fprintf(stderr, "Line #%d: ", lineCtr);
- }
- trb_error("read_register failed");
- if (trb_errno != TRB_ENDPOINT_NOT_REACHED) {
- return -1;
- }
+ logError(ERROR, "read_register failed %s\n",
+ trb_strerror(trb_errno));
} else {
for (i = 0; i < status; i += 2) {
fprintf(stdout, "0x%04x 0x%08x\n", data[i], data[i + 1]);
}
-
+
/* Check Status-Bits */
- if ((trb_term.status_common != 0x01) ||
- (trb_term.status_channel != 0)) {
- if (scriptFile != NULL) {
- fprintf(stderr, "Line #%d: ", lineCtr);
- }
- fprintf(stderr, "WARNING Status-Bits:\n%s\n",
- trb_strterm(trb_term));
- }
+ if (trb_errno == TRB_STATUS_WARNING) {
+ logError(WARNING, "Status-Bit(s) have been set:\n%s\n",
+ trb_strterm(trb_term));
+ }
}
free(data);
unsigned int i;
if (cmdLen != 5) {
- if (scriptFile != NULL) {
- fprintf(stderr, "Line #%d: Invalid command\n", lineCtr);
- } else {
- usage(basename(argv[0]));
- }
+ logError(ERROR, "Invalid command, try -h option\n");
return -1;
}
status = trb_register_read_mem(trb_address, reg_address, option,
size, data, USER_BUFFER_SIZE);
if (status == -1) {
- if (scriptFile != NULL) {
- fprintf(stderr, "Line #%d: ", lineCtr);
- }
- trb_error("read_register_mem failed");
- if (trb_errno != TRB_ENDPOINT_NOT_REACHED) {
- return -1;
- }
+ logError(ERROR, "read_register_mem failed: %s\n",
+ trb_strerror(trb_errno));
+ return -1;
} else {
/* Print data-buffer */
p = data;
}
}
/* Check Status-Bits */
- if ((trb_term.status_common != 0x01) ||
- (trb_term.status_channel != 0)) {
- if (scriptFile != NULL) {
- fprintf(stderr, "Line #%d: ", lineCtr);
- }
- fprintf(stderr, "WARNING Status-Bits:\n%s\n",
- trb_strterm(trb_term));
+ if (trb_errno == TRB_STATUS_WARNING) {
+ logError(WARNING, "Status-Bits are active:\n%s\n",
+ trb_strterm(trb_term));
}
}
free(data);
int status;
if (cmdLen != 5) {
- if (scriptFile != NULL) {
- fprintf(stderr, "Line #%d: Invalid command\n", lineCtr);
- } else {
- usage(basename(argv[0]));
- }
+ logError(ERROR, "Invalid command, try -h option\n");
return -1;
}
} else {
file = fopen(fileName, "r");
if (file == NULL) {
- fprintf(stderr, "Error opening file '%s': %s\n",
+ logError(ERROR, "opening file '%s': %s\n",
fileName, strerror(errno));
return -1;
}
status = trb_register_write_mem(trb_address, reg_address, option,
data, size);
if (status == -1) {
- if (scriptFile != NULL) {
- fprintf(stderr, "Line #%d: ", lineCtr);
- }
- trb_error("write_register_memory failed");
- if (trb_errno != TRB_ENDPOINT_NOT_REACHED) {
- return -1;
- }
+ logError(ERROR, "write_register_memory failed: %s\n",
+ trb_strerror(trb_errno));
+ return -1;
} else {
/* Check Status-Bits */
- if ((trb_term.status_common != 0x01) ||
- (trb_term.status_channel != 0)) {
- if (scriptFile != NULL) {
- fprintf(stderr, "Line #%d: ", lineCtr);
- }
- fprintf(stderr, "WARNING Status-Bits:\n%s\n",
- trb_strterm(trb_term));
+ if (trb_errno == TRB_STATUS_WARNING) {
+ logError(WARNING, "Status-Bits are active:\n%s\n",
+ trb_strterm(trb_term));
}
}
-
+
free(data);
} else if (strncmp(cmd[0], "i", CMD_SIZE) == 0) {
unsigned int i;
if (cmdLen != 2) {
- if (scriptFile != NULL) {
- fprintf(stderr, "Line #%d: Invalid command\n", lineCtr);
- } else {
- usage(basename(argv[0]));
- }
+ logError(ERROR, "Invalid command, try -h option\n");
return -1;
}
status = trb_read_uid(trb_address, uidBuffer, NUM_ENDPOINTS * 4);
if (status == -1) {
- if (scriptFile != NULL) {
- fprintf(stderr, "Line #%d: ", lineCtr);
- }
- trb_error("read_uid failed");
- if (trb_errno != TRB_ENDPOINT_NOT_REACHED) {
- return -1;
- }
+ logError(ERROR, "read_uid failed: %s\n",
+ trb_strerror(trb_errno));
+ return -1;
} else {
for (i = 0;
((i < (unsigned int)status) && (i < NUM_ENDPOINTS * 4));
uidBuffer[i], uidBuffer[i + 1], uidBuffer[i + 2]);
}
/* Check Status-Bits */
- if ((trb_term.status_common != 0x01) ||
- (trb_term.status_channel != 0)) {
- if (scriptFile != NULL) {
- fprintf(stderr, "Line #%d: ", lineCtr);
- }
- fprintf(stderr, "WARNING Status-Bits:\n%s\n",
- trb_strterm(trb_term));
+ if (trb_errno == TRB_STATUS_WARNING) {
+ logError(WARNING, "Status-Bits are active:\n%s\n",
+ trb_strterm(trb_term));
}
}
uint16_t trb_address = 0;
if (cmdLen != 4) {
- if (scriptFile != NULL) {
- fprintf(stderr, "Line #%d: Invalid command\n", lineCtr);
- } else {
- usage(basename(argv[0]));
- }
+ logError(ERROR, "Invalid command, try -h option\n");
return -1;
}
}
if (trb_set_address(uid, endpoint, trb_address) == -1) {
- if (scriptFile != NULL) {
- fprintf(stderr, "Line #%d: ", lineCtr);
- }
- trb_error("set_address failed");
- if (trb_errno != TRB_ENDPOINT_NOT_REACHED) {
- return -1;
- }
+ logError(ERROR, "set_address failed: %s\n",
+ trb_strerror(trb_errno));
+ return -1;
} else {
/* Check Status-Bits */
- if ((trb_term.status_common != 0x01) ||
- (trb_term.status_channel != 0)) {
- if (scriptFile != NULL) {
- fprintf(stderr, "Line #%d: ", lineCtr);
- }
- fprintf(stderr, "WARNING Status-Bits:\n%s\n",
- trb_strterm(trb_term));
+ if (trb_errno == TRB_STATUS_WARNING) {
+ logError(WARNING, "Status-Bits are active:\n%s\n",
+ trb_strterm(trb_term));
}
}
-
+
} else if (strncmp(cmd[0], "T", CMD_SIZE) == 0) {
/*******************************************/
uint16_t number = 0;
if (cmdLen != 5) {
- if (scriptFile != NULL) {
- fprintf(stderr, "Line #%d: Invalid command\n", lineCtr);
- } else {
- usage(basename(argv[0]));
- }
+ logError(ERROR, "Invalid command, try -h option\n");
return -1;
}
}
if (trb_send_trigger(type, info, random, number) == -1) {
- if (scriptFile != NULL) {
- fprintf(stderr, "Line #%d: ", lineCtr);
- }
- trb_error("send_trigger failed");
- if (trb_errno != TRB_ENDPOINT_NOT_REACHED) {
- return -1;
- }
+ logError(ERROR, "send_trigger failed: %s\n",
+ trb_strerror(trb_errno));
+ return -1;
} else {
/* Check Status-Bits */
- if ((trb_term.status_common != 0x01) ||
- (trb_term.status_channel != 0)) {
- if (scriptFile != NULL) {
- fprintf(stderr, "Line #%d: ", lineCtr);
- }
- fprintf(stderr, "WARNING Status-Bits:\n%s\n",
- trb_strterm(trb_term));
+ if (trb_errno == TRB_STATUS_WARNING) {
+ logError(WARNING, "Status-Bits are active:\n%s\n",
+ trb_strterm(trb_term));
}
}
/*******************************************/
if (cmdLen != 1) {
- if (scriptFile != NULL) {
- fprintf(stderr, "Line #%d: Invalid command\n", lineCtr);
- } else {
- usage(basename(argv[0]));
- }
+ logError(ERROR, "Invalid command, try -h option\n");
return -1;
}
}
if (network_reset() == -1) {
- if (scriptFile != NULL) {
- fprintf(stderr, "Line #%d: ", lineCtr);
- }
- trb_error("TRBNet RESET failed");
+ logError(ERROR, "TRBNet RESET failed\n");
return -1;
}
/*******************************************/
if (cmdLen != 1) {
- if (scriptFile != NULL) {
- fprintf(stderr, "Line #%d: Invalid command\n", lineCtr);
- } else {
- usage(basename(argv[0]));
- }
+ logError(ERROR, "Invalid command, try -h option\n");
return -1;
}
}
if (com_reset() == -1) {
- if (scriptFile != NULL) {
- fprintf(stderr, "Line #%d: ", lineCtr);
- }
- trb_error("Etrax RESET failed");
+ logError(ERROR, "Etrax RESET failed: %s\n",
+ trb_strerror(trb_errno));
return -1;
}
/*********************************************/
if (cmdLen != 2) {
- if (scriptFile != NULL) {
- fprintf(stderr, "Line #%d: Invalid command\n", lineCtr);
- } else {
- usage(basename(argv[0]));
- }
+ logError(ERROR, "Invalid command, try -h option\n");
return -1;
}
}
if (trb_register_write(trb_address, 0x0020, 0x8000) == -1) {
- if (scriptFile != NULL) {
- fprintf(stderr, "Line #%d: ", lineCtr);
- }
- trb_error("FPGA reload failed");
- if (trb_errno != TRB_ENDPOINT_NOT_REACHED) {
- return -1;
- }
+ logError(ERROR, "FPGA reload failed: %s\n",
+ trb_strerror(trb_errno));
+ return -1;
} else {
/* Check Status-Bits */
- if ((trb_term.status_common != 0x01) ||
- (trb_term.status_channel != 0)) {
- if (scriptFile != NULL) {
- fprintf(stderr, "Line #%d: ", lineCtr);
- }
- fprintf(stderr, "WARNING Status-Bits:\n%s\n",
- trb_strterm(trb_term));
+ if (trb_errno == TRB_STATUS_WARNING) {
+ logError(WARNING, "Status-Bits are active:\n%s\n",
+ trb_strterm(trb_term));
}
}
-
+
} else if (strncmp(cmd[0], "TR", CMD_SIZE) == 0) {
/*********************************************/
uint16_t number = 0;
if (cmdLen != 6) {
- if (scriptFile != NULL) {
- fprintf(stderr, "Line #%d: Invalid command\n", lineCtr);
- } else {
- usage(basename(argv[0]));
- }
+ logError(ERROR, "Invalid command, try -h option\n");
return -1;
}
}
if (trb_send_trigger_rich(input, type, info, random, number) == -1) {
- if (scriptFile != NULL) {
- fprintf(stderr, "Line #%d: ", lineCtr);
- }
- trb_error("send_trigger failed");
- if (trb_errno != TRB_ENDPOINT_NOT_REACHED) {
- return -1;
- }
+ logError(ERROR, "send_trigger failed: %s\n",
+ trb_strerror(trb_errno));
+ return -1;
} else {
/* Check Status-Bits */
- if ((trb_term.status_common != 0x01) ||
- (trb_term.status_channel != 0)) {
- if (scriptFile != NULL) {
- fprintf(stderr, "Line #%d: ", lineCtr);
- }
- fprintf(stderr, "WARNING Status-Bits:\n%s\n",
- trb_strterm(trb_term));
+ if (trb_errno == TRB_STATUS_WARNING) {
+ logError(WARNING, "Status-Bits are active:\n%s\n",
+ trb_strterm(trb_term));
}
}
int i;
if (cmdLen != 5) {
- if (scriptFile != NULL) {
- fprintf(stderr, "Line #%d: Invalid command\n", lineCtr);
- } else {
- usage(basename(argv[0]));
- }
+ logError(ERROR, "Invalid command, try -h option\n");
return -1;
}
status = trb_ipu_data_read(type, info, random, number,
buffer, USER_BUFFER_SIZE);
if (status == -1) {
- if (scriptFile != NULL) {
- fprintf(stderr, "Line #%d: ", lineCtr);
- }
- trb_error("read_ipu_data failed");
- if (trb_errno != TRB_ENDPOINT_NOT_REACHED) {
- return -1;
- }
+ logError(ERROR, "read_ipu_data failed: %s\n",
+ trb_strerror(trb_errno));
+ return -1;
} else {
for (i = 0; i < status; i++) {
fprintf(stdout, "0x%08x\n", buffer[i]);
}
-
/* Check Status-Bits */
- if ((trb_term.status_common != 0x01) ||
- (trb_term.status_channel != 0)) {
- if (scriptFile != NULL) {
- fprintf(stderr, "Line #%d: ", lineCtr);
- }
- fprintf(stderr, "WARNING Status-Bits:\n%s\n",
- trb_strterm(trb_term));
+ if (trb_errno == TRB_STATUS_WARNING) {
+ logError(WARNING, "Status-Bits are active:\n%s\n",
+ trb_strterm(trb_term));
}
}
uint8_t channel = 0;
if (cmdLen != 2) {
- if (scriptFile != NULL) {
- fprintf(stderr, "Line #%d: Invalid command\n", lineCtr);
- } else {
- usage(basename(argv[0]));
- }
+ logError(ERROR, "Invalid command, try -h option\n");
return -1;
}
}
if (trb_fifo_flush(channel) == -1) {
- if (scriptFile != NULL) {
- fprintf(stderr, "Line #%d: ", lineCtr);
- }
- trb_error("trb_fifo_flush failed");
+ logError(ERROR, "trb_fifo_flush failed: %s\n",
+ trb_strerror(trb_errno));
return -1;
}
uint16_t reg_address = 0;
if (cmdLen != 2) {
- if (scriptFile != NULL) {
- fprintf(stderr, "Line #%d: Invalid command\n", lineCtr);
- } else {
- usage(basename(argv[0]));
- }
+ logError(ERROR, "Invalid command, try -h option\n");
return -1;
}
}
if (fpga_register_read(reg_address, &value) == -1) {
- if (scriptFile != NULL) {
- fprintf(stderr, "Line #%d: ", lineCtr);
- }
- trb_error("fpga_register_read failed");
+ logError(ERROR, "fpga_register_read failed: %s\n",
+ trb_strerror(trb_errno));
return -1;
} else {
fprintf(stdout, "0x%04x 0x%08x\n", reg_address, value);
uint16_t reg_address = 0;
if (cmdLen != 3) {
- if (scriptFile != NULL) {
- fprintf(stderr, "Line #%d: Invalid command\n", lineCtr);
- } else {
- usage(basename(argv[0]));
- }
+ logError(ERROR, "Invalid command, try -h option\n");
return -1;
}
}
if (fpga_register_write(reg_address, value) == -1) {
- if (scriptFile != NULL) {
- fprintf(stderr, "Line #%d: ", lineCtr);
- }
- trb_error("fpga_register_write failed");
+ logError(ERROR, "fpga_register_write failed\n");
return -1;
}
uint32_t bitMask;
if (cmdLen != 4) {
- if (scriptFile != NULL) {
- fprintf(stderr, "Line #%d: Invalid command\n", lineCtr);
- } else {
- usage(basename(argv[0]));
- }
+ logError(ERROR, "Invalid command, try -h option\n");
return -1;
}
status = trb_register_modify(trb_address, reg_address,
1, bitMask, 0);
if (status == -1) {
- if (scriptFile != NULL) {
- fprintf(stderr, "Line #%d: ", lineCtr);
- }
- trb_error("setbit of register failed");
- if (trb_errno != TRB_ENDPOINT_NOT_REACHED) {
- return -1;
- }
+ logError(ERROR, "setbit of register failed: %s\n",
+ trb_strerror(trb_errno));
+ return -1;
}
} else if (strncmp(cmd[0], "clearbit", CMD_SIZE) == 0) {
uint32_t bitMask;
if (cmdLen != 4) {
- if (scriptFile != NULL) {
- fprintf(stderr, "Line #%d: Invalid command\n", lineCtr);
- } else {
- usage(basename(argv[0]));
- }
+ logError(ERROR, "Invalid command, try -h option\n");
return -1;
}
status = trb_register_modify(trb_address, reg_address,
2, bitMask, 0);
if (status == -1) {
- if (scriptFile != NULL) {
- fprintf(stderr, "Line #%d: ", lineCtr);
- }
- trb_error("clearbit of register failed");
- if (trb_errno != TRB_ENDPOINT_NOT_REACHED) {
- return -1;
- }
+ logError(ERROR, "clearbit of register failed: %s\n",
+ trb_strerror(trb_errno));
+
+ return -1;
}
} else if (strncmp(cmd[0], "loadbit", CMD_SIZE) == 0) {
uint32_t bitValue;
if (cmdLen != 5) {
- if (scriptFile != NULL) {
- fprintf(stderr, "Line #%d: Invalid command\n", lineCtr);
- } else {
- usage(basename(argv[0]));
- }
+ logError(ERROR, "Invalid command, try -h option\n");
return -1;
}
status = trb_register_modify(trb_address, reg_address,
3, bitMask, bitValue);
if (status == -1) {
- if (scriptFile != NULL) {
- fprintf(stderr, "Line #%d: ", lineCtr);
- }
- trb_error("loadbit of register failed");
- if (trb_errno != TRB_ENDPOINT_NOT_REACHED) {
- return -1;
- }
+ logError(ERROR, "loadbit of register failed: %s\n",
+ trb_strerror(trb_errno));
+ return -1;
}
} else {
/* Not a valid command */
/*******************************************/
- if (scriptFile != NULL) {
- fprintf(stderr, "Line #%d: Invalid command\n", lineCtr);
- } else {
- usage(basename(argv[0]));
- }
+ logError(ERROR, "Invalid command, try -h option\n");
return -1;
}
} /* End script-file-loop */
/* Enter an infinite loop to accept clients */
while (1) {
socklen_t sin_size = sizeof(struct sockaddr_in);
- ssize_t msgLen = 0;
- char command[256];
if (tcp_debug > 0) {
fprintf(stderr, "\n\nlisten...\n\n");
stderr = clientout;
while (1) {
+ int start_argc = 0;
+ char *start_argv[256];
+ int start_arg = 0;
+ char command[256] = "";
+ ssize_t msgLen = 0;
+
msgLen = recv(myFd, (void *)command, 256, 0);
if (msgLen == -1) {
perror("Error recv");
}
msgLen -= 2;
command[msgLen] = '\0';
-
- int start_argc = 0;
- char *start_argv[256];
- int start_arg = 0;
-
+
start_argv[start_argc++] = argv[0];
for (i = 0; i < (unsigned int)msgLen; i++) {
if (isspace((int)command[i]) != 0) {
"Invalid data-length give by Header",
"FIFO Incomplete, missing",
"SEMAPHORE Error",
- "FIFO Shared Memory Error"
+ "FIFO Shared Memory Error",
+ "Termination Status Warning"
};
- if (trberrno < 26) {
+ if (trberrno < 27) {
return errorstring[trberrno];
} else {
- return "Unknown Errno";
+ return ">Unknown Errno";
}
}
"COM_Checksum: checksum error", /* error */
"COM_DontUnderstand: endpoint doesn't understand data", /* error */
"COM_BufferMismatch: buffer numbers (EOB and ACK) mismatch", /* error */
- "COM_AnswerMissing: One2 endpoint didn't react", /* status */
- "", "", "", "", "", "", "", "", ""
+ "COM_AnswerMissing: One endpoint didn't react", /* status */
+ "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID",
+ "INVALID", "INVALID", "INVALID"
};
static const char ch0StatusBits[16][64] = {
"Ch0_TrigCtr: trigger counter mismatch", /* status */
"Ch0_TrigMissing: timing trigger missing", /* status */
- "",
- "",
+ "INVALID",
+ "INVALID",
"Ch0_BuffersHalfFull: data-buffers half full", /* status */
"Ch0_BuffersFull: data-buffers almost full", /* status */
"Ch0_NotConfigured: endpoint is not configured", /* status */
- "", "", "", "", "", "", "", "", ""
+ "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID",
+ "INVALID", "INVALID", "INVALID"
};
static const char ch1StatusBits[16][64] = {
"Ch1_DataMissing: parts of the data are missing",/* status */
"Ch1_Sync: serious sync problem detected", /* status */
"Ch1_EvtBroken: event data corrupted", /* status */
- "", "", "", "", "", "", "", ""
+ "INVALID", "INVALID", "INVALID", "INVALID", "INVALID",
+ "INVALID", "INVALID", "INVALID"
};
static const char ch2StatusBits[16][64] = {
- "", "", "", "", "", "", "", "",
- "", "", "", "", "", "", "", ""
+ "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID",
+ "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID",
+ "INVALID", "INVALID", "INVALID", "INVALID"
};
static const char ch3StatusBits[16][64] = {
"Ch3_Address: unknown address", /* status */
"Ch3_Timeout: timeout error", /* error */
"Ch3_NoMoreData: no more data" /* status */
- "", "", "", "", "", "", "", "", "", "", "", "", ""
+ "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID",
+ "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID",
+ "INVALID"
};
static const char *chStatusBits[4] = {
unsigned int i;
if (term.channel >= 4) {
- sprintf(buffer, "INVALID ChannelId %d", term.channel);
+ sprintf(buffer, ">INVALID ChannelId %d", term.channel);
return buffer;
}
sprintf(buffer,
- "CommonStatusBits: 0x%04x, Channel#%d StatusBits: 0x%04x",
+ ">CommonStatusBits: 0x%04x, Channel#%d StatusBits: 0x%04x",
term.status_common,
term.channel,
term.status_channel);
for (i = 0; i < 16; i++) {
if ((term.status_common & (0x01 << i)) != (i != 0 ? 0 : 1)) {
- strcat(buffer, "\n ");
+ strcat(buffer, "\n> ");
strcat(buffer, commonStatusBits[i]);
}
}
{
static char buffer[4096] = "";
- if (trb_errno == TRB_STATUS_ERROR) {
- snprintf(buffer, 4096, "%s\n%s",
+ if ((trb_errno == TRB_STATUS_ERROR) || (trb_errno == TRB_STATUS_WARNING)) {
+ snprintf(buffer, 4096, ">%s\n>%s",
trb_strerror(trb_errno), trb_strterm(trb_term));
} else {
- snprintf(buffer, 4096, "%s", trb_strerror(trb_errno));
+ snprintf(buffer, 4096, ">%s", trb_strerror(trb_errno));
}
return buffer;