#include #include #include #include #include #include "contract/contract.h" int main(int argc, char** argv) { if (argc != 2) { return 2; } const std::string name = "/" + std::string(argv[1]); const int fd = shm_open(name.c_str(), O_RDONLY, 0); if (fd < 0) { return 3; } void* map = mmap( nullptr, sizeof(nui::contract::FrameContract), PROT_READ, MAP_SHARED, fd, 0); if (map == MAP_FAILED) { close(fd); return 4; } const auto* contract = static_cast(map); nui::contract::FrameData frame{}; nui::contract::read_latest_frame(*contract, frame); std::printf( "published=%llu frame=%u slot_sequence=%llu\n", static_cast(contract->published_sequence), frame.frame_number, static_cast( contract->slots[ contract->published_sequence % nui::contract::kFrameSlotCount] .sequence)); munmap(map, sizeof(nui::contract::FrameContract)); close(fd); return 0; }