diff --git a/MAC/APL/PIC/TBBDriver/src/AllocCmd.cc b/MAC/APL/PIC/TBBDriver/src/AllocCmd.cc index 41a2ec793f1b171c4cc0a4bd74826d403e111dd9..fe33800f99202315dfc78e8820d91638a890ce9a 100644 --- a/MAC/APL/PIC/TBBDriver/src/AllocCmd.cc +++ b/MAC/APL/PIC/TBBDriver/src/AllocCmd.cc @@ -120,15 +120,15 @@ void AllocCmd::sendTpEvent() // stage 1, get board memory size case 0: { TPSizeEvent tp_event; - tp_event.opcode = TPSIZE; - tp_event.status = 0; + tp_event.opcode = oc_SIZE; + tp_event.status = 0; TS->boardPort(getBoardNr()).send(tp_event); } break; // stage 2, allocate memory case 1: { TPAllocEvent tp_event; - tp_event.opcode = TPALLOC; + tp_event.opcode = oc_ALLOC; tp_event.status = 0; itsRcuStatus = 0; diff --git a/MAC/APL/PIC/TBBDriver/src/ArpCmd.cc b/MAC/APL/PIC/TBBDriver/src/ArpCmd.cc index 6f0693c9dfdece331f9f1571f329d90cfceb30d3..7037b979f00bbc39f8a48e0e73b0a44145345f06 100644 --- a/MAC/APL/PIC/TBBDriver/src/ArpCmd.cc +++ b/MAC/APL/PIC/TBBDriver/src/ArpCmd.cc @@ -79,7 +79,7 @@ void ArpCmd::saveTbbEvent(GCFEvent& event) void ArpCmd::sendTpEvent() { TPArpEvent tp_event; - tp_event.opcode = TPARP; + tp_event.opcode = oc_ARP; tp_event.status = 0; TS->boardPort(getBoardNr()).send(tp_event); diff --git a/MAC/APL/PIC/TBBDriver/src/ArpModeCmd.cc b/MAC/APL/PIC/TBBDriver/src/ArpModeCmd.cc index 142e8439a1006940945a3d7e214421849859be56..fb6c7a1eafb2754f89a0947f5ee6a65168d42e4b 100644 --- a/MAC/APL/PIC/TBBDriver/src/ArpModeCmd.cc +++ b/MAC/APL/PIC/TBBDriver/src/ArpModeCmd.cc @@ -81,7 +81,7 @@ void ArpModeCmd::saveTbbEvent(GCFEvent& event) void ArpModeCmd::sendTpEvent() { TPArpModeEvent tp_event; - tp_event.opcode = TPARPMODE; + tp_event.opcode = oc_ARPMODE; tp_event.status = 0; tp_event.mode = itsMode; diff --git a/MAC/APL/PIC/TBBDriver/src/BoardCmdHandler.cc b/MAC/APL/PIC/TBBDriver/src/BoardCmdHandler.cc index 9e5d5c342598786847a822a7425fa0171d975a3a..275dbaa0fc649e3d75c4f3e407afb577874e6173 100644 --- a/MAC/APL/PIC/TBBDriver/src/BoardCmdHandler.cc +++ b/MAC/APL/PIC/TBBDriver/src/BoardCmdHandler.cc @@ -94,25 +94,28 @@ GCFEvent::TResult BoardCmdHandler::send_state(GCFEvent& event, GCFPortInterface& } break; case F_ENTRY: { - if (itsCmd != 0) { - if (itsDone) { - itsCmd->sendTbbAckEvent(itsClientPort); - TRAN(BoardCmdHandler::idle_state); - } else { - itsRetries = 0; - itsCmd->sendTpEvent(); - TRAN(BoardCmdHandler::waitack_state); - } + if (itsDone) { + LOG_DEBUG_STR("entering send state, cmd is done"); + itsCmd->sendTbbAckEvent(itsClientPort); + // set timer for TBBDriver, to return to idle state + itsSleepTimer->setTimer(0.0); + TRAN(BoardCmdHandler::idle_state); + } else { + LOG_DEBUG_STR("entering send state, next cmd"); + itsRetries = 0; + itsCmd->sendTpEvent(); + TRAN(BoardCmdHandler::waitack_state); } } break; case F_TIMER: { - } break; + } break; case F_EXIT: { } break; default: { + status = GCFEvent::NEXT_STATE; } break; } return(status); @@ -135,6 +138,9 @@ GCFEvent::TResult BoardCmdHandler::waitack_state(GCFEvent& event, GCFPortInterfa case F_TIMER: { if (&port == itsSleepTimer) { + if (itsCmd->isDone()) { + itsDone = true; + } TRAN(BoardCmdHandler::send_state); break; } @@ -172,7 +178,7 @@ GCFEvent::TResult BoardCmdHandler::waitack_state(GCFEvent& event, GCFPortInterfa itsCmd->saveTpAckEvent(event); if (itsCmd->getSleepTime() > 0.0) { itsSleepTimer->setTimer(itsCmd->getSleepTime()); - itsCmd->setSleepTime(0); + itsCmd->setSleepTime(0.0); } else { if (itsCmd->isDone()) { itsDone = true; diff --git a/MAC/APL/PIC/TBBDriver/src/CepDelayCmd.cc b/MAC/APL/PIC/TBBDriver/src/CepDelayCmd.cc index 2771a2f66652d0eb6c5e69b83027ade057bc5758..a7a7bd0497fa552d48631419aa4b7b437ba78bc8 100644 --- a/MAC/APL/PIC/TBBDriver/src/CepDelayCmd.cc +++ b/MAC/APL/PIC/TBBDriver/src/CepDelayCmd.cc @@ -81,7 +81,7 @@ void CepDelayCmd::saveTbbEvent(GCFEvent& event) void CepDelayCmd::sendTpEvent() { TPCepDelayEvent tp_event; - tp_event.opcode = TPCEPDELAY; + tp_event.opcode = oc_CEP_DELAY; tp_event.status = 0; tp_event.delay = itsDelay; diff --git a/MAC/APL/PIC/TBBDriver/src/CepStatusCmd.cc b/MAC/APL/PIC/TBBDriver/src/CepStatusCmd.cc index 756fcf11973ade96dcdf9f020621bba04130aef2..92917c96eefac9f95f05a553a435636d02d371ef 100644 --- a/MAC/APL/PIC/TBBDriver/src/CepStatusCmd.cc +++ b/MAC/APL/PIC/TBBDriver/src/CepStatusCmd.cc @@ -79,7 +79,7 @@ void CepStatusCmd::saveTbbEvent(GCFEvent& event) void CepStatusCmd::sendTpEvent() { TPCepStatusEvent tp_event; - tp_event.opcode = TPCEPSTATUS; + tp_event.opcode = oc_CEP_STATUS; tp_event.status = 0; TS->boardPort(getBoardNr()).send(tp_event); diff --git a/MAC/APL/PIC/TBBDriver/src/ClearCmd.cc b/MAC/APL/PIC/TBBDriver/src/ClearCmd.cc index f529225f144108de6d34966b2612b032c050efae..52098a7b25914cdabba2365e0e1cc7facccf7858 100644 --- a/MAC/APL/PIC/TBBDriver/src/ClearCmd.cc +++ b/MAC/APL/PIC/TBBDriver/src/ClearCmd.cc @@ -78,7 +78,7 @@ void ClearCmd::saveTbbEvent(GCFEvent& event) void ClearCmd::sendTpEvent() { TPClearEvent tp_event; - tp_event.opcode = TPCLEAR; + tp_event.opcode = oc_CLEAR; tp_event.status = 0; TS->boardPort(getBoardNr()).send(tp_event); @@ -101,7 +101,7 @@ void ClearCmd::saveTpAckEvent(GCFEvent& event) LOG_DEBUG_STR(formatString("Received ClearAck from boardnr[%d]", getBoardNr())); nextBoardNr(); - if (getBoardNr() == -1) { + if (isDone()) { setSleepTime(4.0); } } diff --git a/MAC/APL/PIC/TBBDriver/src/ConfigCmd.cc b/MAC/APL/PIC/TBBDriver/src/ConfigCmd.cc index 433fbc0c59ccfff89878217841c9815843c35eed..ea4117c8e2b3b12b3e2092eb06f6ab9bbd49c5e9 100644 --- a/MAC/APL/PIC/TBBDriver/src/ConfigCmd.cc +++ b/MAC/APL/PIC/TBBDriver/src/ConfigCmd.cc @@ -23,6 +23,7 @@ #include <lofar_config.h> #include <Common/LofarLogger.h> #include <Common/StringUtil.h> +#include <unistd.h> #include "ConfigCmd.h" @@ -42,7 +43,7 @@ ConfigCmd::ConfigCmd(): for(int boardnr = 0; boardnr < MAX_N_TBBOARDS; boardnr++) { itsStatus[boardnr] = TBB_NO_BOARD; } - setWaitAck(true); + setWaitAck(true); } //--Destructor for ConfigCmd.--------------------------------------------------- @@ -80,12 +81,12 @@ void ConfigCmd::saveTbbEvent(GCFEvent& event) void ConfigCmd::sendTpEvent() { TPConfigEvent tp_event; - tp_event.opcode = TPCONFIG; + tp_event.opcode = oc_CONFIG; tp_event.status = 0; tp_event.imagenr = itsImage; TS->boardPort(getBoardNr()).send(tp_event); - TS->boardPort(getBoardNr()).setTimer(TS->timeout()); + TS->boardPort(getBoardNr()).setTimer(5.0); } // ---------------------------------------------------------------------------- @@ -106,7 +107,7 @@ void ConfigCmd::saveTpAckEvent(GCFEvent& event) } nextBoardNr(); if (isDone()) { - setSleepTime(15.0); + setSleepTime(10.0); } } @@ -122,6 +123,6 @@ void ConfigCmd::sendTbbAckEvent(GCFPortInterface* clientport) tbb_ack.status_mask[boardnr] = itsStatus[boardnr]; } } - + LOG_DEBUG_STR("Sending ConfigAck to client"); if (clientport->isConnected()) { clientport->send(tbb_ack); } } diff --git a/MAC/APL/PIC/TBBDriver/src/DriverSettings.cc b/MAC/APL/PIC/TBBDriver/src/DriverSettings.cc index e11f6eeb3cfe163d44f9567d85a30649483249eb..ccef3a88eaacb792d2cb375e9acd71299b191692 100644 --- a/MAC/APL/PIC/TBBDriver/src/DriverSettings.cc +++ b/MAC/APL/PIC/TBBDriver/src/DriverSettings.cc @@ -215,8 +215,8 @@ void TbbSettings::setMaxBoards (int32 maxboards) itsBoardInfo[nr].boardState = setImage1; itsBoardInfo[nr].memorySize = 0; itsBoardInfo[nr].imageNr = 0; - itsBoardInfo[nr].freeToReset = true; - itsBoardInfo[nr].srcIp = ""; + itsBoardInfo[nr].freeToReset = true; + itsBoardInfo[nr].srcIp = ""; itsBoardInfo[nr].dstIp = ""; itsBoardInfo[nr].srcMac = ""; itsBoardInfo[nr].dstMac = ""; @@ -297,17 +297,6 @@ bool TbbSettings::isBoardActive(int32 boardnr) return (false); } -bool TbbSettings::isBoardSelected(int32 boardnr) -{ - bool active = false; - - for (int cn = 0; cn < itsChannelsOnBoard; cn++) { - if (itsChannelInfo[(boardnr * itsChannelsOnBoard) + cn].Selected) active = true; - } - return (active); -} - - void TbbSettings::clearRcuSettings(int32 boardnr) { for (int cn = 0; cn < itsChannelsOnBoard; cn++) { diff --git a/MAC/APL/PIC/TBBDriver/src/DriverSettings.h b/MAC/APL/PIC/TBBDriver/src/DriverSettings.h index 0d92e921fdad29c0403432b1c9ef50353e0a24b2..e9a7d3a433c89121860be53ebbe237277c0ed605 100644 --- a/MAC/APL/PIC/TBBDriver/src/DriverSettings.h +++ b/MAC/APL/PIC/TBBDriver/src/DriverSettings.h @@ -161,7 +161,6 @@ public: void convertRcu2Ch(int32 rcunr, int32 *boardnr, int32 *channelnr); void convertCh2Rcu(int32 channelnr, int32 *rcunr); bool isBoardActive(int32 boardnr); - bool isBoardSelected(int32 boardnr); void logChannelInfo(int32 channel); uint32 getMemorySize(int32 boardnr); diff --git a/MAC/APL/PIC/TBBDriver/src/ErasefCmd.cc b/MAC/APL/PIC/TBBDriver/src/ErasefCmd.cc index 93c3df525e06c69c5c85f911275c37a7ac471907..67e322fe109a71b24174b71bd6e1eb523a758331 100644 --- a/MAC/APL/PIC/TBBDriver/src/ErasefCmd.cc +++ b/MAC/APL/PIC/TBBDriver/src/ErasefCmd.cc @@ -89,7 +89,7 @@ void ErasefCmd::saveTbbEvent(GCFEvent& event) void ErasefCmd::sendTpEvent() { TPErasefEvent tp_event; - tp_event.opcode = TPERASEF; + tp_event.opcode = oc_ERASEF; tp_event.status = 0; tp_event.addr = static_cast<uint32>(itsSector * FL_SECTOR_SIZE); diff --git a/MAC/APL/PIC/TBBDriver/src/FreeCmd.cc b/MAC/APL/PIC/TBBDriver/src/FreeCmd.cc index f10004f76015451172235aa62f59396ea262b840..1c0d6a549db44c1d93590299fb620acac00daf78 100644 --- a/MAC/APL/PIC/TBBDriver/src/FreeCmd.cc +++ b/MAC/APL/PIC/TBBDriver/src/FreeCmd.cc @@ -106,7 +106,7 @@ void FreeCmd::saveTbbEvent(GCFEvent& event) void FreeCmd::sendTpEvent() { TPFreeEvent tp_event; - tp_event.opcode = TPFREE; + tp_event.opcode = oc_FREE; tp_event.status = 0; itsRcuStatus = 0; diff --git a/MAC/APL/PIC/TBBDriver/src/ImageInfoCmd.cc b/MAC/APL/PIC/TBBDriver/src/ImageInfoCmd.cc index 097ba43ab0ab355d4662283ea75d7becd852fb3c..ad6ae7f856c5780a7e0828e2aafe7c1fe4efc1de 100644 --- a/MAC/APL/PIC/TBBDriver/src/ImageInfoCmd.cc +++ b/MAC/APL/PIC/TBBDriver/src/ImageInfoCmd.cc @@ -87,7 +87,7 @@ void ImageInfoCmd::saveTbbEvent(GCFEvent& event) void ImageInfoCmd::sendTpEvent() { TPReadfEvent tp_event; - tp_event.opcode = TPREADF; + tp_event.opcode = oc_READF; tp_event.status = 0; itsBlock = (itsImage * FL_BLOCKS_IN_IMAGE) + (FL_BLOCKS_IN_IMAGE - 1); diff --git a/MAC/APL/PIC/TBBDriver/src/PageperiodCmd.cc b/MAC/APL/PIC/TBBDriver/src/PageperiodCmd.cc index dd3e115c78886d9ad35d040f1d5f27fb6bd2e885..a3e04e4fcd4c12a1f59fd141c438f21440bf4de8 100644 --- a/MAC/APL/PIC/TBBDriver/src/PageperiodCmd.cc +++ b/MAC/APL/PIC/TBBDriver/src/PageperiodCmd.cc @@ -69,7 +69,7 @@ void PageperiodCmd::saveTbbEvent(GCFEvent& event) void PageperiodCmd::sendTpEvent() { TPPageperiodEvent tp_event; - tp_event.opcode = TPPAGEPERIOD; + tp_event.opcode = oc_PAGE_PERIOD; tp_event.status = 0; tp_event.channel = static_cast<uint32>(itsChannel); diff --git a/MAC/APL/PIC/TBBDriver/src/RawEvent.cc b/MAC/APL/PIC/TBBDriver/src/RawEvent.cc index e1c9aa3bff013acdb1adfcc10dc07bc6eab6bb78..121c20b97e41dc210370dc558937bf0aaa91729a 100644 --- a/MAC/APL/PIC/TBBDriver/src/RawEvent.cc +++ b/MAC/APL/PIC/TBBDriver/src/RawEvent.cc @@ -66,169 +66,189 @@ GCFEvent::TResult RawEvent::dispatch(GCFTask& task, GCFPortInterface& port) // // for all commands opcode(4) + status(4) switch(buf.opcode) { - case TPALLOC: + case oc_ALLOC: buf.event.signal = TP_ALLOC_ACK; buf.event.length = 8; break; - case TPFREE: + case oc_FREE: buf.event.signal = TP_FREE_ACK; buf.event.length = 8; break; - case TPRECORD: + case oc_RECORD: buf.event.signal = TP_RECORD_ACK; buf.event.length = 8; break; - case TPSTOP: + case oc_STOP: buf.event.signal = TP_STOP_ACK; buf.event.length = 8; break; - case TPTRIGGER: + case oc_TRIGGER: buf.event.signal = TP_TRIGGER; buf.event.length = 44; break; - case TPTRIGRELEASE: + case oc_TRIG_RELEASE: buf.event.signal = TP_TRIG_RELEASE_ACK; buf.event.length = 8; break; - case TPTRIGGENERATE: + case oc_TRIG_GENERATE: buf.event.signal = TP_TRIG_GENERATE_ACK; buf.event.length = 8; break; - case TPTRIGSETUP: + case oc_TRIG_SETUP: buf.event.signal = TP_TRIG_SETUP_ACK; buf.event.length = 8; break; - case TPTRIGCOEF: + case oc_TRIG_COEF: buf.event.signal = TP_TRIG_COEF_ACK; buf.event.length = 8; break; - case TPTRIGINFO: + case oc_TRIG_INFO: buf.event.signal = TP_TRIG_INFO_ACK; buf.event.length = 40; break; - case TPREAD: + case oc_READ: buf.event.signal = TP_READ_ACK; buf.event.length = 28; break; - case TPUDP: + case oc_UDP: buf.event.signal = TP_UDP_ACK; buf.event.length = 8; break; - case TPPAGEPERIOD: + case oc_PAGE_PERIOD: buf.event.signal = TP_PAGEPERIOD_ACK; buf.event.length = 12; break; - case TPVERSION: + case oc_VERSION: buf.event.signal = TP_VERSION_ACK; buf.event.length = 40; break; - case TPSIZE: + case oc_SIZE: buf.event.signal = TP_SIZE_ACK; buf.event.length = 12; break; - case TPSTATUS: + case oc_STATUS: buf.event.signal = TP_STATUS_ACK; buf.event.length = 84; break; - case TPERROR: + case oc_ERROR: buf.event.signal = TP_ERROR; buf.event.length = 12; break; - case TPCLEAR: + case oc_CLEAR: buf.event.signal = TP_CLEAR_ACK; buf.event.length = 8; break; - case TPRESET: + case oc_RESET: buf.event.signal = TP_RESET_ACK; buf.event.length = 8; break; - case TPCONFIG: + case oc_CONFIG: buf.event.signal = TP_CONFIG_ACK; buf.event.length = 8; break; - case TPERASEF: + case oc_ERASEF: buf.event.signal = TP_ERASEF_ACK; buf.event.length = 8; break; - case TPERASEFSPEC: + case oc_ERASEF_SPEC: buf.event.signal = TP_ERASEF_SPEC_ACK; buf.event.length = 8; break; - case TPREADF: + case oc_READF: buf.event.signal = TP_READF_ACK; buf.event.length = 1032; break; - case TPWRITEF: + case oc_WRITEF: buf.event.signal = TP_WRITEF_ACK; buf.event.length = 8; break; - case TPWRITEFSPEC: + case oc_WRITEF_SPEC: buf.event.signal = TP_WRITEF_SPEC_ACK; buf.event.length = 8; break; - case TPPROTECT: + case oc_PROTECT: buf.event.signal = TP_PROTECT_ACK; buf.event.length = 8; break; - case TPUNPROTECT: + case oc_UNPROTECT: buf.event.signal = TP_UNPROTECT_ACK; buf.event.length = 8; break; - case TPREADW: + case oc_READW: buf.event.signal = TP_READW_ACK; buf.event.length = 16; break; - case TPWRITEW: + case oc_WRITEW: buf.event.signal = TP_WRITEW_ACK; buf.event.length = 8; break; - case TPREADR: + case oc_READR: buf.event.signal = TP_READR_ACK; buf.event.length = 2056; break; - case TPWRITER: + case oc_WRITER: buf.event.signal = TP_WRITER_ACK; buf.event.length = 8; break; - case TPREADX: + case oc_READX: buf.event.signal = TP_READX_ACK; buf.event.length = 1032; break; - case TPALIVE: + case oc_ALIVE: buf.event.signal = TP_ALIVE_ACK; buf.event.length = 12; break; - case TPARP: + case oc_ARP: buf.event.signal = TP_ARP_ACK; buf.event.length = 8; break; - case TPARPMODE: + case oc_ARPMODE: buf.event.signal = TP_ARP_MODE_ACK; buf.event.length = 8; break; - case TPSTOPCEP: + case oc_STOP_CEP: buf.event.signal = TP_STOP_CEP_ACK; buf.event.length = 8; break; - case TPCEPSTATUS: + case oc_CEP_STATUS: buf.event.signal = TP_CEP_STATUS_ACK; buf.event.length = 12; break; - case TPCEPDELAY: + case oc_CEP_DELAY: buf.event.signal = TP_CEP_DELAY_ACK; buf.event.length = 8; break; - case TPWATCHDOG: + case oc_WATCHDOG: buf.event.signal = TP_WATCHDOG_ACK; buf.event.length = 8; break; - case TPTEMPLIMIT: + case oc_TEMP_LIMIT: buf.event.signal = TP_TEMP_LIMIT_ACK; buf.event.length = 8; break; - - default: + case oc_TESTMODE: + buf.event.signal = TP_TESTMODE_ACK; + buf.event.length = 8; + break; + case oc_UDP_EN_PRG: + buf.event.signal = TP_UDP_EN_PRG_ACK; + buf.event.length = 8; + break; + case oc_UDP_DIS_PRG: + buf.event.signal = TP_UDP_DIS_PRG_ACK; + buf.event.length = 8; + break; + case oc_UDP_CLR_ERR: + buf.event.signal = TP_UDP_CLR_ERR_ACK; + buf.event.length = 8; + break; + case oc_UDP_GET_ERR: + buf.event.signal = TP_UDP_GET_ERR_ACK; + buf.event.length = 32; + break; + + default: buf.event.signal = 0; buf.event.length = 0; break; diff --git a/MAC/APL/PIC/TBBDriver/src/ReadCmd.cc b/MAC/APL/PIC/TBBDriver/src/ReadCmd.cc index cb892b93279fcbfab8a34c9dc5fb2cee73dd9173..dccd8926ba1753ead2cfbee60c7b786dbd68d97f 100644 --- a/MAC/APL/PIC/TBBDriver/src/ReadCmd.cc +++ b/MAC/APL/PIC/TBBDriver/src/ReadCmd.cc @@ -36,7 +36,7 @@ using namespace TBB; //--Constructors for a ReadCmd object.---------------------------------------- ReadCmd::ReadCmd(): - itsStatus(0), itsSecondstime(0), itsSampletime(0), itsPrepages(0), itsPostpages(0) + itsStatus(0), itsStage(0), itsSecondstime(0), itsSampletime(0), itsPrepages(0), itsPostpages(0) { TS = TbbSettings::instance(); setWaitAck(true); @@ -50,7 +50,8 @@ bool ReadCmd::isValid(GCFEvent& event) { if ((event.signal == TBB_READ) ||(event.signal == TP_READ_ACK) - ||(event.signal == TP_WATCHDOG_ACK)) { + ||(event.signal == TP_WATCHDOG_ACK) + ||(event.signal == TP_CEP_STATUS_ACK)) { return(true); } return(false); @@ -74,6 +75,12 @@ void ReadCmd::saveTbbEvent(GCFEvent& event) itsPostpages = tbb_event.postpages; itsStatus = 0; + // check if channel is stopped + if (TS->getChState(getChannelNr()) != 'S') { + itsStatus |= TBB_RCU_NOT_FREE; + setDone(true); + } + if (!TS->isBoardActive(getBoardNr())) { itsStatus |= TBB_NO_BOARD ; setDone(true); @@ -83,17 +90,31 @@ void ReadCmd::saveTbbEvent(GCFEvent& event) // ---------------------------------------------------------------------------- void ReadCmd::sendTpEvent() { - TPReadEvent tp_event; - - tp_event.opcode = TPREAD; - tp_event.status = 0; - tp_event.channel = getChannelNr(); - tp_event.secondstime = itsSecondstime; - tp_event.sampletime = itsSampletime; - tp_event.prepages = itsPrepages; - tp_event.postpages = itsPostpages; - - TS->boardPort(getBoardNr()).send(tp_event); + switch (itsStage) { + case 0: { + TPReadEvent tp_event; + + tp_event.opcode = oc_READ; + tp_event.status = 0; + tp_event.channel = getChannelNr(); + tp_event.secondstime = itsSecondstime; + tp_event.sampletime = itsSampletime; + tp_event.prepages = itsPrepages; + tp_event.postpages = itsPostpages; + TS->boardPort(getBoardNr()).send(tp_event); + } break; + + case 1: { + TPCepStatusEvent tp_event; + + tp_event.opcode = oc_CEP_STATUS; + tp_event.status = 0; + TS->boardPort(getBoardNr()).send(tp_event); + } break; + + default: { + } break; + } TS->boardPort(getBoardNr()).setTimer(TS->timeout()); } @@ -103,15 +124,25 @@ void ReadCmd::saveTpAckEvent(GCFEvent& event) // in case of a time-out, set error mask if (event.signal == F_TIMER) { itsStatus |= TBB_COMM_ERROR; - } else { + } + else if (event.signal == TP_READ_ACK) { TPReadAckEvent tp_ack(event); - // check if busy + LOG_DEBUG_STR(formatString("Received ReadAck from boardnr[%d]", getBoardNr())); + LOG_DEBUG_STR(formatString("ReadAck.status=%d", tp_ack.status)); if (tp_ack.status == 0xfd) { LOG_DEBUG_STR(formatString("TBB busy, %d pages left, trying until free", tp_ack.pages_left)); setSleepTime(0.1); } else { - LOG_DEBUG_STR(formatString("Received ReadAck from boardnr[%d]", getBoardNr())); + itsStage = 1; + } + } + else if (event.signal == TP_CEP_STATUS_ACK) { + TPCepStatusAckEvent tp_ack(event); + + if (tp_ack.pages_left == 0) { setDone(true); + } else { + setSleepTime(0.1); } } } diff --git a/MAC/APL/PIC/TBBDriver/src/ReadCmd.h b/MAC/APL/PIC/TBBDriver/src/ReadCmd.h index ccae373b540f2992f6f36fc1e71696fe1ce857fd..a14bdedc640dce5874c1cec5eae273db3f3da166 100644 --- a/MAC/APL/PIC/TBBDriver/src/ReadCmd.h +++ b/MAC/APL/PIC/TBBDriver/src/ReadCmd.h @@ -60,6 +60,7 @@ public: private: TbbSettings *TS; uint32 itsStatus; + int32 itsStage; uint32 itsSecondstime; uint32 itsSampletime; uint32 itsPrepages; diff --git a/MAC/APL/PIC/TBBDriver/src/ReadfCmd.cc b/MAC/APL/PIC/TBBDriver/src/ReadfCmd.cc index affeb525aad066a791eb3f54f9140272d2de09db..3829e884a2dce7d238e91a38e55d688ed3d03e63 100644 --- a/MAC/APL/PIC/TBBDriver/src/ReadfCmd.cc +++ b/MAC/APL/PIC/TBBDriver/src/ReadfCmd.cc @@ -93,7 +93,7 @@ void ReadfCmd::saveTbbEvent(GCFEvent& event) void ReadfCmd::sendTpEvent() { TPReadfEvent tp_event; - tp_event.opcode = TPREADF; + tp_event.opcode = oc_READF; tp_event.status = 0; tp_event.addr = static_cast<uint32>(itsBlock * FL_BLOCK_SIZE); diff --git a/MAC/APL/PIC/TBBDriver/src/ReadrCmd.cc b/MAC/APL/PIC/TBBDriver/src/ReadrCmd.cc index 0c162b10e58acb3fee929d359f9ffb4b35145a0e..0159e3c8b8e66e3a0b75a2c5e5dd2a1c1c704c63 100644 --- a/MAC/APL/PIC/TBBDriver/src/ReadrCmd.cc +++ b/MAC/APL/PIC/TBBDriver/src/ReadrCmd.cc @@ -77,7 +77,7 @@ void ReadrCmd::sendTpEvent() { TPReadrEvent tp_event; - tp_event.opcode = TPREADR; + tp_event.opcode = oc_READR; tp_event.status = 0; tp_event.mp = itsMp; tp_event.pid = itsPid; diff --git a/MAC/APL/PIC/TBBDriver/src/ReadwCmd.cc b/MAC/APL/PIC/TBBDriver/src/ReadwCmd.cc index c077b14d1b1a37cb42747083d4399a0132884f4f..f76a423f6158c4da1c7a0ea844d75a465d45d94b 100644 --- a/MAC/APL/PIC/TBBDriver/src/ReadwCmd.cc +++ b/MAC/APL/PIC/TBBDriver/src/ReadwCmd.cc @@ -74,7 +74,7 @@ void ReadwCmd::saveTbbEvent(GCFEvent& event) void ReadwCmd::sendTpEvent() { TPReadwEvent tp_event; - tp_event.opcode = TPREADW; + tp_event.opcode = oc_READW; tp_event.status = 0; tp_event.mp = itsMp; tp_event.addr = itsAddr; diff --git a/MAC/APL/PIC/TBBDriver/src/ReadxCmd.cc b/MAC/APL/PIC/TBBDriver/src/ReadxCmd.cc index 3e32a906ddc971b5a8c6374e3449d17576a18428..7a5820109d1353f2a7b3a0e1164b32b87abc2ba5 100644 --- a/MAC/APL/PIC/TBBDriver/src/ReadxCmd.cc +++ b/MAC/APL/PIC/TBBDriver/src/ReadxCmd.cc @@ -81,7 +81,7 @@ void ReadxCmd::sendTpEvent() { TPReadxEvent tp_event; - tp_event.opcode = TPREADX; + tp_event.opcode = oc_READX; tp_event.status = 0; tp_event.mp = itsMp; tp_event.pid = itsPid; diff --git a/MAC/APL/PIC/TBBDriver/src/RecordCmd.cc b/MAC/APL/PIC/TBBDriver/src/RecordCmd.cc index bbd0ddb7616baf59908f9f7b08a87054bf318e1a..4cc50f7f41bd5e676278fe6bddeed9d4cb65755d 100644 --- a/MAC/APL/PIC/TBBDriver/src/RecordCmd.cc +++ b/MAC/APL/PIC/TBBDriver/src/RecordCmd.cc @@ -107,7 +107,7 @@ void RecordCmd::saveTbbEvent(GCFEvent& event) void RecordCmd::sendTpEvent() { TPRecordEvent tp_event; - tp_event.opcode = TPRECORD; + tp_event.opcode = oc_RECORD; tp_event.status = 0; if ((itsChannelMask[getBoardNr()] == 0xFFFF) && ((getChannelNr()% 16) == 0)) { tp_event.channel = ~0; diff --git a/MAC/APL/PIC/TBBDriver/src/ResetCmd.cc b/MAC/APL/PIC/TBBDriver/src/ResetCmd.cc index 059e8a813a6337d6697f86139b455fe5330bcb03..300b14c14299fb1967218752d3d135d9f858f683 100644 --- a/MAC/APL/PIC/TBBDriver/src/ResetCmd.cc +++ b/MAC/APL/PIC/TBBDriver/src/ResetCmd.cc @@ -91,7 +91,7 @@ void ResetCmd::sendTpEvent() { TPResetEvent tp_event; - tp_event.opcode = TPRESET; + tp_event.opcode = oc_RESET; tp_event.status = 0; if (TS->boardPort(getBoardNr()).isConnected()) { diff --git a/MAC/APL/PIC/TBBDriver/src/SizeCmd.cc b/MAC/APL/PIC/TBBDriver/src/SizeCmd.cc index 0a07817480c62032bb12cd4694756bcbfd292f65..31751da950a99b5ac04dcd675455180f2e363fda 100644 --- a/MAC/APL/PIC/TBBDriver/src/SizeCmd.cc +++ b/MAC/APL/PIC/TBBDriver/src/SizeCmd.cc @@ -78,8 +78,8 @@ void SizeCmd::sendTpEvent() { TPSizeEvent tp_event; - tp_event.opcode = TPSIZE; - tp_event.status = 0; + tp_event.opcode = oc_SIZE; + tp_event.status = 0; TS->boardPort(getBoardNr()).send(tp_event); TS->boardPort(getBoardNr()).setTimer(TS->timeout()); } diff --git a/MAC/APL/PIC/TBBDriver/src/StatusCmd.cc b/MAC/APL/PIC/TBBDriver/src/StatusCmd.cc index 40af177c98439a572c425742c65c3dc6f09df35b..4dbdd594f1c9c7492a085659d838a1247082ad40 100644 --- a/MAC/APL/PIC/TBBDriver/src/StatusCmd.cc +++ b/MAC/APL/PIC/TBBDriver/src/StatusCmd.cc @@ -90,7 +90,7 @@ void StatusCmd::saveTbbEvent(GCFEvent& event) void StatusCmd::sendTpEvent() { TPStatusEvent tp_event; - tp_event.opcode = TPSTATUS; + tp_event.opcode = oc_STATUS; tp_event.status = 0; TS->boardPort(getBoardNr()).send(tp_event); diff --git a/MAC/APL/PIC/TBBDriver/src/StopCepCmd.cc b/MAC/APL/PIC/TBBDriver/src/StopCepCmd.cc index 52d3da8c36ae5a335a976772418be5af72bd7b5c..d2c704204740431e61bb6fca2d87693b08e6b342 100644 --- a/MAC/APL/PIC/TBBDriver/src/StopCepCmd.cc +++ b/MAC/APL/PIC/TBBDriver/src/StopCepCmd.cc @@ -79,7 +79,7 @@ void StopCepCmd::saveTbbEvent(GCFEvent& event) void StopCepCmd::sendTpEvent() { TPStopCepEvent tp_event; - tp_event.opcode = TPSTOPCEP; + tp_event.opcode = oc_STOP_CEP; tp_event.status = 0; TS->boardPort(getBoardNr()).send(tp_event); diff --git a/MAC/APL/PIC/TBBDriver/src/StopCmd.cc b/MAC/APL/PIC/TBBDriver/src/StopCmd.cc index 3f07b21032341e4f3f899dcef913d540102bb6fd..1b19a0edba4a3b19c91e7dfd60775a4245fc2c82 100644 --- a/MAC/APL/PIC/TBBDriver/src/StopCmd.cc +++ b/MAC/APL/PIC/TBBDriver/src/StopCmd.cc @@ -108,7 +108,7 @@ void StopCmd::sendTpEvent() { TPStopEvent tp_event; - tp_event.opcode = TPSTOP; + tp_event.opcode = oc_STOP; tp_event.status = 0; if ((itsChannelMask[getBoardNr()] == 0xFFFF) && ((getChannelNr()% 16) == 0)) { tp_event.channel = ~0; diff --git a/MAC/APL/PIC/TBBDriver/src/TBBDriver.cc b/MAC/APL/PIC/TBBDriver/src/TBBDriver.cc index 1cb1152158e5ebee4dada0286d3ef50bf3faa14c..272e7c1aaf77392e894a1f87d478bb475a5b2a84 100644 --- a/MAC/APL/PIC/TBBDriver/src/TBBDriver.cc +++ b/MAC/APL/PIC/TBBDriver/src/TBBDriver.cc @@ -263,6 +263,8 @@ GCFEvent::TResult TBBDriver::setup_state(GCFEvent& event, GCFPortInterface& port } break; case F_EXIT: { + if (TS->saveTriggersToFile()) { itsSaveTimer->setTimer(2.0, 2.0); } + itsAliveTimer->setTimer(ALIVECHECKTIME); if (retries) delete [] retries; if (waitTimer) delete [] waitTimer; } break; @@ -325,7 +327,7 @@ GCFEvent::TResult TBBDriver::setup_state(GCFEvent& event, GCFPortInterface& port if (TS->getBoardState(board) == setImage1) { TPConfigEvent config; - config.opcode = TPCONFIG; + config.opcode = oc_CONFIG; config.status = 0; config.imagenr = 1; //config.imagenr = 0; @@ -340,7 +342,7 @@ GCFEvent::TResult TBBDriver::setup_state(GCFEvent& event, GCFPortInterface& port if (TS->getBoardState(board) == clearBoard) { TPClearEvent clear; - clear.opcode = TPCLEAR; + clear.opcode = oc_CLEAR; clear.status = 0; itsBoard[board].send(clear); itsBoard[board].setTimer(10.0); @@ -355,7 +357,7 @@ GCFEvent::TResult TBBDriver::setup_state(GCFEvent& event, GCFPortInterface& port (TS->getBoardState(board) == image1Set)) { TPWatchdogEvent watchdog; - watchdog.opcode = TPWATCHDOG; + watchdog.opcode = oc_WATCHDOG; watchdog.status = 0; watchdog.mode = 1; // watchdog is set to eth port //watchdog.mode = 0; @@ -371,7 +373,7 @@ GCFEvent::TResult TBBDriver::setup_state(GCFEvent& event, GCFPortInterface& port (TS->getBoardState(board) == watchdogSet)) { TPFreeEvent free; - free.opcode = TPFREE; + free.opcode = oc_FREE; free.status = 0; free.channel = 0xFFFFFFFF; // send channel = -1 to free all inputs itsBoard[board].send(free); @@ -384,7 +386,7 @@ GCFEvent::TResult TBBDriver::setup_state(GCFEvent& event, GCFPortInterface& port if (TS->getBoardState(board) == boardFreed) { TPAliveEvent alive; - alive.opcode = TPALIVE; + alive.opcode = oc_ALIVE; alive.status = 0; itsBoard[board].send(alive); itsBoard[board].setTimer(10.0); @@ -412,8 +414,6 @@ GCFEvent::TResult TBBDriver::setup_state(GCFEvent& event, GCFPortInterface& port if (setupDone) { LOG_INFO_STR("setting up boards done"); TS->clearBoardSetup(); - if (TS->saveTriggersToFile()) { itsSaveTimer->setTimer(2.0, 2.0); } - itsAliveTimer->setTimer(ALIVECHECKTIME); TRAN(TBBDriver::idle_state); } } break; @@ -603,9 +603,6 @@ GCFEvent::TResult TBBDriver::idle_state(GCFEvent& event, GCFPortInterface& port) default: { // look if the event is a Tbb event if (SetTbbCommand(event.signal)) { - if ((TS->activeBoardsMask() != 0) && (itsAliveCheck == false)) { - itsAliveTimer->cancelAllTimers(); - } status = itsCmdHandler->doEvent(event,port); TRAN(TBBDriver::busy_state); } else { @@ -632,7 +629,6 @@ GCFEvent::TResult TBBDriver::busy_state(GCFEvent& event, GCFPortInterface& port) case F_EXIT: { if (itsCmd) delete itsCmd; - itsAliveTimer->setTimer(ALIVECHECKTIME); } break; case F_ENTRY: { @@ -671,14 +667,13 @@ GCFEvent::TResult TBBDriver::busy_state(GCFEvent& event, GCFPortInterface& port) } else if (&port == itsAliveTimer) { CheckAlive(event, port); - itsAliveTimer->cancelAllTimers(); } else { if (itsCmdHandler->tpCmdDone()) { TRAN(TBBDriver::idle_state); } else { - status = itsCmdHandler->doEvent(event,port); // dispatch time-out event + status = itsCmdHandler->doEvent(event,port); // dispatch timer event } } } break; @@ -760,9 +755,6 @@ GCFEvent::TResult TBBDriver::busy_state(GCFEvent& event, GCFPortInterface& port) case TP_TEMP_LIMIT_ACK: { status = itsCmdHandler->doEvent(event,port); // dispatch ack from boards - if (itsCmdHandler->tpCmdDone()) { - TRAN(TBBDriver::idle_state); - } } break; default: { @@ -814,11 +806,9 @@ bool TBBDriver::CheckAlive(GCFEvent& event, GCFPortInterface& port) static uint32 activeboards; static uint32 sendmask; - - //itsAliveTimer->cancelAllTimers(); if (!itsAliveCheck) { TPAliveEvent tp_event; - tp_event.opcode = TPALIVE; + tp_event.opcode = oc_ALIVE; tp_event.status = 0; itsAliveCheck = true; @@ -827,16 +817,18 @@ bool TBBDriver::CheckAlive(GCFEvent& event, GCFPortInterface& port) sendmask = 0; activeboards = 0; - itsAliveTimer->cancelAllTimers(); // mask all boards to check for(int nr = 0; nr < TS->maxBoards(); nr++) { + + if ((itsCmd != 0) && (itsCmd->getBoardNr() == nr)) { + continue; // if board is busy, don't check alive + } itsBoard[nr].send(tp_event); sendmask |= (1 << nr); } - // 1 timer for al events + // 1 time-out timer for al events itsAliveTimer->setTimer(2.0); } else { - if (event.signal == TP_ALIVE_ACK) { boardnr = TS->port2Board(&port); if (boardnr != -1) { @@ -882,7 +874,6 @@ bool TBBDriver::CheckAlive(GCFEvent& event, GCFPortInterface& port) if (activeboards != TS->activeBoardsMask()) { TS->setActiveBoardsMask(activeboards); - //itsActiveBoardsChange = true; char boardstr[40]; char instr[5]; strcpy(boardstr,""); diff --git a/MAC/APL/PIC/TBBDriver/src/TP_Protocol.prot b/MAC/APL/PIC/TBBDriver/src/TP_Protocol.prot index a7fe717b5b51a5b9ad175fa4ab94ebedcb026f73..47902f423ca1e3ebbd827d0af4d820660854ebf8 100644 --- a/MAC/APL/PIC/TBBDriver/src/TP_Protocol.prot +++ b/MAC/APL/PIC/TBBDriver/src/TP_Protocol.prot @@ -20,58 +20,72 @@ prelude = << PRELUDE_END //--TP Command Opcode's------------------------------------------------------- //--Data Recording---------- - static const uint32 TPALLOC = 0x00000100; // OUT allocate buffer space to a certain input channel - static const uint32 TPFREE = 0x00000101; // OUT free buffer settings and disable input channel - static const uint32 TPRECORD = 0x00000102; // OUT record channel - static const uint32 TPSTOP = 0x00000103; // OUT freeze channel + static const uint32 oc_ALLOC = 0x00000100; // OUT allocate buffer space to a certain input channel + static const uint32 oc_FREE = 0x00000101; // OUT free buffer settings and disable input channel + static const uint32 oc_RECORD = 0x00000102; // OUT record channel + static const uint32 oc_STOP = 0x00000103; // OUT freeze channel + //--Triggering-------------- - static const uint32 TPTRIGGER = 0x00000200; // IN trigger detected - static const uint32 TPTRIGRELEASE = 0x00000201; // OUT clear trigger - static const uint32 TPTRIGGENERATE= 0x00000202; // OUT generate trigger - static const uint32 TPTRIGSETUP = 0x00000203; // OUT setup trigger system - static const uint32 TPTRIGCOEF = 0x00000204; // OUT set coefficients for the filters - static const uint32 TPTRIGINFO = 0x00000205; // IN/OUT get trigger info, same data as TPTRIGGER + static const uint32 oc_TRIGGER = 0x00000200; // IN trigger detected + static const uint32 oc_TRIG_RELEASE = 0x00000201; // OUT clear trigger + static const uint32 oc_TRIG_GENERATE= 0x00000202; // OUT generate trigger + static const uint32 oc_TRIG_SETUP = 0x00000203; // OUT setup trigger system + static const uint32 oc_TRIG_COEF = 0x00000204; // OUT set coefficients for the filters + static const uint32 oc_TRIG_INFO = 0x00000205; // IN/OUT get trigger info, same data as TPTRIGGER + //--Data reading------------ - static const uint32 TPREAD = 0x00000300; // OUT send recorded data to CEP - static const uint32 TPUDP = 0x00000301; // OUT configure UDP and IP header - static const uint32 TPPAGEPERIOD = 0x00000302; // OUT time in one page 30.2 format in nsec - static const uint32 TPSTOPCEP = 0x00000303; // OUT stop CEP transfers - static const uint32 TPCEPSTATUS = 0x00000304; // IN read CEP pages left - static const uint32 TPCEPDELAY = 0x00000305; // OUT set CEP delay between pages + static const uint32 oc_READ = 0x00000300; // OUT send recorded data to CEP + static const uint32 oc_UDP = 0x00000301; // OUT configure UDP and IP header + static const uint32 oc_PAGE_PERIOD = 0x00000302; // OUT time in one page 30.2 format in nsec + static const uint32 oc_STOP_CEP = 0x00000303; // OUT stop CEP transfers + static const uint32 oc_CEP_STATUS = 0x00000304; // IN read CEP pages left + static const uint32 oc_CEP_DELAY = 0x00000305; // OUT set CEP delay between pages //--Board information------- - static const uint32 TPVERSION = 0x00000700; // IN/OUT returns board version - static const uint32 TPSIZE = 0x00000701; // IN/OUT returns TBB memory size + static const uint32 oc_VERSION = 0x00000700; // IN/OUT returns board version + static const uint32 oc_SIZE = 0x00000701; // IN/OUT returns TBB memory size + //--Board status------------ - static const uint32 TPERROR = 0x00000702; // IN error on TBB board - static const uint32 TPSTATUS = 0x00000703; // IN status of board Voltage and Temperature - static const uint32 TPALIVE = 0x00000704; // OUT if response board exist - static const uint32 TPWATCHDOG = 0x00000705; // OUT set watchdog mode - static const uint32 TPTEMPLIMIT = 0x00000706; // OUT set temperature limits for fan control + static const uint32 oc_ERROR = 0x00000702; // IN error on TBB board + static const uint32 oc_STATUS = 0x00000703; // IN status of board Voltage and Temperature + static const uint32 oc_ALIVE = 0x00000704; // OUT if response board exist + static const uint32 oc_WATCHDOG = 0x00000705; // OUT set watchdog mode + static const uint32 oc_TEMP_LIMIT = 0x00000706; // OUT set temperature limits for fan control //--Board control----------- - static const uint32 TPCLEAR = 0x00000710; // OUT clear registers - static const uint32 TPRESET = 0x00000711; // OUT reset to facory image - static const uint32 TPCONFIG = 0x00000712; // OUT reconfigure image + static const uint32 oc_CLEAR = 0x00000710; // OUT clear registers + static const uint32 oc_RESET = 0x00000711; // OUT reset to facory image + static const uint32 oc_CONFIG = 0x00000712; // OUT reconfigure image + //--Remote system update---- - static const uint32 TPERASEFSPEC = 0x00000719; // OUT erase flash memory image 0 - static const uint32 TPERASEF = 0x00000720; // OUT erase flash memory - static const uint32 TPREADF = 0x00000721; // IN/OUT read flash memory - static const uint32 TPWRITEF = 0x00000722; // OUT write flash memory - static const uint32 TPWRITEFSPEC = 0x00000723; // OUT write flash memory image 0 - static const uint32 TPPROTECT = 0x00000724; // OUT protect writing to image 0 - static const uint32 TPUNPROTECT = 0x00000725; // OUT unprotect writing to image 0 + static const uint32 oc_ERASEF_SPEC = 0x00000719; // OUT erase flash memory image 0 + static const uint32 oc_ERASEF = 0x00000720; // OUT erase flash memory + static const uint32 oc_READF = 0x00000721; // IN/OUT read flash memory + static const uint32 oc_WRITEF = 0x00000722; // OUT write flash memory + static const uint32 oc_WRITEF_SPEC = 0x00000723; // OUT write flash memory image 0 + static const uint32 oc_PROTECT = 0x00000724; // OUT protect writing to image 0 + static const uint32 oc_UNPROTECT = 0x00000725; // OUT unprotect writing to image 0 //--DDR2 acces-------------- - static const uint32 TPREADW = 0x00000730; // IN/OUT read 64bit word from mp - static const uint32 TPWRITEW = 0x00000731; // OUT write 64bit wort to mp + static const uint32 oc_READW = 0x00000730; // IN/OUT read 64bit word from mp + static const uint32 oc_WRITEW = 0x00000731; // OUT write 64bit wort to mp + //--Direct register acces--- - static const uint32 TPREADR = 0x00000740; // IN/OUT read register(direct access), for debug purpose - static const uint32 TPWRITER = 0x00000741; // OUT write register(direct access), for debug purpose - static const uint32 TPREADX = 0x00000742; // OUT write register(direct access), for debug purpose + static const uint32 oc_READR = 0x00000740; // IN/OUT read register(direct access), for debug purpose + static const uint32 oc_WRITER = 0x00000741; // OUT write register(direct access), for debug purpose + static const uint32 oc_READX = 0x00000742; // OUT write register(direct access), for debug purpose + + //--Testmodes--------------- + static const uint32 oc_TESTMODE = 0x00000753; // OUT set input to testsignal + static const uint32 oc_UDP_EN_PRG = 0x00000760; // OUT enable prg check in CEP interface + static const uint32 oc_UDP_DIS_PRG = 0x00000761; // OUT disables prg check in CEP interface + static const uint32 oc_UDP_CLR_ERR = 0x00000762; // OUT clear error counter in CEP interface + static const uint32 oc_UDP_GET_ERR = 0x00000763; // OUT return error counter + + //--Settings for CEP port--- + static const uint32 oc_ARP = 0x000007F4; // OUT send 1 Arp message to CEP + static const uint32 oc_ARPMODE = 0x000007F5; // OUT set Arp mode - static const uint32 TPARP = 0x000007F4; // OUT send 1 Arp message to CEP - static const uint32 TPARPMODE = 0x000007F5; // OUT set Arp mode typedef struct TpTriggerInfo // trigger information { @@ -1519,6 +1533,194 @@ event = { }; }; +event = { + noheader; + signal = TESTMODE; + dir = OUT; + param = { + name = "opcode"; + type = "uint32"; + }; + param = { + name = "status"; + type = "uint32"; + }; + param = { + name = "mp"; + type = "uint32"; + }; + param = { + name = "RSP_tst"; + type = "uint32"; + }; + param = { + name = "RSP_samp"; + type = "uint32"; + }; + param = { + name = "clockdelay"; + type = "uint32"; + }; + param = { + name = "mem_in_tst"; + type = "uint32"; + }; + param = { + name = "mem_out_tst"; + type = "uint32"; + }; +}; + +event = { + noheader; + signal = TESTMODE_ACK; + dir = IN; + param = { + name = "opcode"; + type = "uint32"; + }; + param = { + name = "status"; + type = "uint32"; + }; +}; + +event = { + noheader; + signal = UDP_EN_PRG; + dir = OUT; + param = { + name = "opcode"; + type = "uint32"; + }; + param = { + name = "status"; + type = "uint32"; + }; +}; + +event = { + noheader; + signal = UDP_EN_PRG_ACK; + dir = IN; + param = { + name = "opcode"; + type = "uint32"; + }; + param = { + name = "status"; + type = "uint32"; + }; +}; + +event = { + noheader; + signal = UDP_DIS_PRG; + dir = OUT; + param = { + name = "opcode"; + type = "uint32"; + }; + param = { + name = "status"; + type = "uint32"; + }; +}; + +event = { + noheader; + signal = UDP_DIS_PRG_ACK; + dir = IN; + param = { + name = "opcode"; + type = "uint32"; + }; + param = { + name = "status"; + type = "uint32"; + }; +}; + +event = { + noheader; + signal = UDP_CLR_ERR; + dir = OUT; + param = { + name = "opcode"; + type = "uint32"; + }; + param = { + name = "status"; + type = "uint32"; + }; +}; + +event = { + noheader; + signal = UDP_CLR_ERR_ACK; + dir = IN; + param = { + name = "opcode"; + type = "uint32"; + }; + param = { + name = "status"; + type = "uint32"; + }; +}; + +event = { + noheader; + signal = UDP_GET_ERR; + dir = OUT; + param = { + name = "opcode"; + type = "uint32"; + }; + param = { + name = "status"; + type = "uint32"; + }; +}; + +event = { + noheader; + signal = UDP_GET_ERR_ACK; + dir = IN; + param = { + name = "opcode"; + type = "uint32"; + }; + param = { + name = "status"; + type = "uint32"; + }; + param = { + name = "prg_errors"; + type = "uint32"; + }; + param = { + name = "header_id"; + type = "uint32"; + }; + param = { + name = "seq_nr"; + type = "uint32"; + }; + param = { + name = "Time"; + type = "uint32"; + }; + param = { + name = "samplenr"; + type = "uint32"; + }; + param = { + name = "length"; + type = "uint32"; + }; +}; + event = { noheader; signal = ARP; diff --git a/MAC/APL/PIC/TBBDriver/src/TempLimitCmd.cc b/MAC/APL/PIC/TBBDriver/src/TempLimitCmd.cc index 96b1d72db1c310708305e0bf88a91c70d76ebdb4..f34505c3d77a552ce8e5e1265863355ba96dd686 100644 --- a/MAC/APL/PIC/TBBDriver/src/TempLimitCmd.cc +++ b/MAC/APL/PIC/TBBDriver/src/TempLimitCmd.cc @@ -82,7 +82,7 @@ void TempLimitCmd::saveTbbEvent(GCFEvent& event) void TempLimitCmd::sendTpEvent() { TPTempLimitEvent tp_event; - tp_event.opcode = TPTEMPLIMIT; + tp_event.opcode = oc_TEMP_LIMIT; tp_event.status = 0; tp_event.high = itsHigh; tp_event.low = itsLow; diff --git a/MAC/APL/PIC/TBBDriver/src/TrigCoefCmd.cc b/MAC/APL/PIC/TBBDriver/src/TrigCoefCmd.cc index 343b73a709efbf9cacb894d7a497019be44bbfd3..ea4c7a950d6d5643c8fb3ae523f548be8eb4b34d 100644 --- a/MAC/APL/PIC/TBBDriver/src/TrigCoefCmd.cc +++ b/MAC/APL/PIC/TBBDriver/src/TrigCoefCmd.cc @@ -95,7 +95,7 @@ void TrigCoefCmd::sendTpEvent() { TPTrigCoefEvent tp_event; - tp_event.opcode = TPTRIGCOEF; + tp_event.opcode = oc_TRIG_COEF; tp_event.status = 0; // send cmd if no errors diff --git a/MAC/APL/PIC/TBBDriver/src/TrigGenCmd.cc b/MAC/APL/PIC/TBBDriver/src/TrigGenCmd.cc index dc3e0f3295c6228a56b2263c9a28482352edc2cd..dd7cfc77e401af0171dd60dc89cbc76c40bb2dc2 100644 --- a/MAC/APL/PIC/TBBDriver/src/TrigGenCmd.cc +++ b/MAC/APL/PIC/TBBDriver/src/TrigGenCmd.cc @@ -109,7 +109,7 @@ void TrigGenCmd::sendTpEvent() // set all channels to zero TPTrigReleaseEvent tp_event; - tp_event.opcode = TPTRIGRELEASE; + tp_event.opcode = oc_TRIG_RELEASE; tp_event.status = 0; tp_event.mp = 0xFFFFFFFF; tp_event.channel_mask = 0; @@ -120,7 +120,7 @@ void TrigGenCmd::sendTpEvent() case 1: { TPTrigGenerateEvent tp_event; - tp_event.opcode = TPTRIGGENERATE; + tp_event.opcode = oc_TRIG_GENERATE; tp_event.status = 0; if (itsChannelMask[getBoardNr()] == 0xFFFF) { diff --git a/MAC/APL/PIC/TBBDriver/src/TrigInfoCmd.cc b/MAC/APL/PIC/TBBDriver/src/TrigInfoCmd.cc index 4311d2981bd39646c8bf64f4199848a1f38139e3..af44bf0b38bdc923317cc2187230b221ea524bb6 100644 --- a/MAC/APL/PIC/TBBDriver/src/TrigInfoCmd.cc +++ b/MAC/APL/PIC/TBBDriver/src/TrigInfoCmd.cc @@ -83,7 +83,7 @@ void TrigInfoCmd::sendTpEvent() if (itsStatus == 0) { TPTrigInfoEvent tp_event; - tp_event.opcode = TPTRIGINFO; + tp_event.opcode = oc_TRIG_INFO; tp_event.status = 0; tp_event.channel = static_cast<uint32>(TS->getChInputNr(getChannelNr())); diff --git a/MAC/APL/PIC/TBBDriver/src/TrigReleaseCmd.cc b/MAC/APL/PIC/TBBDriver/src/TrigReleaseCmd.cc index 26b65121590d1130496619e26d498e51cbd6a40e..8fa6f0c8eb95ae401ad6916df86425878295ca62 100644 --- a/MAC/APL/PIC/TBBDriver/src/TrigReleaseCmd.cc +++ b/MAC/APL/PIC/TBBDriver/src/TrigReleaseCmd.cc @@ -109,7 +109,7 @@ void TrigReleaseCmd::sendTpEvent() // send cmd if no errors if (itsStatus[getBoardNr()] == 0) { TPTrigReleaseEvent tp_event; - tp_event.opcode = TPTRIGRELEASE; + tp_event.opcode = oc_TRIG_RELEASE; tp_event.status = 0; switch (itsStage) { diff --git a/MAC/APL/PIC/TBBDriver/src/TrigSetupCmd.cc b/MAC/APL/PIC/TBBDriver/src/TrigSetupCmd.cc index a7aec270ee33f63f4d598183e516db0b6a8032ed..2ca3cff90b6d5d68a31e0eea191f27a7d9c4ad38 100644 --- a/MAC/APL/PIC/TBBDriver/src/TrigSetupCmd.cc +++ b/MAC/APL/PIC/TBBDriver/src/TrigSetupCmd.cc @@ -103,7 +103,7 @@ void TrigSetupCmd::sendTpEvent() // send cmd if no errors if (itsStatus[getBoardNr()] == 0) { TPTrigSetupEvent tp_event; - tp_event.opcode = TPTRIGSETUP; + tp_event.opcode = oc_TRIG_SETUP; tp_event.status = 0; tp_event.mp = TS->getChMpNr(getChannelNr()); diff --git a/MAC/APL/PIC/TBBDriver/src/UdpCmd.cc b/MAC/APL/PIC/TBBDriver/src/UdpCmd.cc index f6acc2519588885c69fcd48424cdda9c9bcf6076..20e2f7867265beff8d67c8a52e9ffa59dbc30f45 100644 --- a/MAC/APL/PIC/TBBDriver/src/UdpCmd.cc +++ b/MAC/APL/PIC/TBBDriver/src/UdpCmd.cc @@ -208,7 +208,7 @@ void UdpCmd::saveTbbEvent(GCFEvent& event) void UdpCmd::sendTpEvent() { TPUdpEvent tp_event; - tp_event.opcode = TPUDP; + tp_event.opcode = oc_UDP; tp_event.status = 0; // fill in destination mac address diff --git a/MAC/APL/PIC/TBBDriver/src/VersionCmd.cc b/MAC/APL/PIC/TBBDriver/src/VersionCmd.cc index 17ef4b12c84a34fd7df4e3beddb47d4c36c15d9f..4dd92c5498dcefb45c56311a5ce469805cbd842d 100644 --- a/MAC/APL/PIC/TBBDriver/src/VersionCmd.cc +++ b/MAC/APL/PIC/TBBDriver/src/VersionCmd.cc @@ -87,7 +87,7 @@ void VersionCmd::saveTbbEvent(GCFEvent& event) void VersionCmd::sendTpEvent() { TPVersionEvent tp_event; - tp_event.opcode = TPVERSION; + tp_event.opcode = oc_VERSION; tp_event.status = 0; TS->boardPort(getBoardNr()).send(tp_event); diff --git a/MAC/APL/PIC/TBBDriver/src/WatchDogCmd.cc b/MAC/APL/PIC/TBBDriver/src/WatchDogCmd.cc index 1bff7b0630b25617a7d61c5d3072a1fdbd88fc2d..f4425287f274c02ac467cf0a59c2be84391b6cf6 100644 --- a/MAC/APL/PIC/TBBDriver/src/WatchDogCmd.cc +++ b/MAC/APL/PIC/TBBDriver/src/WatchDogCmd.cc @@ -82,7 +82,7 @@ void WatchDogCmd::saveTbbEvent(GCFEvent& event) void WatchDogCmd::sendTpEvent() { TPWatchdogEvent tp_event; - tp_event.opcode = TPWATCHDOG; + tp_event.opcode = oc_WATCHDOG; tp_event.status = 0; tp_event.mode = itsMode; diff --git a/MAC/APL/PIC/TBBDriver/src/WritefCmd.cc b/MAC/APL/PIC/TBBDriver/src/WritefCmd.cc index 640800558b93cae4271d471afa41a2645d4c9713..7a2d345903024b184738fc7a1d38d397854f8da4 100644 --- a/MAC/APL/PIC/TBBDriver/src/WritefCmd.cc +++ b/MAC/APL/PIC/TBBDriver/src/WritefCmd.cc @@ -166,7 +166,7 @@ void WritefCmd::sendTpEvent() case unprotect: { TPUnprotectEvent tp_event; - tp_event.opcode = TPUNPROTECT; + tp_event.opcode = oc_UNPROTECT; tp_event.status = 0; tp_event.password = itsPassword; TS->boardPort(getBoardNr()).send(tp_event); @@ -176,13 +176,13 @@ void WritefCmd::sendTpEvent() case erase_flash: { if ((itsImage == 0) && (itsPassword != 0xfac)) { TPErasefSpecEvent tp_event; - tp_event.opcode = TPERASEFSPEC; + tp_event.opcode = oc_ERASEF_SPEC; tp_event.status = 0; tp_event.addr = static_cast<uint32>(itsSector * FL_SECTOR_SIZE); TS->boardPort(getBoardNr()).send(tp_event); } else { TPErasefEvent tp_event; - tp_event.opcode = TPERASEF; + tp_event.opcode = oc_ERASEF; tp_event.status = 0; tp_event.addr = static_cast<uint32>(itsSector * FL_SECTOR_SIZE); TS->boardPort(getBoardNr()).send(tp_event); @@ -195,7 +195,7 @@ void WritefCmd::sendTpEvent() // fill event with data and send if ((itsImage == 0) && (itsPassword != 0xfac)) { TPWritefSpecEvent tp_event; - tp_event.opcode = TPWRITEFSPEC; + tp_event.opcode = oc_WRITEF_SPEC; tp_event.status = 0; tp_event.addr = static_cast<uint32>(itsBlock * FL_BLOCK_SIZE); @@ -209,7 +209,7 @@ void WritefCmd::sendTpEvent() TS->boardPort(getBoardNr()).send(tp_event); } else { TPWritefEvent tp_event; - tp_event.opcode = TPWRITEF; + tp_event.opcode = oc_WRITEF; tp_event.status = 0; tp_event.addr = static_cast<uint32>(itsBlock * FL_BLOCK_SIZE); @@ -229,8 +229,8 @@ void WritefCmd::sendTpEvent() // stage 3, verify flash case verify_flash: { TPReadfEvent tp_event; - tp_event.opcode = TPREADF; - tp_event.status = 0; + tp_event.opcode = oc_READF; + tp_event.status = 0; tp_event.addr = static_cast<uint32>(itsBlock * FL_BLOCK_SIZE); TS->boardPort(getBoardNr()).send(tp_event); TS->boardPort(getBoardNr()).setTimer(5.0); @@ -238,7 +238,7 @@ void WritefCmd::sendTpEvent() case protect: { TPProtectEvent tp_event; - tp_event.opcode = TPPROTECT; + tp_event.opcode = oc_PROTECT; tp_event.status = 0; TS->boardPort(getBoardNr()).send(tp_event); TS->boardPort(getBoardNr()).setTimer(TS->timeout()); diff --git a/MAC/APL/PIC/TBBDriver/src/WriterCmd.cc b/MAC/APL/PIC/TBBDriver/src/WriterCmd.cc index 78b0de6193638120008f9e41b23448af27a8878f..0b9093dc77c724ff11fcbfa442dbbc7f15c18607 100644 --- a/MAC/APL/PIC/TBBDriver/src/WriterCmd.cc +++ b/MAC/APL/PIC/TBBDriver/src/WriterCmd.cc @@ -78,7 +78,7 @@ void WriterCmd::saveTbbEvent(GCFEvent& event) void WriterCmd::sendTpEvent() { TPWriterEvent tp_event; - tp_event.opcode = TPWRITER; + tp_event.opcode = oc_WRITER; tp_event.status = 0; tp_event.mp = itsMp; tp_event.pid = itsPid; diff --git a/MAC/APL/PIC/TBBDriver/src/WritewCmd.cc b/MAC/APL/PIC/TBBDriver/src/WritewCmd.cc index 8cbbd31d33647a4f5759e3db5b6981d21d162549..8936366a512fd5c3a2b05f09a544f50c402899a8 100644 --- a/MAC/APL/PIC/TBBDriver/src/WritewCmd.cc +++ b/MAC/APL/PIC/TBBDriver/src/WritewCmd.cc @@ -80,7 +80,7 @@ void WritewCmd::saveTbbEvent(GCFEvent& event) void WritewCmd::sendTpEvent() { TPWritewEvent tp_event; - tp_event.opcode = TPWRITEW; + tp_event.opcode = oc_WRITEW; tp_event.status = 0; tp_event.mp = itsMp; tp_event.addr = itsAddr; diff --git a/MAC/APL/PIC/TBBDriver/src/XXXCmd.cc b/MAC/APL/PIC/TBBDriver/src/XXXCmd.cc index c9d51073507e2884d53f7d438053a3e2e71dc4b8..c309944d7d0e634e0132413ab46feb3c3f953f23 100644 --- a/MAC/APL/PIC/TBBDriver/src/XXXCmd.cc +++ b/MAC/APL/PIC/TBBDriver/src/XXXCmd.cc @@ -83,7 +83,7 @@ void XxxCmd::saveTbbEvent(GCFEvent& event) void XxxCmd::sendTpEvent() { TPXxxEvent tp_event; - tp_event.opcode = TPXXX; + tp_event.opcode = oc_XXX; tp_event.status = 0; TS->boardPort(getBoardNr()).send(tp_event); diff --git a/MAC/APL/PIC/TBBDriver/src/tbbctl.cc b/MAC/APL/PIC/TBBDriver/src/tbbctl.cc index 8a22a11a0dc3b4bac62f2a12b5d9b9bf7a1e97cf..41e924a7e325e4b42601db2233d14be0c14814e8 100644 --- a/MAC/APL/PIC/TBBDriver/src/tbbctl.cc +++ b/MAC/APL/PIC/TBBDriver/src/tbbctl.cc @@ -624,7 +624,6 @@ ListenCmd::ListenCmd(GCFPortInterface& port) : Command(port), cout << endl; cout << "== TBB ============================ listen for triggers on selected rcu's ====" << endl; cout << endl; - } //----------------------------------------------------------------------------- @@ -805,7 +804,7 @@ void ReadAllCmd::send() event.mp = rcu2mp(itsRcu); event.pid = rcu2writer(itsRcu); event.regid = 4; // Last stored time instance - cout << "readr board=" << event.board << " mp=" << event.mp << " writer=" << event.pid << endl; + //cout << "readr board=" << event.board << " mp=" << event.mp << " writer=" << event.pid << endl; itsPort.send(event); itsPort.setTimer(DELAY); } break; @@ -820,7 +819,7 @@ void ReadAllCmd::send() } else { event.prepages = itsPages - 1; } - cout << "sending " << itsPages << " pages to cep" << endl; + cout << " wait while sending " << itsPages << " pages to cep" << endl; event.postpages = 0; itsPort.send(event); itsPort.setTimer(600.0); @@ -860,7 +859,7 @@ GCFEvent::TResult ReadAllCmd::ack(GCFEvent& e) TBBReadrAckEvent ack(e); itsSecondsTime = ack.data[0]; itsSampleTime = ack.data[1]; - cout << formatString("time of last frame from rcu-%d, %d seconds, sample number %d", + cout << formatString("rcu %-3d, last recorded time 0x%08x seconds and sample number 0x%08x", itsRcu, itsSecondsTime, itsSampleTime) << endl; itsStage = 2; } break; @@ -939,18 +938,19 @@ VersionCmd::VersionCmd(GCFPortInterface& port) : Command(port) //----------------------------------------------------------------------------- void VersionCmd::send() { - TBBVersionEvent event; - event.boardmask = getBoardMask(); - itsPort.send(event); - itsPort.setTimer(DELAY); + TBBVersionEvent event; + event.boardmask = getBoardMask(); + itsPort.send(event); + itsPort.setTimer(DELAY); } //----------------------------------------------------------------------------- GCFEvent::TResult VersionCmd::ack(GCFEvent& e) { - TBBVersionAckEvent ack(e); + TBBVersionAckEvent ack(e); - cout << formatString("TBBDriver software version %3.2f",(ack.driverversion / 100.)) << endl; + cout << formatString("TBBDriver version %3.2f",(ack.driverversion / 100.)) << endl; + cout << formatString("tbbctl version %3.2f",(TBBCTL_VERSION / 100.)) << endl; cout << endl; cout << "TBB ID Board TP sw TP hw MP hw" << endl; cout << "--- -- ----- ----- ----- -----" << endl; @@ -1608,7 +1608,7 @@ GCFEvent::TResult ReadwCmd::ack(GCFEvent& e) } //if (itsAddr == (itsStopAddr - 1)) - itsAddr++; + itsAddr += 4; if (itsAddr >= itsStopAddr) { setCmdDone(true); } else { @@ -2030,8 +2030,6 @@ void ReadPageCmd::send() itsPort.send(send); itsPort.setTimer(DELAY); - cout << formatString("MP=%d Addr=%X", itsMp, mp_page_addr) << endl; - LOG_DEBUG_STR(formatString("Writer[%x][%x][%x][%x]", send.mp,send.pid,send.regid,send.data[0])); } break; @@ -2461,31 +2459,35 @@ void TBBCtl::commandHelp(int level) cout << " # Example: --select=0,1,4 or --select=0:6 or --select=0,1,2,8:11" << endl; cout << endl; cout << "______| CHANNEL |_________________________________________________________________________________________________________" << endl; - cout << " tbbctl --rcuinfo [--select=<set>] # list rcu info, only allocated rcu's are listed" << endl; cout << " tbbctl --alloc [--select=<set>] # allocate memmory locations for selected rcu's" << endl; cout << " tbbctl --free [--select=<set>] # free memmory locations for selected rcu's" << endl; cout << " tbbctl --record [--select=<set>] # start recording on selected rcu's" << endl; cout << " tbbctl --stop [--select=<set>] # stop recording on selected rcu's" << endl; - cout << " tbbctl --mode=[transient | subbands] # set mode to configure UDP/IP header for CEP tranport" << endl; - cout << " # before using: --read, --arp or --arpmode," << endl; + cout << endl; + cout << "______| CEP |_____________________________________________________________________________________________________________" << endl; + cout << " tbbctl --mode=[transient | subbands] # set mode to configure UDP/IP header for CEP tranport" << endl; + cout << " # before using: --read, readall, --arp or --arpmode," << endl; cout << " # first use --mode to setup UDP/IP header" << endl; cout << " tbbctl --read=rcunr,secondstime,sampletime,prepages,postpages # transfer recorded data from rcunr to CEP, " << endl; cout << " tbbctl --readall=pages [--select=<set>] # transfer number of pages from all selected rcunr to CEP, " << endl; - cout << " tbbctl --stopcep [--select=<set>] # stop sending CEP messages" << endl; - cout << " tbbctl --cepdelay=delay [--select=<set>] # set delay between CEP frames, 1 unit = 5 uS" << endl; + cout << " tbbctl --stopcep [--select=<set>] # stop sending data to CEP" << endl; + cout << " tbbctl --cepdelay=delay [--select=<set>] # set delay between CEP frames, 1 delay unit = 5 uS" << endl; cout << " tbbctl --arp [--select=<set>] # send 1 arp message" << endl; - cout << " tbbctl --arpmode=mode [--select=<set>] # set arp mode, 0=manual, 1=auto" << endl; + cout << " tbbctl --arpmode=mode [--select=<set>] # set arp mode, 0=manual, 1=auto(every 42 seconds 1 message)" << endl; cout << endl; cout << "______| TRIGGER |_________________________________________________________________________________________________________" << endl; cout << " tbbctl --settings [--select=<set>] # list trigger settings for selected rcu's" << endl; cout << " tbbctl --release [--select=<set>] # release trigger system for selected rcu's" << endl; cout << " tbbctl --generate [--select=<set>] # generate a trigger for selected rcu's" << endl; cout << " tbbctl --setup=level,start,stop,filter,window,mode [--select=<set>]# setup trigger system for selected rcu's, mode = 0/1" << endl; - cout << " tbbctl --coef=c0,c1,c2,c3 [--select=<set>] # set trigger coeffients for elected rcu's" << endl; + cout << " tbbctl --coef=c0,c1,c2,c3 [--select=<set>] # set trigger coeffients for selected rcu's" << endl; cout << " tbbctl --triginfo=rcu # get trigger info for selected rcu" << endl; - cout << " tbbctl --listen=[one_shot | continues] # put in listen mode, all triggers will be listed" << endl; + cout << " tbbctl --listen=[one_shot | continues] # listen for triggers, in continues mode the system" << endl; + cout << " # is released after a trigger, in one_shot mode" << endl; + cout << " # the recording is stopped after a trigger" << endl; cout << endl; cout << "______| INFO |____________________________________________________________________________________________________________" << endl; + cout << " tbbctl --rcuinfo [--select=<set>] # list rcu info, only allocated rcu's are listed" << endl; cout << " tbbctl --version [--select=<set>] # get version information from selected boards" << endl; cout << " tbbctl --status [--select=<set>] # get status information from selected boards" << endl; cout << " tbbctl --size [--select=<set>] # get installed memory size from selected boards" << endl; @@ -2494,8 +2496,8 @@ void TBBCtl::commandHelp(int level) cout << " tbbctl --readpage=rcunr,startpage,npages # ddr read npages from rcunr, starting on startpage" << endl; if (level == 3) { cout << " tbbctl --testddr=board # ddr memory test, adress and data lines" << endl; - cout << " tbbctl --readddr=board,mp,addr,size # ddr read, (size x 2) words starting on addr" << endl; - cout << " tbbctl --writeddr=board,mp,addr,wordL,wordH # ddr write, 2 words to starting on addr" << endl; + cout << " tbbctl --readddr=board,mp,addr,size # read 'size' blocks of 8 words from ddr starting on addr" << endl; + cout << " tbbctl --writeddr=board,mp,addr,word[0],word[1] .. word[7] # write 8 words to ddr starting on addr" << endl; cout << endl; cout << "______| MP-REGISTER |_____________________________________________________________________________________________________" << endl; cout << " tbbctl --readreg=board,mp,pid,regid # register read" << endl; @@ -2513,10 +2515,12 @@ void TBBCtl::commandHelp(int level) cout << "______| FLASH |___________________________________________________________________________________________________________" << endl; } cout << " tbbctl --imageinfo=board # read info from all images on board" << endl; - cout << " tbbctl --config=imagenr [--select=<set>] # reconfigure TP and MP's with imagenr [0..31] on " << endl; + cout << " tbbctl --config=imagenr [--select=<set>] # reconfigure TP and MP's with imagenr [0..15] on " << endl; cout << " # selected boards" << endl; cout << "__________________________________________________________________________________________________________________________" << endl; - cout << " tbbctl --templimits=high,low [--select=<set>] # set temp limts for fan control" << endl; + if (level == 3) { + cout << " tbbctl --templimits=high,low [--select=<set>] # set temp limts for fan control" << endl; + } cout << " tbbctl --clear [--select=<set>] # clear selected board" << endl; cout << " tbbctl --reset [--select=<set>] # reset to factory images on selected boards" << endl; cout << endl; @@ -2534,7 +2538,7 @@ TBBCtl::TBBCtl(string name, int argc, char** argv): GCFTask((State)&TBBCtl::init for(int boardnr = 0; boardnr < itsMaxBoards; boardnr++) { itsMemory[boardnr] = 0; } - registerProtocol (TBB_PROTOCOL, TBB_PROTOCOL_STRINGS); + registerProtocol (TBB_PROTOCOL, TBB_PROTOCOL_STRINGS); itsServerPort.init(*this, MAC_SVCMASK_TBBDRIVER, GCFPortInterface::SAP, TBB_PROTOCOL); itsCmdTimer = new GCFTimerPort(*this, "AliveTimer"); } @@ -2542,93 +2546,87 @@ TBBCtl::TBBCtl(string name, int argc, char** argv): GCFTask((State)&TBBCtl::init //----------------------------------------------------------------------------- TBBCtl::~TBBCtl() { - if (itsCommand) { delete itsCommand; } - if (itsCmdTimer) { delete itsCmdTimer; } + if (itsCommand) { delete itsCommand; } + if (itsCmdTimer) { delete itsCmdTimer; } } //----------------------------------------------------------------------------- GCFEvent::TResult TBBCtl::initial(GCFEvent& e, GCFPortInterface& port) { - GCFEvent::TResult status = GCFEvent::HANDLED; + GCFEvent::TResult status = GCFEvent::HANDLED; - switch (e.signal) { - case F_INIT: { - } break; + switch (e.signal) { + case F_INIT: { + } break; - case F_ENTRY: { - if (!itsServerPort.isConnected()) { - itsServerPort.open(); - itsServerPort.setTimer(5.0); - } - } break; + case F_ENTRY: { + if (!itsServerPort.isConnected()) { + itsServerPort.open(); + itsServerPort.setTimer(5.0); + } + } break; - case F_CONNECTED: { - if (itsServerPort.isConnected()) { - itsServerPort.cancelAllTimers(); - TBBGetConfigEvent getconfig; - itsServerPort.send(getconfig); - } - } break; + case F_CONNECTED: { + if (itsServerPort.isConnected()) { + itsServerPort.cancelAllTimers(); + TBBGetConfigEvent getconfig; + itsServerPort.send(getconfig); + } + } break; case TBB_DRIVER_BUSY_ACK: { - cout << endl << "=x=x= DRIVER BUSY, with setting up boards, try again =x=x=" << endl << flush; - GCFScheduler::instance()->stop(); - } - - case TBB_GET_CONFIG_ACK: { - TBBGetConfigAckEvent ack(e); - itsMaxBoards = ack.max_boards; - itsActiveBoards = ack.active_boards_mask; - itsMaxChannels = itsMaxBoards * 16; - cout << "active boards=" << itsActiveBoards << endl; - - if (itsActiveBoards == 0) { - if (itsMaxBoards == 0) { - cout << "=x=x= Driver in init state =x=x=" << endl; - } else { - cout << "=x=x= NO boards available =x=x=" << endl; - } + cout << endl << "=x=x= DRIVER BUSY, with setting up boards, try again =x=x=" << endl << flush; GCFScheduler::instance()->stop(); } - // send subscribe - TBBSubscribeEvent subscribe; - subscribe.triggers = false; - subscribe.hardware = true; - itsServerPort.send(subscribe); - } break; + case TBB_GET_CONFIG_ACK: { + TBBGetConfigAckEvent ack(e); + itsMaxBoards = ack.max_boards; + itsActiveBoards = ack.active_boards_mask; + itsMaxChannels = itsMaxBoards * 16; - case TBB_SUBSCRIBE_ACK: { - TRAN(TBBCtl::docommand); + if (itsActiveBoards == 0) { + cout << "=x=x= NO boards available at this moment =x=x=" << endl; + GCFScheduler::instance()->stop(); + } + + // send subscribe + TBBSubscribeEvent subscribe; + subscribe.triggers = false; + subscribe.hardware = true; + itsServerPort.send(subscribe); } break; - case F_DISCONNECTED: { - //port.setTimer(DELAY); - port.close(); - } break; - - case F_TIMER: { - // try again - cout << " =x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=" << endl; - cout << " =x= TBBDriver is NOT responding =x=" << endl; - cout << " =x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=" << endl; - //itsServerPort.open(); - exit(EXIT_FAILURE); - } break; + case TBB_SUBSCRIBE_ACK: { + TRAN(TBBCtl::docommand); + } break; - default: { - status = GCFEvent::NOT_HANDLED; - } break; - } + case F_DISCONNECTED: { + //port.setTimer(DELAY); + port.close(); + } break; - return(status); + case F_TIMER: { + // try again + cout << " =x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=" << endl; + cout << " =x= TBBDriver is NOT responding =x=" << endl; + cout << " =x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=" << endl; + //itsServerPort.open(); + exit(EXIT_FAILURE); + } break; + + default: { + status = GCFEvent::NOT_HANDLED; + } break; + } + return(status); } //----------------------------------------------------------------------------- GCFEvent::TResult TBBCtl::docommand(GCFEvent& e, GCFPortInterface& port) { - //cout << "docommand signal:" << eventName(e) << endl; - GCFEvent::TResult status = GCFEvent::HANDLED; + //cout << "docommand signal:" << eventName(e) << endl; + GCFEvent::TResult status = GCFEvent::HANDLED; switch (e.signal) { case F_INIT: { diff --git a/MAC/APL/PIC/TBBDriver/src/tbbctl.h b/MAC/APL/PIC/TBBDriver/src/tbbctl.h index 4258b138a067ffbf4ddf4525cd857218272ab986..e91a41c59815e8f65e41816b012f7e79d920e39d 100644 --- a/MAC/APL/PIC/TBBDriver/src/tbbctl.h +++ b/MAC/APL/PIC/TBBDriver/src/tbbctl.h @@ -42,6 +42,8 @@ namespace LOFAR { using GCF::TM::GCFPortInterface; namespace TbbCtl { +static const int TBBCTL_VERSION = 210; + // MAX_N_TBBOARDS and MAX_N_RCUS come from TBB_protocol.ph static const int BOARDCMD = 1;