@@ -85,10 +85,10 @@ class StringRpcServer: public DimRpc
8585};
8686
8787// / Splits a string
88- static std::vector<std::string> split (const std::string& string, const char * separators)
88+ static std::vector<std::string> split (const std::string& string, std::string separators)
8989{
9090 std::vector<std::string> split;
91- b::split (split, string, b::is_any_of (separators));
91+ b::split (split, string, b::is_any_of (separators. c_str () ));
9292 return split;
9393}
9494
@@ -203,6 +203,7 @@ class ProgramAliceLowlevelFrontendServer: public AliceO2::Common::Program
203203 } catch (const Exception& exception) {
204204 getLogger () << " Failed to get devices: " << exception.what () << endm;
205205 }
206+ // Add dummy card
206207 cardsFound.push_back (
207208 CardDescriptor{CardType::Dummy, ChannelFactory::getDummySerialNumber (), {" dummy" , " dummy" }, {0 , 0 , 0 }});
208209
@@ -375,15 +376,15 @@ class ProgramAliceLowlevelFrontendServer: public AliceO2::Common::Program
375376 // / Publish updated values
376377 void serviceUpdate (Service& service)
377378 {
378- getLogger () << " Updating '" << service.description .dnsName << " ': " << endm;
379+ getLogger () << " Updating '" << service.description .dnsName << " '" << endm;
379380
380381 Visitor::apply (service.description .type ,
381382 [&](const ServiceDescription::Register& type){
382383 auto & bar0 = *(mBars .at (service.description .linkInfo .serial ).at (0 ));
383384 for (size_t i = 0 ; i < type.addresses .size (); ++i) {
384385 auto index = type.addresses [i] / 4 ;
385386 auto value = bar0.readRegister (index);
386- service.registerValues .at (i) = bar0. readRegister (index) ;
387+ service.registerValues .at (i) = value ;
387388 }
388389 },
389390 [&](const ServiceDescription::ScaSequence& type){
@@ -435,34 +436,24 @@ class ProgramAliceLowlevelFrontendServer: public AliceO2::Common::Program
435436 checkAddress (address);
436437
437438 uint32_t value = channel->readRegister (address / 4 );
438-
439439 getLogger () << " READ " << Common::makeRegisterString (address, value) << endm;
440-
441440 return (b::format (" 0x%x" ) % value).str ();
442441 }
443442
444443 // / RPC handler for register writes
445444 static std::string registerWrite (const std::string& parameter, BarSharedPtr channel)
446445 {
447- std::vector<std::string> params = split (parameter, argumentSeparator (). c_str () );
446+ std::vector<std::string> params = split (parameter, argumentSeparator ());
448447
449448 if (params.size () != 2 ) {
450449 BOOST_THROW_EXCEPTION (AlfException () << ErrorInfo::Message (" Write RPC call did not have 2 parameters" ));
451450 }
452451
453- auto address = convertHexString (params[ 0 ] );;
454- auto value = convertHexString (params[ 1 ] );;
452+ auto address = convertHexString (params. at ( 0 ) );;
453+ auto value = convertHexString (params. at ( 1 ) );;
455454 checkAddress (address);
456455
457456 getLogger () << " WRITE " << Common::makeRegisterString (address, value) << endm;
458-
459- if (address == 0x1f4 ) {
460- // This is to the command register, we need to wait until the card indicates it's not busy before sending a
461- // command
462- while (!isSigInt () && (channel->readRegister (0x1f0 / 4 ) & 0x80000000 )) {
463- }
464- }
465-
466457 channel->writeRegister (address / 4 , value);
467458 return " " ;
468459 }
@@ -472,18 +463,27 @@ class ProgramAliceLowlevelFrontendServer: public AliceO2::Common::Program
472463 LinkInfo linkInfo)
473464 {
474465 getLogger () << " PUBLISH_REGISTERS_START: '" << parameter << " '" << endm;
475- auto params = split (parameter, argumentSeparator ().c_str ());
476466
477- size_t args = 2 ;
467+ auto params = split (parameter, argumentSeparator ());
468+ auto dnsName = params.at (0 );
469+ auto interval = params.at (1 );
470+
471+ if (params.size () < 3 ) {
472+ BOOST_THROW_EXCEPTION (AlfException ()
473+ << ErrorInfo::Message (" Not enough parameters given" ));
474+ }
475+
476+ // Convert register string sequence to binary format
477+ size_t skip = 2 ; // First two arguments don't go in the array
478478 std::vector<uintptr_t > registers;
479- for (size_t i = 0 ; (i + args ) < params.size (); ++i) {
480- registers.push_back (b::lexical_cast<uintptr_t >(i + args ));
479+ for (size_t i = 0 ; (i + skip ) < params.size (); ++i) {
480+ registers.push_back (b::lexical_cast<uintptr_t >(i + skip ));
481481 }
482482
483483 auto command = std::make_unique<CommandQueue::Command>();
484484 command->start = true ;
485- command->description .dnsName = ServiceNames (linkInfo.serial , linkInfo.link ).publishRegistersSubdir (params. at ( 0 ) );
486- command->description .interval = std::chrono::milliseconds (int64_t (b::lexical_cast<double >(params. at ( 1 ) ) * 1000.0 ));
485+ command->description .dnsName = ServiceNames (linkInfo.serial , linkInfo.link ).publishRegistersSubdir (dnsName );
486+ command->description .interval = std::chrono::milliseconds (int64_t (b::lexical_cast<double >(interval ) * 1000.0 ));
487487 command->description .type = ServiceDescription::Register{std::move (registers)};
488488 command->description .linkInfo = linkInfo;
489489
@@ -497,31 +497,28 @@ class ProgramAliceLowlevelFrontendServer: public AliceO2::Common::Program
497497 {
498498 getLogger () << " PUBLISH_SCA_SEQUENCE_START: '" << parameter << " '" << endm;
499499
500- auto params = split (parameter, argumentSeparator ().c_str ());
500+ auto params = split (parameter, argumentSeparator ());
501+ auto dnsName = params.at (0 );
502+ auto interval = params.at (1 );
501503
502504 if (params.size () < 3 ) {
503505 BOOST_THROW_EXCEPTION (AlfException ()
504506 << ErrorInfo::Message (" Not enough parameters given" ));
505507 }
506508
507- size_t args = 2 ; // Number of args to skip for the array
508- std::vector<uintptr_t > registers;
509- for (size_t i = args; (i + args) < params.size (); ++i) {
510- registers.push_back (b::lexical_cast<uintptr_t >(i));
511- }
512-
513509 // Convert command-data pair string sequence to binary format
510+ size_t skip = 2 ; // Number of arguments to skip for the array
514511 ServiceDescription::ScaSequence sca;
515- sca.commandDataPairs .resize (params.size () - args );
516- for (size_t i = 0 ; (i + args ) < params.size (); ++i) {
517- sca.commandDataPairs [i] = stringToScaCommandDataPair (params[i + args ]);
512+ sca.commandDataPairs .resize (params.size () - skip );
513+ for (size_t i = 0 ; (i + skip ) < params.size (); ++i) {
514+ sca.commandDataPairs [i] = stringToScaCommandDataPair (params[i + skip ]);
518515 }
519516
520517 auto command = std::make_unique<CommandQueue::Command>();
521518 command->start = true ;
522519 command->description .type = sca;
523- command->description .dnsName = ServiceNames (linkInfo.serial , linkInfo.link ).publishScaSequenceSubdir (params. at ( 0 ) );
524- command->description .interval = std::chrono::milliseconds (int64_t (b::lexical_cast<double >(params. at ( 1 ) ) * 1000.0 ));
520+ command->description .dnsName = ServiceNames (linkInfo.serial , linkInfo.link ).publishScaSequenceSubdir (dnsName );
521+ command->description .interval = std::chrono::milliseconds (int64_t (b::lexical_cast<double >(interval ) * 1000.0 ));
525522 command->description .linkInfo = linkInfo;
526523
527524 tryAddToQueue (*queue, std::move (command));
@@ -574,7 +571,7 @@ class ProgramAliceLowlevelFrontendServer: public AliceO2::Common::Program
574571 static std::string scaWrite (const std::string& parameter, BarSharedPtr bar2, LinkInfo linkInfo)
575572 {
576573 getLogger () << " SCA_WRITE: '" << parameter << " '" << endm;
577- auto params = split (parameter, argumentSeparator (). c_str ());
574+ auto params = split (parameter, scaPairSeparator ());
578575 auto command = convertHexString (params.at (0 ));
579576 auto data = convertHexString (params.at (1 ));
580577 Sca (*bar2, bar2->getCardType (), linkInfo.link ).write (command, data);
@@ -601,23 +598,19 @@ class ProgramAliceLowlevelFrontendServer: public AliceO2::Common::Program
601598 // / RPC handler for SCA blob write commands (sequence of commands)
602599 static std::string scaBlobWrite (const std::string& parameter, BarSharedPtr bar2, LinkInfo linkInfo)
603600 {
604- getLogger () << " SCA_BLOB_WRITE size=" << parameter.size () << " bytes" << endm;
601+ getLogger () << " SCA_SEQUENCE size=" << parameter.size () << " bytes" << endm;
605602
606603 // We first split on \n to get the pairs of SCA command and SCA data
607- // Since this can be an enormous list of pairs, we walk through it using the tokenizer
608- using tokenizer = boost::tokenizer<boost::char_separator<char >>;
609- // Drop '\n' delimiters, keep none
610- boost::char_separator<char > sep (argumentSeparator ().c_str (), " " , boost::drop_empty_tokens);
604+ auto lines = split (parameter, argumentSeparator ());
611605 std::stringstream resultBuffer;
612606 auto sca = Sca (*bar2, bar2->getCardType (), linkInfo.link );
613607
614- for (const std::string& token : tokenizer (parameter, sep) ) {
608+ for (const auto & line : lines ) {
615609 // Walk through the tokens, these should be the pairs (or comments).
616- if (token.find (' #' ) == 0 ) {
617- // We have a comment, skip this token
610+ if (isLineComment (line)) {
618611 continue ;
619612 } else {
620- auto commandData = stringToScaCommandDataPair (token );
613+ auto commandData = stringToScaCommandDataPair (line );
621614 try {
622615 sca.write (commandData);
623616 auto result = sca.read ();
@@ -627,6 +620,9 @@ class ProgramAliceLowlevelFrontendServer: public AliceO2::Common::Program
627620 } catch (const ScaException &e) {
628621 // If an SCA error occurs, we stop executing the sequence of commands and return the results as far as we got
629622 // them, plus the error message.
623+ getLogger () << InfoLogger::InfoLogger::Error
624+ << (b::format (" SCA_SEQUENCE cmd=0x%x data=0x%x serial=%d link=%d error='%s'" ) % commandData.command
625+ % commandData.data % linkInfo.serial % linkInfo.link % e.what ()).str () << endm;
630626 resultBuffer << e.what ();
631627 break ;
632628 }
@@ -636,6 +632,11 @@ class ProgramAliceLowlevelFrontendServer: public AliceO2::Common::Program
636632 return resultBuffer.str ();
637633 }
638634
635+ static bool isLineComment (const std::string& line)
636+ {
637+ return line.find (' #' ) == 0 ;
638+ }
639+
639640 static Sca::CommandData stringToScaCommandDataPair (const std::string& string)
640641 {
641642 // The pairs are comma-separated, so we split them.
0 commit comments