Read next pending reply packet from appropriate page of FPGA-to-host device file, and validate contents.
550{
552 SteadyClock_t::time_point lStartTime = SteadyClock_t::now();
553
555 uint32_t lHwPublishedPageCount = 0x0;
556
557 std::vector<uint32_t> lValues;
558 while (true) {
560
562 lHwPublishedPageCount = lValues.at(3);
563
564
565
567 "Read status info from addr 0 (",
568 uhal::Integer(lValues.at(0)),
569 ", ",
570 uhal::Integer(lValues.at(1)),
571 ", ",
572 uhal::Integer(lValues.at(2)),
573 ", ",
574 uhal::Integer(lValues.at(3)),
575 "): ",
576 PacketFmt((const uint8_t*)lValues.data(), 4 * lValues.size()));
577
580 break;
581 }
582
583
584 if (SteadyClock_t::now() - lStartTime > std::chrono::microseconds(getBoostTimeoutPeriod().total_microseconds())) {
585 exception::FlxTimeout lExc;
587 "Next page (index ",
588 uhal::Integer(lPageIndexToRead),
589 " count ",
592 throw lExc;
593 }
594
596 "flx client ",
597 uhal::Quote(id()),
598 " (URI: ",
600 ") : Trying to read page index ",
601 uhal::Integer(lPageIndexToRead),
602 " = count ",
604 "; published page count is ",
605 uhal::Integer(lHwPublishedPageCount),
606 "; sleeping for ",
608 "us");
611 lValues.clear();
612 }
613
615 "flx client ",
616 uhal::Quote(id()),
617 " (URI: ",
619 ") : Reading page ",
620 uhal::Integer(lPageIndexToRead),
621 " (published count ",
622 uhal::Integer(lHwPublishedPageCount),
623 ", surpasses required, ",
625 ")");
626 }
628
629
630 std::shared_ptr<uhal::Buffers> lBuffers =
mReplyQueue.front();
632
633 uint32_t lNrWordsToRead(lBuffers->replyCounter() >> 2);
634 lNrWordsToRead += 1;
635
636 std::vector<uint32_t> lPageContents;
639 lGuard.unlock();
641 "Read ",
642 uhal::Integer(lNrWordsToRead),
643 " 32-bit words from address ",
644 uhal::Integer(4 + lPageIndexToRead * 4 *
mPageSize),
645 " ... ",
646 PacketFmt((
const uint8_t*)lPageContents.data(), 4 * lPageContents.size()));
647
648
649 const std::deque<std::pair<uint8_t*, uint32_t>>& lReplyBuffers(lBuffers->getReplyBuffer());
650 size_t lNrWordsInPacket = (lPageContents.at(0) >> 16) + (lPageContents.at(0) & 0xFFFF);
651 if (lNrWordsInPacket != (lBuffers->replyCounter() >> 2))
653 "Expected reply packet to contain ",
654 uhal::Integer(lBuffers->replyCounter() >> 2),
655 " words, but it actually contains ",
656 uhal::Integer(lNrWordsInPacket),
657 " words");
658
659 size_t lNrBytesCopied = 0;
660 for (std::deque<std::pair<uint8_t*, uint32_t>>::const_iterator lIt = lReplyBuffers.begin();
661 lIt != lReplyBuffers.end();
662 ++lIt) {
663
664 if (lNrBytesCopied >= 4 * lNrWordsInPacket)
665 break;
666
667 size_t lNrBytesToCopy = std::min(lIt->second, uint32_t(4 * lNrWordsInPacket - lNrBytesCopied));
668 memcpy(lIt->first, &lPageContents.at(1 + (lNrBytesCopied / 4)), lNrBytesToCopy);
669 lNrBytesCopied += lNrBytesToCopy;
670 }
671
672
673 try {
674 if (uhal::exception::exception* lExc =
675 ClientInterface::validate(lBuffers))
676 {
678 }
679 } catch (uhal::exception::exception& aExc) {
682 "Exception caught during reply validation for flx device with URI ",
683 uhal::Quote(this->
uri()),
684 "; what returned: ",
685 uhal::Quote(aExc.what()));
686 }
687
690 }
691}
PacketFmt(const uint8_t *const, const size_t)