/* Error Handling */
int trb_errno = TRB_NONE;
-uint64_t trb_statusbits = 0;
+
+TRB_TERM trb_term = {0, 0, 0, 0};
void trb_error(const char *s)
{
}
/* Print Statusbits */
- if (trb_errno == TRB_TERM_ERRBIT) {
- fprintf(stderr, "%s\n", trb_statusbits_str(trb_statusbits));
+ if (trb_errno == TRB_STATUS_ERROR) {
+ fprintf(stderr, "%s\n", trb_strterm(trb_term));
}
}
"User-Buffer Overflow",
"Invalid Channel",
"Invalid number of Packages returned",
- "TERMINATION ErrorBit(s) set",
+ "Termination Status Error",
"Invalid TRB-Address",
"Invalid Data-Buffer Length",
"Endpoint not reached",
"DMA not available (check whether module 'can_module.ko' is loaded)",
"DMA-Timeout",
- "ReadMem invalid size"
+ "ReadMem invalid size",
+ "Invalid data-length give by Header"
};
- if (errno < 21) {
+ if (errno < 22) {
return errorstring[errno];
} else {
return "Unknown Errno";
}
}
-const char* trb_statusbits_str(uint64_t statusbits)
+const char* trb_strterm(TRB_TERM term)
{
- static const char commonStatusBits[16][64] = {
- "Endpoint not reached",
- "Coll: collision detected",
- "WordMiss: word missing",
- "Checksum: checksum error",
- "DontKnow: dont understand",
- "BufferMatch: buffer mismatch",
- "", "", "", "", "", "", "", "", "", ""
+ static const char commonStatusBits[16][64] = {
+ "Endpoint not reached", /* error */
+ "Coll: collision detected", /* error */
+ "WordMiss: word missing", /* error */
+ "Checksum: checksum error", /* status, at the moment */
+ "DontKnow: dont understand", /* error */
+ "BufferMatch: buffer mismatch", /* error */
+ "", "", "", "", "", "", "", "", "", ""
};
- static const char ch0StatusBits[16][64] = {
- "Ch0_TrigCtr: trigger counter mismatch",
- "",
- "",
- "",
- "Ch0_BufferHalfFull: data-buffers half full",
- "Ch0_BuffersFull: data-buffers almost full"
+ static const char ch0StatusBits[16][64] = {
+ "Ch0_TrigCtr: trigger counter mismatch", /* status */
+ "",
+ "",
+ "",
+ "Ch0_BufferHalfFull: data-buffers half full", /* status */
+ "Ch0_BuffersFull: data-buffers almost full" /* status */
"", "", "", "", "", "", "", "", "", ""
};
- static const char ch1StatusBits[16][64] = {
- "Ch1_TrigNum: trigger number mismatch",
- "Ch1_TrigCode: trigger code / random mismatch",
- "Ch1_Length: wrong length",
- "Ch1_NoAnswer: answer missing",
- "",
- "",
- "",
- "",
- "Ch1_NotFound: not found"
- "", "", "", "", "", "", "", ""
+ static const char ch1StatusBits[16][64] = {
+ "Ch1_TrigNum: trigger number mismatch", /* status */
+ "Ch1_TrigCode: trigger code / random mismatch", /* status */
+ "Ch1_Length: wrong length", /* status */
+ "Ch1_NoAnswer: answer missing", /* status */
+ "",
+ "",
+ "",
+ "",
+ "Ch1_NotFound: sent trigger number mismatch", /* status */
+ "Ch1_DataMissing: parts of the data are missing",/* status */
+ "Ch1_Sync: serious sync problem detected", /* status */
+ "Ch1_EvtBroken: event data corrupted", /* status */
+ "", "", "", ""
};
static const char ch2StatusBits[16][64] = {
"", "", "", "", "", "", "", ""
};
- static const char ch3StatusBits[16][64] = {
- "Ch3_Address: unknown address",
- "Ch3_TimeOut: timeout error",
- "Ch3_NoData: no more data"
+ static const char ch3StatusBits[16][64] = {
+ "Ch3_Address: unknown address", /* error */
+ "Ch3_TimeOut: timeout error", /* error */
+ "Ch3_NoData: no more data" /* status */
"", "", "", "", "", "", "", "", "", "", "", "", ""
};
static char buffer[2048] = "";
unsigned int i;
- uint8_t channel = (statusbits & 0x700000000LL) >> 32;
- if (channel >= 4) {
- snprintf(buffer, 2048, "INVALID ChannelId %d", channel);
+ if (term.channel >= 4) {
+ snprintf(buffer, 2048, "INVALID ChannelId %d", term.channel);
return buffer;
}
snprintf(buffer, 2048,
"CommonStatusBits: 0x%04x, Channel#%d StatusBits: 0x%04x\n",
- (uint16_t)(statusbits & 0x0000ffffLL),
- channel,
- (uint16_t)((statusbits & 0xffff0000LL) >> 16));
+ term.status_common,
+ term.channel,
+ term.status_channel);
for (i = 0; i < 16; i++) {
- if (((statusbits & 0xffffLL) & (0x01LL << i)) != (i != 0 ? 0 : 1)) {
+ if ((term.status_common & (0x01 << i)) != (i != 0 ? 0 : 1)) {
strncat(buffer, " ", 2048);
strncat(buffer, commonStatusBits[i], 2048);
strncat(buffer, "\n", 2048);
}
}
for (i = 0; i < 16; i++) {
- if ((((statusbits & 0xffff0000LL) >> 16) & (0x01LL << i)) != 0) {
+ if ((term.status_channel & (0x01 << i)) != 0) {
strncat(buffer, " ", 2048);
- strncat(buffer, chStatusBits[channel] + 64 * i, 2048);
+ strncat(buffer, chStatusBits[term.channel] + 64 * i, 2048);
strncat(buffer, "\n", 2048);
}
}