From 0dc4d06450f9a39c780fc91ffb73317d606c5098 Mon Sep 17 00:00:00 2001 From: Lars Amsel Date: Tue, 13 Jul 2021 12:28:11 +0200 Subject: rfnoc: allow find_blocks to search by device number or block count. In current implementation it is not possible to find all blocks of a device by calling find_blocks("0/"). The same is true for the block count. This is caused by the valid block id regex which requires a block name. This regex is used to validate the block name as well as to match block ids in search. This fix looses the requirement for the block name to allow searches by device number and block count and also extends the is_valid_block_id method to require the block name match to be non empty (which restores the previous behaviour at this point). --- host/include/uhd/rfnoc/constants.hpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'host/include') diff --git a/host/include/uhd/rfnoc/constants.hpp b/host/include/uhd/rfnoc/constants.hpp index 68833430c..fdcc40d99 100644 --- a/host/include/uhd/rfnoc/constants.hpp +++ b/host/include/uhd/rfnoc/constants.hpp @@ -89,7 +89,11 @@ static const size_t MAX_NUM_PORTS = 16; // Regular expressions static const std::string VALID_BLOCKNAME_REGEX = "[A-Za-z][A-Za-z0-9_]*"; +static const std::string DEVICE_NUMBER_REGEX = R"-((?:(\d+)/)?)-"; +static const std::string BLOCK_COUNTER_REGEX = R"-((?:#(\d+))?)-"; static const std::string VALID_BLOCKID_REGEX = - "(?:(\\d+)(?:/))?([A-Za-z][A-Za-z0-9_]*)(?:(?:#)(\\d\\d?))?"; + DEVICE_NUMBER_REGEX + "(" + VALID_BLOCKNAME_REGEX + ")" + BLOCK_COUNTER_REGEX; +static const std::string MATCH_BLOCKID_REGEX = + DEVICE_NUMBER_REGEX + "(" + VALID_BLOCKNAME_REGEX + ")?" + BLOCK_COUNTER_REGEX; }} /* namespace uhd::rfnoc */ -- cgit v1.2.3