Skip to content

Commit

Permalink
connect: warn about unused type and doc updates
Browse files Browse the repository at this point in the history
Signed-off-by: Markus Klotzbuecher <mk@mkio.de>
  • Loading branch information
kmarkus committed Jul 21, 2020
1 parent f4a40b4 commit 24f72b9
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 22 deletions.
15 changes: 9 additions & 6 deletions docs/dev/003-blockdiagram-new-connect-statement.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ beforehand). The new connect statement shall support the following:
- allow specifying which iblock to connect with
- it must be possible to provide custom configs for iblocks
- allow iblock connections to/from existing and nonexisting iblocks
(the latter need to be created, obviously)
(the latter shall be created on the fly)
- backwards compatibility as much as possible. By default connect via
`lfds_cyclic`, `buffer_len = 1`

Expand Down Expand Up @@ -43,7 +43,7 @@ The default when no type is defined is to use `lfds_cyclic` with a the
### connections to existing iblocks

Creating a cblock->iblock connection to an **existing** iblock is
achieved as follows:
achieved as follows (same as before):

```Lua
connect { src="CB1", tgt="IB1" } -- or
Expand All @@ -53,7 +53,7 @@ connect { src="IB1", tgt="CB1" }
**Note**:

- both src and tgt blocks must exist
- `type` and `config` are ignored (rationale: since the block was
- `type` and `config` must not be set (rationale: since the block was
created elsewhere, it should also be configured elsewhere).

### connections to non-existing (to-be-created) iblocks
Expand All @@ -62,14 +62,17 @@ Create a cblock->iblock connection to a **non-existing** iblock use
the following:

```Lua
connect { src="CB1", tgt="IB1", type="IBTYPE", config={...} } -- or
connect { src="IB1", tgt="CB1", type="IBTYPE", config={...} }
connect { src="CB1", type="IBTYPE", config={...} } -- or
connect { tgt="CB1", type="IBTYPE", config={...} }
```

**Note**:

- `CB1` *must* exit, `IB1` must **not**
- the cblock *must* exit
- the non-existing `src` or `tgt` must be unset (an automatic uid based name is chosen)
- `type` must be a valid iblock type and `config` its config
- `type_name`, `data_len` and `buffer_len` and `mq_id` are
automatically set (if they exist).


## Implementation
Expand Down
44 changes: 28 additions & 16 deletions lua/ubx.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1671,20 +1671,20 @@ end
-- connected using a new iblock of ibtype configured with config.
--
-- 2. cblock-iblock: if one of src and tgt is a cblock and the other
-- an iblock, then these are connected. config must be nil (as the
-- iblock was created elsewhere, it must be configured elsewhere too).
-- an iblock, then these are connected. ibtype and config must be nil
-- (as the iblock was created elsewhere, it must be configured
-- elsewhere too).
--
-- 3. cblock-iblock: if one of src and tgt is a cblock, and the other
-- is nil, then a new iblock will be created and configured with
-- `config` and src or tgt is connected to it.
-- is nil, then a new iblock of ibtype will be created and configured
-- with `config` and src or tgt is connected to it.
--
-- Special cases:
-- - for 1: if ibtype is unset, the it defaults to lfds_cyclic
-- - for 3:
-- - if ibtype is "mqueue" and config.mq_id is nil, then the
-- connected cblocks name and port will be used.
-- - type_name, data_len and buffer_len are set automatically
-- unless overriden in config.
-- - for 1: if ibtype is unset, the it defaults to lfds_cyclic
-- - for 1+3: type_name, data_len and buffer_len are set automatically
-- unless overriden in config.
-- - for 3: if config.mq_id is unset, a default name based on the
-- peer port is chosen.
--
-- @param nd node
-- @param srcbn source block name
Expand Down Expand Up @@ -1771,14 +1771,26 @@ function M.connect(nd, srcbn, srcpn, tgtbn, tgtpn, ibtype, ibconfig)
end

-- check: warn about a config table when it's not used
if M.is_iblock_instance(srcb) and ibconfig then
warn(nd, "connect", fmt("%s -> %s.%s: ignoring config %s",
srcbn, tgtbn, tgtpn, utils.tab2str(ibconfig)))
if M.is_iblock_instance(srcb) then
if ibconfig then
warn(nd, "connect", fmt("%s -> %s.%s: ignoring config %s",
srcbn, tgtbn, tgtpn, utils.tab2str(ibconfig)))
end
if ibtype then
warn(nd, "connect", fmt("%s -> %s.%s: ignoring type %s",
srcbn, tgtbn, tgtpn, ibtype))
end
end

if M.is_iblock_instance(tgtb) and ibconfig then
warn(nd, "connect", fmt("%s.%s -> %s: ignoring config %s",
srcbn, srcpn, tgtbn, utils.tab2str(ibconfig)))
if M.is_iblock_instance(tgtb) then
if ibconfig then
warn(nd, "connect", fmt("%s.%s -> %s: ignoring config %s",
srcbn, srcpn, tgtbn, utils.tab2str(ibconfig)))
end
if ibtype then
warn(nd, "connect", fmt("%s -> %s.%s: ignoring type %s",
srcbn, tgtpn, tgtbn, ibtype))
end
end

-- check: for port-port connections, types and dimensions must match
Expand Down

0 comments on commit 24f72b9

Please sign in to comment.