static int hexMode = HEXMODE;
-static const char trbcmd_version[] = "$Revision: 2.77 $";
+static const char trbcmd_version[] = "$Revision: 2.78 $";
#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_MAX_SIZE = 4194304; /* *4Bytes = 5MByte */
+static size_t BUFFER_SIZE = 4194304; /* 4MByte */
+static uint32_t buffer[4194304];
/* ---- Error Handling -------------------------------------------------- */
/*******************************************/
int status = 0;
- uint32_t *data = NULL;
- int i;
+ int i;
if (cmdLen != 3) {
logError(ERROR, "Invalid command, try -h option\n");
"reg_address: 0x%04x\n", trb_address, reg_address);
}
- data = (uint32_t *) malloc(sizeof(uint32_t) * NUM_ENDPOINTS * 2);
- if (data == NULL)
- abort();
-
status = trb_register_read(trb_address, reg_address,
- data, NUM_ENDPOINTS * 2);
+ buffer, BUFFER_SIZE);
if (status == -1) {
logError(ERROR, "read_register failed: %s\n", trb_strerror());
} else {
for (i = 0; i < status; i += 2) {
- fprintf(stdout, "0x%04x 0x%08x\n", data[i], data[i + 1]);
+ fprintf(stdout, "0x%04x 0x%08x\n", buffer[i], buffer[i + 1]);
}
/* Check Status-Bits */
trb_termstr(trb_term));
}
}
- free(data);
} else if (strncmp(cmd[0], "rt", CMD_SIZE) == 0) {
/*******************************************/
int status = 0;
- uint32_t *data = NULL;
int i;
if (cmdLen != 3) {
"reg_address: 0x%04x\n", trb_address, reg_address);
}
- 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 * 3);
+ buffer, BUFFER_SIZE);
if (status == -1) {
logError(ERROR, "read_register failed: %s\n", trb_strerror());
} else {
for (i = 0; i < status; i += 3) {
fprintf(stdout, "0x%04x 0x%08x 0x%04x\n",
- data[i], data[i + 1], data[i + 2]);
+ buffer[i], buffer[i + 1], buffer[i + 2]);
}
/* Check Status-Bits */
trb_termstr(trb_term));
}
}
- free(data);
} else if (strncmp(cmd[0], "w", CMD_SIZE) == 0) {
/* Register Read Memory */
/*******************************************/
- uint32_t *data = NULL;
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;
"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();
-
status = trb_register_read_mem(trb_address, reg_address, option,
- size, data, USER_BUFFER_SIZE);
+ size, buffer, BUFFER_SIZE);
if (status == -1) {
logError(ERROR, "read_register_mem failed: %s\n",
trb_strerror());
return -1;
} else {
/* Print data-buffer */
- p = data;
+ p = buffer;
end = p + status;
while (p < end) {
len = (*p >> 16) & 0xffff;
trb_termstr(trb_term));
}
}
- free(data);
} else if (strncmp(cmd[0], "rmt", CMD_SIZE) == 0) {
/* Register Read Memory plus TimeStamp */
/*******************************************/
- uint32_t *data = NULL;
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;
"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();
-
status = trb_registertime_read_mem(trb_address, reg_address, option,
- size, data, USER_BUFFER_SIZE);
+ size, buffer, BUFFER_SIZE);
if (status == -1) {
logError(ERROR, "read_registertime_mem failed: %s\n",
trb_strerror());
return -1;
} else {
/* Print data-buffer */
- p = data;
+ p = buffer;
end = p + status;
while (p < end) {
len = (*p >> 16) & 0xffff;
trb_termstr(trb_term));
}
}
- free(data);
} else if (strncmp(cmd[0], "wm", CMD_SIZE) == 0) {
/* ReadUId */
/*******************************************/
- uint32_t *uidBuffer = NULL;
int status;
unsigned int i;
"Command: READ_UID: trb_address: 0x%04x\n", trb_address);
}
- uidBuffer = (uint32_t *) malloc(sizeof(uint32_t) * NUM_ENDPOINTS * 4);
- if (uidBuffer == NULL)
- abort();
-
- status = trb_read_uid(trb_address, uidBuffer, NUM_ENDPOINTS * 4);
+ status = trb_read_uid(trb_address, buffer, BUFFER_SIZE);
if (status == -1) {
logError(ERROR, "read_uid failed: %s\n",
trb_strerror());
return -1;
} else {
- for (i = 0;
- ((i < (unsigned int)status) && (i < NUM_ENDPOINTS * 4));
- i += 4) {
+ for (i = 0; i < status; i += 4) {
fprintf(stdout, "0x%04x 0x%08x%08x 0x%02x\n",
- uidBuffer[i + 3],
- uidBuffer[i], uidBuffer[i + 1], uidBuffer[i + 2]);
+ buffer[i + 3],
+ buffer[i], buffer[i + 1], buffer[i + 2]);
}
/* Check Status-Bits */
if (trb_errno == TRB_STATUS_WARNING) {
trb_termstr(trb_term));
}
}
-
- free(uidBuffer);
-
} else if (strncmp(cmd[0], "s", CMD_SIZE) == 0) {
/*******************************************/
"number: 0x%04x\n", type, random, info, number);
}
- 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_MAX_SIZE);
+ buffer, BUFFER_SIZE);
if (status == -1) {
logError(ERROR, "read_ipu_data failed: %s\n",
trb_strerror());
}
}
- free(buffer);
-
} else if (strncmp(cmd[0], "f", CMD_SIZE) == 0) {
/*******************************************/