static int hexMode = HEXMODE;
-static const char trbcmd_version[] = "$Revision: 2.28 $";
+static const char trbcmd_version[] = "$Revision: 2.29 $";
+
+/* ---- User Buffers --------------------------------------------------- */
+
+#define NUM_ENDPOINTS 512
+#define READ_MEM_BUFFER_SIZE (NUM_ENDPOINTS * (32768 + 2))
+#define READ_IPU_BUFFER_SIZE (10 * 1024)
/* ------ MAIN ---------------------------------------------------------- */
#define CMD_SIZE 256
#define CMD_MAX_NUM 10
-#define READ_MEM_SIZE 1048576
int main(int argc, char ** argv)
{
/*******************************************/
int status = 0;
- uint32_t data[256];
+ uint32_t *data = NULL;
int i;
if (cmdLen != 3) {
"reg_address: 0x%04x\n",
trb_address, reg_address);
}
-
- status = trb_register_read(trb_address, reg_address, data, 256);
+
+ 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);
if (status == -1) {
if (scriptFile != NULL) {
fprintf(stderr, "Line #%d: ", lineCtr);
trb_address, reg_address, size, option);
}
- if ((data = malloc(sizeof(uint32_t) * READ_MEM_SIZE)) == NULL) abort();
+ data = (uint32_t*)malloc(sizeof(uint32_t) * READ_MEM_BUFFER_SIZE);
+ if (data == NULL) abort();
status =
trb_register_read_mem(trb_address, reg_address, option,
- size, data, READ_MEM_SIZE);
+ size, data, READ_MEM_BUFFER_SIZE);
if (status == -1) {
if (scriptFile != NULL) {
fprintf(stderr, "Line #%d: ", lineCtr);
}
}
- if ((data = malloc(sizeof(uint32_t) * dataSize)) == NULL) abort();
+ data = (uint32_t*)malloc(sizeof(uint32_t) * dataSize);
+ if (data == NULL) abort();
+
while (getline(&line, &len, file) != -1) {
if (size >= dataSize) {
dataSize += 64;
- if ((data = realloc(data, sizeof(uint32_t) * dataSize)) == NULL) {
- abort();
- }
+ data = (uint32_t*)realloc(data, sizeof(uint32_t) * dataSize);
+ if (data == NULL) abort();
}
data[size++] = strtoul(line, NULL, hexMode == 1 ? 16 : 0);
}
/* ReadUId */
/*******************************************/
- uint32_t uidBuffer[512];
+ uint32_t *uidBuffer = NULL;
int status;
int i;
"Command: READ_UID: trb_address: 0x%04x\n",
trb_address);
}
-
- status = trb_read_uid(trb_address, uidBuffer, 128);
+
+ uidBuffer = (uint32_t*)malloc(sizeof(uint32_t) * NUM_ENDPOINTS * 4);
+ if (uidBuffer == NULL) abort();
+
+ status = trb_read_uid(trb_address, uidBuffer, NUM_ENDPOINTS * 4);
if (status == -1) {
if (scriptFile != NULL) {
fprintf(stderr, "Line #%d: ", lineCtr);
/* IPU channel readout */
/*******************************************/
- uint32_t buffer[4096];
+ uint32_t *buffer = NULL;
uint8_t type = 0;
uint8_t random = 0;
uint8_t info = 0;
"number: 0x%04x\n",
type, random, info, number);
}
- status = trb_ipu_data_read(type, info, random, number, buffer, 4096);
+
+ buffer = (uint32_t*)malloc(sizeof(uint32_t) * READ_IPU_BUFFER_SIZE);
+ if (buffer == NULL) abort();
+
+ status = trb_ipu_data_read(type, info, random, number,
+ buffer, READ_IPU_BUFFER_SIZE);
if (status == -1) {
if (scriptFile != NULL) {
fprintf(stderr, "Line #%d: ", lineCtr);