@@ -499,15 +499,16 @@ StWord Crorc::ddlReadCTSTW(int transid, int destination, long long int time)
499499 return stw;
500500}
501501
502- StWord Crorc::ddlReadSiu (int transid, long long int time)
502+ // TODO: Transid could be set automatically here
503+ StWord Crorc::ddlReadSiu (int transid, long long int time) // TODO: This to be kept like this -> clean wherever possible
503504{
504505 // prepare and send DDL command
505506 int destination = Ddl::Destination::SIU;
506- ddlSendCommand (destination, Rorc::RandCIFST, transid, 0 , time);
507+ ddlSendCommand (destination, Rorc::RandCIFST, transid, 0 , time); // TODO: A bar write
507508
508509 // read and check the answer
509- ddlWaitStatus (time);
510- StWord stw = ddlReadStatus ();
510+ ddlWaitStatus (time); // TODO: Keep reading to check the status
511+ StWord stw = ddlReadStatus (); // TODO: Read once
511512 if (stw.part .code != Rorc::IFSTW || stw.part .trid != transid || stw.part .dest != destination) {
512513 BOOST_THROW_EXCEPTION (
513514 Exception () << ErrorInfo::Message (" Unexpected SIU STW (not IFSTW)" )
@@ -516,7 +517,7 @@ StWord Crorc::ddlReadSiu(int transid, long long int time)
516517 }
517518
518519 StWord ret = stw;
519- stw = ddlReadStatus ();
520+ stw = ddlReadStatus (); // TODO: Read twice
520521 if ((stw.part .code != Rorc::CTSTW && stw.part .code != Rorc::ILCMD && stw.part .code != Rorc::CTSTW_TO) || stw.part .trid != transid || stw.part .dest != destination) {
521522 BOOST_THROW_EXCEPTION (
522523 Exception () << ErrorInfo::Message (" Unexpected SIU STW (not CTSTW)" )
@@ -698,18 +699,6 @@ void Crorc::resetCommand(int option, const DiuConfig& diuConfig)
698699 if (option & Rorc::Reset::DIU) {
699700 command |= Rorc::CcsrCommand::RESET_DIU;
700701 }
701- if (option & Rorc::Reset::FF) {
702- command |= Rorc::CcsrCommand::CLEAR_RXFF | Rorc::CcsrCommand::CLEAR_TXFF;
703- }
704- if (option & Rorc::Reset::FIFOS) {
705- command |= Rorc::CcsrCommand::CLEAR_FIFOS;
706- }
707- if (option & Rorc::Reset::ERROR) {
708- command |= Rorc::CcsrCommand::CLEAR_ERROR;
709- }
710- if (option & Rorc::Reset::COUNTERS) {
711- command |= Rorc::CcsrCommand::CLEAR_COUNTERS;
712- }
713702 if (command) {
714703 write (Rorc::C_CSR, (uint32_t )command);
715704 }
@@ -724,41 +713,40 @@ void Crorc::resetCommand(int option, const DiuConfig& diuConfig)
724713 }
725714}
726715
727- // / Try to empty D-RORC's data FIFOs
728- // / \param timeoutMicroseconds Time-out value in usecs
729- void Crorc::emptyDataFifos (int timeoutMicroseconds)
716+ void Crorc::armDdl (/* int resetMask, const DiuConfig& diuConfig*/ )
730717{
731- auto endTime = chrono::steady_clock::now () + chrono::microseconds (timeoutMicroseconds) ;
718+ // auto reset = [&](uint32_t command) { resetCommand(command, diuConfig); } ;
732719
733- while (chrono::steady_clock::now () < endTime) {
734- if (!checkRxData ()) {
735- return ;
736- }
737- write (Rorc::C_CSR, (uint32_t )Rorc::CcsrCommand::CLEAR_FIFOS);
738- }
739-
740- if (checkRxData ()) {
741- BOOST_THROW_EXCEPTION (TimeoutException () << ErrorInfo::Message (" Timed out emptying data FIFOs" ));
742- }
743- }
744-
745- void Crorc::armDdl (int resetMask, const DiuConfig& diuConfig)
746- {
747- auto reset = [&](uint32_t command) { resetCommand (command, diuConfig); };
748-
749- if (resetMask & Rorc::Reset::FEE) {
720+ /* if (resetMask & Rorc::Reset::FEE) { //TODO: Remove
750721 BOOST_THROW_EXCEPTION(Exception() << ErrorInfo::Message("Command not allowed"));
751722 }
752- if (resetMask & Rorc::Reset::SIU) {
723+ if (resetMask & Rorc::Reset::SIU) { //TODO: Remove
753724 ddlResetSiu(3, Ddl::RESPONSE_TIME * diuConfig.pciLoopPerUsec);
725+ }*/
726+ /* SHOULD BE ONLY THIS u*/
727+ if (true ) { // TODO: Test only with this
728+ // reset(Rorc::Reset::RORC);
729+ // reset(Rorc::Reset::SIU); //TODO: This doesn't happen now
730+
731+ // write(0x0, 0x1); //CRORC device
732+ write (0x0 , 0x2 ); // CRORC channel
733+ write (0x18 / 4 , 0xf1 ); // SIU
734+ // sleep_for(100ms);
735+ write (0x18 / 4 , 0xf1 ); // SIU
736+ write (0x0 , 0x2 ); // CRORC channel
737+ // write(0x0, 0x1); //CRORC device
738+ sleep_for (100ms); // TODO: Make this into a timeout
739+ // reset(Rorc::Reset::SIU);
740+ // reset(Rorc::Reset::RORC);
741+ assertLinkUp ();
754742 }
755- if (resetMask & Rorc::Reset::LINK_UP) {
743+
744+ /* if (resetMask & Rorc::Reset::LINK_UP) {
756745 reset(Rorc::Reset::RORC);
757746 reset(Rorc::Reset::DIU);
758747 reset(Rorc::Reset::SIU);
759748 sleep_for(100ms);
760749 assertLinkUp();
761- emptyDataFifos (100000 );
762750
763751 reset(Rorc::Reset::SIU);
764752 reset(Rorc::Reset::DIU);
@@ -774,7 +762,7 @@ void Crorc::armDdl(int resetMask, const DiuConfig& diuConfig)
774762 }
775763 if (resetMask & Rorc::Reset::RORC) {
776764 reset(Rorc::Reset::RORC);
777- }
765+ }*/
778766}
779767
780768auto Crorc::initDiuVersion () -> DiuConfig
@@ -908,13 +896,16 @@ void Crorc::setDiuLoopback(const DiuConfig& diuConfig)
908896}
909897
910898void Crorc::startTrigger (const DiuConfig& diuConfig, uint32_t command)
899+ // void Crorc::startTrigger(uint32_t command)
911900{
912901 if ((command != Fee::RDYRX) && (command != Fee::STBRD)) {
913902 BOOST_THROW_EXCEPTION (Exception () << ErrorInfo::Message (" Trigger can only be started with RDYRX or STBRD." ));
914903 }
915904 uint64_t timeout = Ddl::RESPONSE_TIME * diuConfig.pciLoopPerUsec ;
916905 ddlSendCommand (Ddl::Destination::FEE, command, 0 , 0 , timeout);
906+ // ddlSendCommand(Ddl::Destination::FEE, command, 0, 0, 0);
917907 ddlWaitStatus (timeout);
908+ // ddlWaitStatus(0);
918909 ddlReadStatus ();
919910}
920911
@@ -1128,8 +1119,8 @@ uint32_t Crorc::ddlPrintStatus(int destination, int time)
11281119std::tuple<std::string, uint32_t > Crorc::siuStatus ()
11291120{
11301121 DiuConfig diuConfig = initDiuVersion ();
1131- resetCommand (Rorc::Reset::SIU, diuConfig);
1132- sleep_for (100ms);
1122+ // resetCommand(Rorc::Reset::SIU, diuConfig);
1123+ // sleep_for(100ms);
11331124
11341125 long long int time = Ddl::RESPONSE_TIME * diuConfig.pciLoopPerUsec ;
11351126
0 commit comments