#define TEMP_RESOLUTION 0.0625
-static const char trbrichcmd_version[] = "$Revision: 1.9 $";
+static const uint16_t BroadCastRich = 0xfffb;
+
+static const char trbrichcmd_version[] = "$Revision: 1.10 $";
static const uint16_t adcm_uid_register = 0xc000;
printf(" -V Version number\n");
printf("\nCommands:\n");
printf(" uid <trb_address> "
- "-> read uids from APV-FrondEnds\n"
- " (default-Address:0xfffb)\n");
+ "-> read uids from APVS (default-Addr: 0x%04x)\n",
+ BroadCastRich);
printf(" temp <trb_address> "
- "-> read temperatures from APV-FrondEnds\n"
- " (default-Address:0xfffb)\n");
- printf(" adcsnoop <trb_address> "
+ "-> read temperatures from APVS (default-Addr: 0x%04x)\n",
+ BroadCastRich);
+ printf(" adcsnoop trb_address "
"-> ADC Sniffer Tool\n");
+ printf(" sync_apv <trb_address> "
+ "-> Synchronize APVS (default-Addr: 0x%04x)\n",
+ BroadCastRich);
}
/* ------ MAIN ---------------------------------------------------------- */
/*************************************************/
/* Read UIDs */
/*************************************************/
-
+
uint32_t *buffer = NULL;
uint32_t *tmp = NULL;
uint32_t *end = NULL;
tmp++;
for (i = 0, ctr = 0; (i < len) && (tmp < end); i += 4, tmp += 4, ctr++) {
if ((tmp[2] & 0x8000) > 0 ) {
+
+
printf("%02d 0x%08x%08x\n", ctr, tmp[1], tmp[0]);
} else {
printf("%02d ------------------\n", ctr);
}
+
+
}
printf("\n");
}
uint32_t *tmp = NULL;
uint32_t *end = NULL;
int status = 0;
- uint16_t trb_address = 0xfffb;
+ uint16_t trb_address = BroadCastRich;
if (argc - optind == 2) {
trb_address = (uint16_t)strtoul(argv[optind + 1], NULL, 0);
free(sampleBuffer[ch]);
sampleBuffer[ch] = NULL;
}
+
+ } else if (strcmp(argv[optind], "sync_apv") == 0) {
+ /*************************************************/
+ /* Synchronize APVS */
+ /*************************************************/
+ uint32_t *buffer = NULL;
+ uint32_t *tmp = NULL;
+ uint32_t *end = NULL;
+
+ uint16_t trb_address = BroadCastRich;
+ int status = 0;
+ unsigned int timeOut = 0;
+
+ if (argc - optind == 2) {
+ trb_address = (uint16_t)strtoul(argv[optind + 1], NULL, 0);
+ } else if (argc - optind > 2) {
+ usage(argv[0]);
+ exit(EXIT_FAILURE);
+ }
+ if ((buffer = (uint32_t*)malloc(sizeof(uint32_t) * BUFFER_SIZE)) == NULL) {
+ abort();
+ }
+
+ while (timeOut < 3) {
+ if (trb_register_write(trb_address, 0x20, 0x80000000) == -1) {
+ trb_error("Error sync_apv failed sync");
+ exit(EXIT_FAILURE);
+ }
+
+ status = trb_register_read_mem(trb_address, 0xb000, 0, 15,
+ buffer, BUFFER_SIZE);
+ if (status == -1) {
+ trb_error("Error sync_apv failed read status");
+ exit(EXIT_FAILURE);
+ }
+
+ tmp = buffer;
+ end = buffer + status;
+ while (tmp < end) {
+ unsigned int len = *tmp >> 16;
+ uint16_t endPoint = *tmp & 0xffff;
+ unsigned int i;
+ unsigned int ctr;
+ tmp++;
+ for (i = 0, ctr = 0; (i < len) && (tmp < end); i++, tmp ++, ctr++) {
+ if (!(((*tmp >> 29) == 0x8) ||
+ ((*tmp >> 29) == 0x1))) {
+ fprintf(stderr,
+ "TimeOut: %d Sync Failed on EndPoint: "
+ "0x%04x APV#: %02d\n",
+ timeOut, endPoint, ((*tmp >> 16) &0xf));
+ }
+ }
+ }
+ timeOut++;
+ }
+ free(buffer);
+
} else {
usage(basename(argv[0]));
exit(EXIT_FAILURE);