static int hexMode = HEXMODE;
-static const char trbcmd_version[] = "$Revision: 2.59 $";
+static const char trbcmd_version[] = "$Revision: 2.60 $";
#define BACKLOG 10
static uint16_t tcp_port = 55555;
/* ---- User Buffer Size ------------------------------------------------ */
-static const size_t NUM_ENDPOINTS = 1024; /* Maximum of 16KByte */
-static size_t USER_BUFFER_SIZE = 0;
+static const size_t NUM_ENDPOINTS = 1024; /* Maximum of 16KByte */
+static size_t USER_BUFFER_MAX_SIZE = 1310720; /* *4Bytes = 5MByte */
/* ---- Error Handling -------------------------------------------------- */
}
#define CMD_SIZE 256
-#define CMD_MAX_NUM 10
+#define CMD_MAX_ARGS 10
int start(int argc, char **argv)
{
char scriptFileName[256] = "";
- char cmd[CMD_MAX_NUM][CMD_SIZE];
+ char cmd[CMD_MAX_ARGS][CMD_SIZE];
char *cmdLine = NULL;
size_t cmdLineLen = 0;
unsigned int cmdLen = 0;
int opt;
int i;
- for (i = 0; i < CMD_MAX_NUM; i++) {
+ for (i = 0; i < CMD_MAX_ARGS; i++) {
cmd[i][0] = 0;
}
- /* LowMem Settings, i.e. 3 MBye maximum */
- USER_BUFFER_SIZE = 786432; /* 0xc000 * 4 Byte */
-
trb_debug = 0;
/* Parse Arguments */
return 0;
break;
case 'M':
- /* HighMem Setting, i.e. 20 MByte maximum 0x500000 * 4 */
- USER_BUFFER_SIZE = 5242880;
+ /* HighMem Setting */
+ USER_BUFFER_MAX_SIZE = 5242880; /* *4Bytes = 20MByte */
break;
default:
break;
/* Get command from function-call */
unsigned int i;
cmdLen = argc - optind;
- for (i = 0; (i < cmdLen) && (i < CMD_MAX_NUM); i++) {
+ for (i = 0; (i < cmdLen) && (i < CMD_MAX_ARGS); i++) {
strncpy(cmd[i], argv[optind + i], CMD_SIZE);
}
scriptStatus = -1;
/* Get next command from file */
lineCtr++;
/* Initialize */
- for (i = 0; i < CMD_MAX_NUM; i++) {
+ for (i = 0; i < CMD_MAX_ARGS; i++) {
cmd[i][0] = '\0';
}
cmd[0], cmd[1], cmd[2], cmd[3], cmd[4],
cmd[5], cmd[6], cmd[7], cmd[8], cmd[9]);
- for (i = 0, cmdLen = 0; i < CMD_MAX_NUM; i++, cmdLen++) {
+ for (i = 0, cmdLen = 0; i < CMD_MAX_ARGS; i++, cmdLen++) {
if (cmd[i][0] == '\0')
break;
}
}
}
- if (strncmp(cmd[0], "w", CMD_SIZE) == 0) {
-
- /*******************************************/
- /* Register Write */
- /*******************************************/
-
- uint32_t value = 0;
-
- if (cmdLen != 4) {
- logError(ERROR, "Invalid command, try -h option\n");
- return -1;
- }
-
- trb_address = strtoul(cmd[1], NULL, hexMode == 1 ? 16 : 0);
- reg_address = strtoul(cmd[2], NULL, hexMode == 1 ? 16 : 0);
- value = strtoul(cmd[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);
- }
-
- if (trb_register_write(trb_address, reg_address, value) == -1) {
- logError(ERROR, "write_register failed %s\n", trb_termstr(trb_term));
- return -1;
- } else {
- if (trb_errno == TRB_STATUS_WARNING) {
- logError(WARNING, "Status-Bit(s) have been set:\n%s\n",
- trb_termstr(trb_term));
- }
- }
-
- } else if (strncmp(cmd[0], "r", CMD_SIZE) == 0) {
+ if (strncmp(cmd[0], "r", CMD_SIZE) == 0) {
/*******************************************/
/* Register Read */
"reg_address: 0x%04x\n", trb_address, reg_address);
}
- data = (uint32_t *) malloc(sizeof(uint32_t) * NUM_ENDPOINTS * 2);
+ data = (uint32_t *) malloc(sizeof(uint32_t) * NUM_ENDPOINTS * 3);
if (data == NULL)
abort();
status = trb_registertime_read(trb_address, reg_address,
- data, NUM_ENDPOINTS * 2);
+ data, NUM_ENDPOINTS * 3);
if (status == -1) {
logError(ERROR, "read_register failed: %s\n", trb_strerror());
} else {
}
free(data);
+ } else if (strncmp(cmd[0], "w", CMD_SIZE) == 0) {
+
+ /*******************************************/
+ /* Register Write */
+ /*******************************************/
+
+ uint32_t value = 0;
+
+ if (cmdLen != 4) {
+ logError(ERROR, "Invalid command, try -h option\n");
+ return -1;
+ }
+
+ trb_address = strtoul(cmd[1], NULL, hexMode == 1 ? 16 : 0);
+ reg_address = strtoul(cmd[2], NULL, hexMode == 1 ? 16 : 0);
+ value = strtoul(cmd[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);
+ }
+
+ if (trb_register_write(trb_address, reg_address, value) == -1) {
+ logError(ERROR, "write_register failed %s\n", trb_termstr(trb_term));
+ return -1;
+ } else {
+ if (trb_errno == TRB_STATUS_WARNING) {
+ logError(WARNING, "Status-Bit(s) have been set:\n%s\n",
+ trb_termstr(trb_term));
+ }
+ }
+
} else if (strncmp(cmd[0], "rm", CMD_SIZE) == 0) {
/*******************************************/
uint16_t size = 0;
uint8_t option = 0;
int status;
+ size_t USER_BUFFER_SIZE = 0;
const uint32_t *p;
const uint32_t *end = NULL;
unsigned int len;
reg_address = strtoul(cmd[2], NULL, hexMode == 1 ? 16 : 0);
size = strtoul(cmd[3], NULL, hexMode == 1 ? 16 : 0);
option = strtoul(cmd[4], NULL, hexMode == 1 ? 16 : 0);
-
+
/* DEBUG Info */
if (trb_debug > 0) {
fprintf(stderr,
"size: 0x%04x, "
"option: %d\n", trb_address, reg_address, size, option);
}
-
+
+ USER_BUFFER_SIZE =
+ (NUM_ENDPOINTS * size + NUM_ENDPOINTS) < USER_BUFFER_MAX_SIZE
+ ? NUM_ENDPOINTS * size + NUM_ENDPOINTS
+ : USER_BUFFER_MAX_SIZE;
+
data = (uint32_t *) malloc(sizeof(uint32_t) * USER_BUFFER_SIZE);
if (data == NULL)
abort();
uint16_t size = 0;
uint8_t option = 0;
int status;
+ size_t USER_BUFFER_SIZE = 0;
const uint32_t *p;
const uint32_t *end = NULL;
unsigned int len;
"size: 0x%04x, "
"option: %d\n", trb_address, reg_address, size, option);
}
-
+
+ USER_BUFFER_SIZE =
+ (NUM_ENDPOINTS * size * 2 + NUM_ENDPOINTS) < USER_BUFFER_MAX_SIZE
+ ? NUM_ENDPOINTS * size * 2 + NUM_ENDPOINTS
+ : USER_BUFFER_MAX_SIZE;
+
data = (uint32_t *) malloc(sizeof(uint32_t) * USER_BUFFER_SIZE);
if (data == NULL)
abort();
"info: 0x%02x, "
"number: 0x%04x\n", type, random, info, number);
}
-
- buffer = (uint32_t *) malloc(sizeof(uint32_t) * USER_BUFFER_SIZE);
+
+ buffer = (uint32_t *) malloc(sizeof(uint32_t) * USER_BUFFER_MAX_SIZE);
if (buffer == NULL)
abort();
status = trb_ipu_data_read(type, info, random, number,
- buffer, USER_BUFFER_SIZE);
+ buffer, USER_BUFFER_MAX_SIZE);
if (status == -1) {
logError(ERROR, "read_ipu_data failed: %s\n",
trb_strerror());
} else if (strncmp(cmd[0], "clearbit", CMD_SIZE) == 0) {
/*******************************************/
- /* Register Clear Bits */
+ /* Register Clear Bits */
/*******************************************/
int status = 0;
} else if (strncmp(cmd[0], "loadbit", CMD_SIZE) == 0) {
/*******************************************/
- /* Register Load Bits */
+ /* Register Load Bits */
/*******************************************/
int status = 0;