diff --git a/README.md b/README.md index c94d947..867f245 100644 --- a/README.md +++ b/README.md @@ -130,8 +130,9 @@ A missing privilege exits with code 9 and the error code `permission_denied` ([d | `gsdml schema versions` | the GSDML schema versions go-profinet has (1.0 to 2.46) | | `gsdml schema validate FILE [--version V]` | validation against the schema of the file's version (or `V`) only: structure, simple types and facets, identity constraints, each issue with its line (exit code 7 when it is not valid) | | `gsdml schema dump FILE [--version V] [--no-validate]` | the typed model of the file as JSON, with the schema's names and JSON numbers and booleans for numeric and boolean types | -| `gsdml modules FILE`, `gsdml submodules FILE` | the module and submodule types, with IO lengths, records and (`submodules`) the API of a submodule of an API other than 0; `modules` also lists, with why, the modules left out of the catalog because they need a configurable submodule | -| `gsdml plan FILE [--dap ID] [--plug SLOT=IDENT]... [--slot N]... [--param-value SLOT:SUBSLOT:INDEX:FIELD=VALUE]... [--param-defaults]` | the parameter records an AR with the same flags writes before PrmEnd, in write order (with the API of a submodule of an API other than 0), built from the file's fields with go-profinet's `PlanParameters`, with the issues of the records and their severity (with `--format table` on stderr); sends nothing (exit code 7 when go-profinet refuses the plan for errors of the records). An AR's `--param` records are not part of the plan | +| `gsdml modules FILE`, `gsdml submodules FILE` | the module and submodule types, with IO lengths, records and (`submodules`) the API of a submodule of an API other than 0; `modules` lists the modules with configurable submodules too, with their number and the IO lengths of their defaults, and apart, with why, those go-profinet cannot place | +| `gsdml config FILE [--dap ID] [--plug SLOT=IDENT]... [--plug-submodule SLOT:SUBSLOT=SUBMODULE]...` | the configuration of a device access point, resolved with go-profinet's `gsdml.Configuration`: each slot (0 is the DAP) with its module and submodules, a configurable submodule marked with its SubmoduleItem ID, and the configurable submodules the DAP and each plugged module can put in their subslots (allowed, fixed and used subslots); `--plug` and `--plug-submodule` change it as for an AR; sends nothing | +| `gsdml plan FILE [--dap ID] [--plug SLOT=IDENT]... [--plug-submodule SLOT:SUBSLOT=SUBMODULE]... [--slot N]... [--param-value SLOT:SUBSLOT:INDEX:FIELD=VALUE]... [--param-defaults]` | the parameter records an AR with the same flags writes before PrmEnd, in write order (with the API of a submodule of an API other than 0), built from the file's fields with go-profinet's `PlanParameters`, with the issues of the records and their severity (with `--format table` on stderr); sends nothing (exit code 7 when go-profinet refuses the plan for errors of the records). An AR's `--param` records are not part of the plan | | `gsdml generate --model MODEL.json [--output-file FILE\|DIR] [--pnio-version V] [--device-access=false]` | the GSDML file of a go-profinet device model (`--output-file`/`-O`: a file, or a directory for the conventional name; `--pnio-version`: declared PNIO_Version, default V2.35; `--device-access`: declare DeviceAccessSupported, default true) | | `connect` | establish an AR as IO-Controller and run it: states and alarms are streamed, then a summary; `--slot N` expects only some modules (shared device: another controller owns the rest), `--peer-check PORT=STATION/PORT` has the device watch a port's neighbor, `--mrp-role client\|manager\|off` gives a multiport device its MRP role, `--reparam SLOT:SUBSLOT:INDEX:HEX` re-parameterizes the running AR (PrmBegin … PrmEnd) | | `ar` | establish an AR and show what Connect negotiated (AR, IOCRs, ModuleDiff) | @@ -157,6 +158,8 @@ Every command has `--help`. A device is selected by `--station NAME` (resolved w `connect`, `ar`, `iocr`, `io` and `alarms` act as IO-Controller (conformance class A, RT_CLASS_1, or RT_CLASS_2 with `--advanced`). They need the expected configuration of the device: its GSDML file (`--gsdml FILE`, with `--dap ID` when it has several device access points), or a go-profinet model in JSON (`--model`). The modules a GSDML file fixes or uses in slots are expected; `--plug SLOT=IDENT` plugs others from its catalog (`gsdml modules` lists them), in a slot the file allows them in (the device access point's `PhysicalSlots` and the module's `AllowedInSlots`); `--plug-any-slot` lifts that, to test how a device answers a module in the wrong slot. +Configurable submodules (a module's or the DAP's `UseableSubmodules`, from the file's `SubmoduleList`) are configured with go-profinet's `gsdml.Configuration`: each is in the subslots the file fixes it in, else uses it in, and `--plug-submodule SLOT:SUBSLOT=SUBMODULE` (repeatable, after `--plug`; slot 0 is the DAP) puts another in a subslot the file allows it in, by its SubmoduleItem ID or by its ident number when only one has it, or with `-` leaves a subslot empty; `gsdml config` shows the configuration and the choices. profinetctl uses the configuration for `--plug-submodule`, for a device access point whose defaults need configurable submodules, and for a `--plug` of a module that has them; otherwise the model is go-profinet's `gsdml.ToModel`, as before. The configuration plugs a module only in a slot the file allows (`--plug-any-slot` is refused with it) and does not replace a module the file fixes in a slot; a subslot the file uses two submodules in by default needs a `--plug-submodule`. Its reading of the subslot attributes is go-profinet's, not checked against PI's specification or an engineering tool. + ```console $ sudo profinetctl -i eth0 connect -s io-rack-1 --gsdml device.xml --plug 3=0x30 \ --output 2:1:00000001 --param 1:1:123:01020304 --duration 10s diff --git a/RELEASE.md b/RELEASE.md index 3213857..6274283 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -23,6 +23,79 @@ ending with a `---` line and no `---` line inside a section --- +## v0.22.0 + +**Date:** 2026-11-24 +**Previous release:** v0.21.0 + +## Summary + +Built on go-profinet v0.24.0, whose `gsdml.Configuration` configures +configurable GSDML submodules (`UseableSubmodules`). `--plug-submodule` +chooses them for an AR and `gsdml plan`, the new `gsdml config` shows a +device access point's configuration and its choices, and the device +access points and modules v0.21.0 refused for configurable submodules +now work with their defaults. + +## Changes + +### Added + +- **`--plug-submodule SLOT:SUBSLOT=SUBMODULE`** (`connect`, the other AR + commands, `gsdml plan`; repeatable, after `--plug`; slot 0 is the + DAP): puts a configurable submodule in a subslot the file allows it in, + by its SubmoduleItem ID or by its ident number when only one submodule + has it, or with `-` leaves the subslot empty. +- **`gsdml config FILE [--dap ID] [--plug ...] [--plug-submodule ...]`**: + the resolved configuration (each slot with its module and submodules, a + configurable submodule marked with its ID) and the configurable + submodules of the DAP and of each plugged module, with the subslots the + file allows, fixes and uses them in. JSON: docs/json-output.md. +- **`gsdml modules`**: `configurable_submodules` per module in JSON, + ", N configurable" in text. + +### Changed + +- **go-profinet v0.24.0** (from v0.23.0). +- **Configurable submodules.** profinetctl builds the model with + go-profinet's `gsdml.Configuration` when `--plug-submodule` is given, + when a device access point's defaults need configurable submodules + (`ToModel` refuses it), and when a `--plug` names a module that has + them; otherwise it is `gsdml.ToModel`'s model, as before. Each + configurable submodule is in the subslots the file fixes it in, else + uses it in. The configuration plugs a module only in a slot the file + allows and does not replace a module the file fixes in a slot. +- **`--gsdml`, `gsdml modules`, `submodules`, `inspect`, `check`**: a + device access point v0.21.0 refused with `unsupported_gsdml` for a + configurable submodule is its default configuration. A default that + needs a choice (two submodules used in one subslot) exits 3 with + `invalid_input` and names the subslot; `gsdml check` reports it as + unvalidated, rule `model`. +- **`gsdml modules`**: a module with configurable submodules is among + the usable modules (its submodules and IO lengths those of its + defaults); `omitted_modules` now holds only the modules go-profinet + cannot place, with why. +- **`--plug` of a module with configurable submodules** plugs it with its + defaults instead of exiting 3 with `unsupported_gsdml`. A slot the file + does not allow, or one with a module the file fixes, is `invalid_input` + (exit 3). + +### Breaking + +- `--plug-any-slot` with a configuration of configurable submodules exits + 2 with `invalid_flag_combination`; it had no such configuration to + apply to before. `--plug-submodule` with `--model` does too. +- `gsdml modules` JSON: modules with configurable submodules move from + `omitted_modules` to `modules`. +- Exit codes and messages for files with configurable submodules change + as above: `unsupported_gsdml` becomes success, or `invalid_input` for a + choice the file does not allow or a default that needs one. + +The reading of the subslot attributes is go-profinet's, not checked +against PI's specification or an engineering tool (its LIMITATIONS.md). + +--- + ## v0.21.0 **Date:** 2026-11-24 diff --git a/cmd/ar.go b/cmd/ar.go index b99f136..3a20906 100644 --- a/cmd/ar.go +++ b/cmd/ar.go @@ -35,6 +35,7 @@ type arOptions struct { gsdml, dap string modelFile string plugs []string + plugSubs []string plugAnySlot bool advanced bool sendClock uint16 @@ -73,6 +74,7 @@ func addAROptions(c *cobra.Command, o *arOptions) { f.StringVar(&o.dap, "dap", "", "Device access point ID in the GSDML file (default: the first)") f.StringVar(&o.modelFile, "model", "", "Expected configuration as a go-profinet model in JSON (instead of --gsdml)") f.StringArrayVar(&o.plugs, "plug", nil, "Plug the module with this ident number from the GSDML catalog: SLOT=IDENT (repeatable), in a slot the GSDML file allows it in") + f.StringArrayVar(&o.plugSubs, "plug-submodule", nil, plugSubmoduleUsage) f.BoolVar(&o.plugAnySlot, "plug-any-slot", false, "Let --plug plug a module in a slot the GSDML file does not allow it in (PhysicalSlots, AllowedInSlots), to test how the device answers") f.BoolVar(&o.advanced, "advanced", false, "Advanced startup with RT_CLASS_2 (instead of legacy startup with RT_CLASS_1)") f.Uint16Var(&o.sendClock, "send-clock", 32, "SendClockFactor in units of 31.25 µs (32 = 1 ms)") @@ -161,21 +163,10 @@ func (o *arOptions) parse() (*parsedAR, error) { if err := o.checkNumbers(); err != nil { return nil, err } - m, doc, err := loadModelDoc(o.gsdml, o.dap, o.modelFile) + m, doc, err := buildModel(o.gsdml, o.dap, o.modelFile, modelChoices{plugs: o.plugs, subs: o.plugSubs, anySlot: o.plugAnySlot}) if err != nil { return nil, err } - var rules *slotRules - if doc != nil && !o.plugAnySlot { - rules = slotRulesOf(doc, o.dap) - } - var omitted []omittedModule - if len(o.plugs) > 0 { - omitted = omittedModules(doc, o.dap) - } - if err := plug(m, o.plugs, rules, omitted); err != nil { - return nil, err - } if m, err = withSlots(m, o.slots); err != nil { return nil, err } diff --git a/cmd/configuration.go b/cmd/configuration.go new file mode 100644 index 0000000..f6e70d4 --- /dev/null +++ b/cmd/configuration.go @@ -0,0 +1,461 @@ +// SPDX-License-Identifier: MIT + +package cmd + +import ( + "context" + "errors" + "fmt" + "slices" + "strconv" + "strings" + + "github.com/spf13/cobra" + + "github.com/otfabric/go-profinet" + "github.com/otfabric/go-profinet/gsdml" + "github.com/otfabric/go-profinet/model" + "github.com/otfabric/profinetctl/internal/errs" +) + +// modelChoices are the changes to the default configuration of a device +// access point: --plug, --plug-submodule and --plug-any-slot. +type modelChoices struct { + plugs []string + subs []string + anySlot bool +} + +// parsedPlug is a --plug SLOT=IDENT. +type parsedPlug struct { + text string + slot uint16 + ident uint32 +} + +func parsePlug(pl string) (parsedPlug, error) { + slotS, identS, ok := strings.Cut(pl, "=") + slot, err := parseUint16(slotS) + if !ok || err != nil || slot == 0 { + return parsedPlug{}, errs.InvalidInput(errs.CodeInvalidInput, fmt.Sprintf("--plug %q: want SLOT=IDENT with a slot from 1", pl), err) + } + ident, err := strconv.ParseUint(identS, 0, 32) + if err != nil { + return parsedPlug{}, errs.InvalidInput(errs.CodeInvalidInput, fmt.Sprintf("--plug %q: %v", pl, err), err) + } + return parsedPlug{text: pl, slot: slot, ident: uint32(ident)}, nil +} + +// parsedSub is a --plug-submodule SLOT:SUBSLOT=SUBMODULE; submodule "-" +// clears the subslot. +type parsedSub struct { + text string + slot, subslot uint16 + submodule string +} + +func parsePlugSubmodule(s string) (parsedSub, error) { + addr, sub, ok := strings.Cut(s, "=") + slotS, subslotS, ok2 := strings.Cut(addr, ":") + slot, e1 := parseUint16(slotS) + subslot, e2 := parseUint16(subslotS) + sub = strings.TrimSpace(sub) + if !ok || !ok2 || e1 != nil || e2 != nil || subslot == 0 || sub == "" { + return parsedSub{}, errs.InvalidInput(errs.CodeInvalidInput, fmt.Sprintf("--plug-submodule %q: want SLOT:SUBSLOT=SUBMODULE (the SubmoduleItem ID or its ident number, or - to leave the subslot empty) with a subslot from 1", s), errors.Join(e1, e2)) + } + return parsedSub{text: s, slot: slot, subslot: subslot, submodule: sub}, nil +} + +// buildModel reads the expected configuration of a device: a GSDML file +// (with the ID of its device access point) or a model in JSON, with the +// modules of --plug and the submodules of --plug-submodule. +// +// A GSDML file becomes gsdml.ToModel's model, --plug changing its slots, +// unless it needs go-profinet's gsdml.Configuration: --plug-submodule is +// given, ToModel refuses the device access point (ErrUnsupported: it needs +// configurable submodules), or a --plug names a module ToModel leaves out +// of the catalog for one. The configuration plugs modules only in the +// slots the file allows (--plug-any-slot is refused) and does not replace a +// module the file fixes in a slot. +func buildModel(gsdmlFile, dap, modelFile string, ch modelChoices) (*model.Device, *gsdml.Document, error) { + if gsdmlFile == "" || modelFile != "" { + if len(ch.subs) > 0 && modelFile != "" && gsdmlFile == "" { + return nil, nil, errs.New(errs.KindUsage, errs.CodeInvalidFlagCombination, "--plug-submodule needs --gsdml: a model in JSON has its submodules", nil) + } + m, doc, err := loadModelDoc(gsdmlFile, dap, modelFile) + if err != nil { + return nil, nil, err + } + if err := plug(m, ch.plugs, nil, nil); err != nil { + return nil, nil, err + } + return m, doc, nil + } + doc, err := readGSDML(gsdmlFile) + if err != nil { + return nil, nil, err + } + plugs := make([]parsedPlug, 0, len(ch.plugs)) + for _, pl := range ch.plugs { + p, err := parsePlug(pl) + if err != nil { + return nil, nil, err + } + plugs = append(plugs, p) + } + m, terr := gsdml.ToModel(doc, dap) + var omitted []omittedModule + if terr == nil && len(plugs) > 0 { + omitted = omittedModules(doc, dap) + } + if len(ch.subs) == 0 && !errors.Is(terr, profinet.ErrUnsupported) && !plugsOmitted(plugs, omitted) { + if terr != nil { + return nil, nil, gsdmlError(fmt.Sprintf("%s: %v", gsdmlFile, terr), terr) + } + var rules *slotRules + if !ch.anySlot { + rules = slotRulesOf(doc, dap) + } + if err := plug(m, ch.plugs, rules, omitted); err != nil { + return nil, nil, err + } + return m, doc, nil + } + if ch.anySlot && len(plugs) > 0 { + return nil, nil, errs.New(errs.KindUsage, errs.CodeInvalidFlagCombination, + "--plug-any-slot: this configuration needs configurable submodules (go-profinet's gsdml.Configuration), which plugs modules only in the slots the GSDML file allows", nil) + } + _, m, err = configure(gsdmlFile, doc, dap, plugs, ch.subs) + if err != nil { + return nil, nil, err + } + return m, doc, nil +} + +// defaultModel is the model of a device access point that --gsdml with +// its ID and no choices gives: gsdml.ToModel's, or for one ToModel refuses +// as unsupported, its default configuration's (gsdml.Configuration). The +// configuration's error replaces ToModel's when it is not unsupported too. +func defaultModel(doc *gsdml.Document, dap string) (*model.Device, error) { + m, err := gsdml.ToModel(doc, dap) + if !errors.Is(err, profinet.ErrUnsupported) { + return m, err + } + c, cerr := gsdml.NewConfiguration(doc, dap) + if cerr == nil { + var cm *model.Device + if cm, cerr = c.Resolve(); cerr == nil { + return cm, nil + } + } + if errors.Is(cerr, profinet.ErrUnsupported) { + return nil, err + } + return nil, cerr +} + +// plugsOmitted reports whether a --plug names a module the catalog leaves +// out. +func plugsOmitted(plugs []parsedPlug, omitted []omittedModule) bool { + for _, p := range plugs { + for _, om := range omitted { + if om.IdentNumber == p.ident { + return true + } + } + } + return false +} + +// configure is the configuration of a device access point with the +// modules of plugs, then the submodules of subs, and its model. +func configure(file string, doc *gsdml.Document, dap string, plugs []parsedPlug, subs []string) (*gsdml.Configuration, *model.Device, error) { + c, err := gsdml.NewConfiguration(doc, dap) + if err != nil { + return nil, nil, gsdmlError(fmt.Sprintf("%s: %v", file, err), err) + } + for _, p := range plugs { + if err := c.PlugIdent(p.slot, p.ident); err != nil { + return nil, nil, choiceError("--plug", p.text, err) + } + } + for _, s := range subs { + ps, err := parsePlugSubmodule(s) + if err != nil { + return nil, nil, err + } + if ps.submodule == "-" { + err = c.ClearSubslot(ps.slot, ps.subslot) + } else { + var id string + if id, err = submoduleID(c, ps.slot, ps.submodule); err == nil { + err = c.Select(ps.slot, ps.subslot, id) + } + } + if err != nil { + return nil, nil, choiceError("--plug-submodule", s, err) + } + } + m, err := c.Resolve() + if err != nil { + msg := fmt.Sprintf("%s: %v", file, err) + if errors.Is(err, profinet.ErrInvalidConfig) { + return nil, nil, errs.InvalidInput(errs.CodeInvalidInput, msg+" (profinetctl gsdml config lists the configurable submodules; --plug-submodule SLOT:SUBSLOT=ID chooses one)", err) + } + return nil, nil, gsdmlError(msg, err) + } + return c, m, nil +} + +// choiceError is the typed error of a choice the configuration refused: +// invalid_input for one the file does not allow, unsupported_gsdml or +// invalid_gsdml for one go-profinet cannot convert. +func choiceError(flag, value string, err error) error { + msg := fmt.Sprintf("%s %q: %v", flag, value, err) + if errors.Is(err, profinet.ErrInvalidConfig) && !errors.Is(err, profinet.ErrUnsupported) && !errors.Is(err, profinet.ErrMalformed) { + return errs.InvalidInput(errs.CodeInvalidInput, msg, err) + } + return gsdmlError(msg, err) +} + +// slotOptions are the configurable submodules of slot: the DAP's for slot +// 0, those of the module plugged in it otherwise; and the module's ID. +func slotOptions(c *gsdml.Configuration, slot uint16) (string, []gsdml.SubmoduleOption, *model.Module) { + if slot == 0 { + return "", c.DAP(), nil + } + id, ok := c.Module(slot) + mods := c.Modules() + i := slices.IndexFunc(mods, func(mo gsdml.ModuleOption) bool { return mo.ID == id }) + if !ok || i < 0 { + return id, nil, nil + } + return id, mods[i].Submodules, &mods[i].Module +} + +// submoduleID is the SubmoduleItem ID a --plug-submodule names: an ID of +// the slot's configurable submodules, else the ID of the only one with that +// ident number. Anything else is returned as given, for Select to refuse. +func submoduleID(c *gsdml.Configuration, slot uint16, v string) (string, error) { + _, opts, _ := slotOptions(c, slot) + for _, o := range opts { + if o.ID == v { + return v, nil + } + } + // Not an ID: an ident number names the submodule that has it. + if ident, err := gsdml.ParseUint32(v); err == nil { + var ids []string + for _, o := range opts { + if o.Submodule.IdentNumber == ident && !slices.Contains(ids, o.ID) { + ids = append(ids, o.ID) + } + } + switch len(ids) { + case 0: + case 1: + return ids[0], nil + default: + return "", fmt.Errorf("%w: submodules %s have SubmoduleIdentNumber 0x%08X: give the ID", profinet.ErrInvalidConfig, strings.Join(ids, " and "), ident) + } + } + return v, nil +} + +// configResult is the configuration of a device access point: its slots +// as resolved, and the configurable submodules of the DAP and of each +// plugged module. +type configResult struct { + DAP string `json:"dap"` + Slots []configSlot `json:"slots"` + Choices []configChoice `json:"choices"` +} + +type configSlot struct { + Slot uint16 `json:"slot"` + Module string `json:"module"` + IdentNumber uint32 `json:"ident_number"` + Submodules []configSubmodule `json:"submodules"` +} + +type configSubmodule struct { + Subslot uint16 `json:"subslot"` + Name string `json:"name"` + IdentNumber uint32 `json:"ident_number"` + API uint32 `json:"api"` + InputLen uint16 `json:"input_length"` + OutputLen uint16 `json:"output_length"` + Records int `json:"records"` + // ID is the SubmoduleItem of a configurable submodule; absent for a + // built-in one. + ID string `json:"id,omitempty"` +} + +// configChoice is a configurable submodule of the DAP (slot 0) or of a +// plugged module: what --plug-submodule can put in that slot. +type configChoice struct { + Slot uint16 `json:"slot"` + Module string `json:"module"` + ID string `json:"id"` + Name string `json:"name"` + IdentNumber uint32 `json:"ident_number"` + Port bool `json:"port,omitempty"` + Allowed string `json:"allowed_in_subslots,omitempty"` + Fixed string `json:"fixed_in_subslots,omitempty"` + Used string `json:"used_in_subslots,omitempty"` + Error string `json:"error,omitempty"` +} + +func newConfigResult(c *gsdml.Configuration, m *model.Device, dap string) configResult { + r := configResult{DAP: orDash(dap), Slots: []configSlot{}, Choices: []configChoice{}} + add := func(slot uint16, mod model.Module) { + modID, opts, builtin := slotOptions(c, slot) + if slot == 0 { + modID = mod.Name + } + s := configSlot{Slot: slot, Module: mod.Name, IdentNumber: mod.IdentNumber, Submodules: []configSubmodule{}} + for _, sm := range mod.Submodules { + v := configSubmodule{Subslot: sm.Subslot, Name: sm.Name, IdentNumber: sm.IdentNumber, API: sm.API, + InputLen: sm.InputLen, OutputLen: sm.OutputLen, Records: len(sm.Records), ID: configurableID(opts, builtin, sm)} + s.Submodules = append(s.Submodules, v) + } + r.Slots = append(r.Slots, s) + for _, o := range opts { + r.Choices = append(r.Choices, configChoice{Slot: slot, Module: modID, ID: o.ID, Name: o.Submodule.Name, IdentNumber: o.Submodule.IdentNumber, + Port: o.Port, Allowed: o.AllowedInSubslots, Fixed: o.FixedInSubslots, Used: o.UsedInSubslots, Error: o.Error}) + } + } + add(0, m.DAP) + for _, sl := range m.Slots { + add(sl.Number, sl.Module) + } + return r +} + +// configurableID is the ID of the configurable submodule sm is: the only +// option with its ident number that allows its subslot, which is not a +// subslot of the module's built-in submodules. +func configurableID(opts []gsdml.SubmoduleOption, builtin *model.Module, sm model.Submodule) string { + if builtin != nil { + for _, b := range builtin.Submodules { + if b.Subslot == sm.Subslot { + return "" + } + } + } + id := "" + for _, o := range opts { + if o.Err != nil || o.Submodule.IdentNumber != sm.IdentNumber || !o.Allows(sm.Subslot) { + continue + } + if id != "" && id != o.ID { + return "" + } + id = o.ID + } + return id +} + +func (r configResult) MarshalTextOutput() (string, error) { + var b strings.Builder + for _, s := range r.Slots { + fmt.Fprintf(&b, "slot %d 0x%08X %s\n", s.Slot, s.IdentNumber, s.Module) + for _, sm := range s.Submodules { + id := "" + if sm.ID != "" { + id = " [" + sm.ID + "]" + } + fmt.Fprintf(&b, " subslot 0x%04X 0x%08X %-28s %d in / %d out octets, %d record(s)%s\n", sm.Subslot, sm.IdentNumber, sm.Name, sm.InputLen, sm.OutputLen, sm.Records, id) + } + } + if len(r.Choices) == 0 { + b.WriteString("no configurable submodules\n") + return b.String(), nil + } + b.WriteString("configurable submodules (--plug-submodule SLOT:SUBSLOT=ID):\n") + for _, c := range r.Choices { + var where []string + for _, w := range [][2]string{{"allowed", c.Allowed}, {"fixed", c.Fixed}, {"used", c.Used}} { + if w[1] != "" { + where = append(where, w[0]+" "+clipList(w[1])) + } + } + line := fmt.Sprintf(" slot %d %s 0x%08X %s", c.Slot, c.ID, c.IdentNumber, c.Name) + if len(where) > 0 { + line += " (" + strings.Join(where, ", ") + ")" + } + if c.Error != "" { + line += ": cannot be placed: " + c.Error + } + b.WriteString(line + "\n") + } + return b.String(), nil +} + +func (r configResult) TableHeaders() []string { + return []string{"SLOT", "SUBSLOT", "MODULE", "SUBMODULE", "IDENT", "IN", "OUT", "ID"} +} + +func (r configResult) TableRows() [][]string { + var rows [][]string + for _, s := range r.Slots { + for _, sm := range s.Submodules { + rows = append(rows, []string{fmt.Sprint(s.Slot), fmt.Sprintf("0x%04X", sm.Subslot), s.Module, sm.Name, + fmt.Sprintf("0x%08X", sm.IdentNumber), fmt.Sprint(sm.InputLen), fmt.Sprint(sm.OutputLen), orDash(sm.ID)}) + } + } + return rows +} + +func newGSDMLConfigCmd(a *app) *cobra.Command { + var dap string + var plugs, subs []string + c := &cobra.Command{ + Use: "config FILE [--dap ID] [--plug SLOT=IDENT]... [--plug-submodule SLOT:SUBSLOT=SUBMODULE]...", + Short: "Show a device access point's configuration: its slots and the configurable submodules it can choose", + Long: `Resolve the configuration of a device access point with go-profinet's +gsdml.Configuration and show it: each slot (0 is the DAP) with its module +and submodules, a configurable submodule marked with its SubmoduleItem ID, +and the configurable submodules the DAP and each plugged module can put in +their subslots, with the subslots the file allows, fixes or uses them in. + +Without flags it is the default configuration: the modules the file plugs, +each configurable submodule in the subslots it is fixed in, else used in. +--plug and --plug-submodule change it as they do for an AR: --plug plugs a +module in a slot the file allows, --plug-submodule puts a configurable +submodule (its SubmoduleItem ID, or its ident number when one submodule has +it) in a subslot, or with - leaves the subslot empty. A configuration the +file does not allow (a fixed submodule replaced, a subslot two submodules +are used in by default without a choice) exits 3.`, + Args: cobra.ExactArgs(1), + RunE: func(cc *cobra.Command, args []string) error { + return a.result(cc, func(ctx context.Context) (any, error) { + doc, err := readGSDML(args[0]) + if err != nil { + return nil, err + } + var ps []parsedPlug + for _, pl := range plugs { + p, err := parsePlug(pl) + if err != nil { + return nil, err + } + ps = append(ps, p) + } + cfg, m, err := configure(args[0], doc, dap, ps, subs) + if err != nil { + return nil, err + } + return newConfigResult(cfg, m, dap), nil + }) + }, + } + f := c.Flags() + f.StringVar(&dap, "dap", "", "Device access point ID (default: the first)") + f.StringArrayVar(&plugs, "plug", nil, "Plug the module with this ident number: SLOT=IDENT (repeatable), in a slot the GSDML file allows it in") + f.StringArrayVar(&subs, "plug-submodule", nil, plugSubmoduleUsage) + return c +} + +// plugSubmoduleUsage is the help of --plug-submodule. +const plugSubmoduleUsage = "Put a configurable submodule in a subslot: SLOT:SUBSLOT=SUBMODULE, the SubmoduleItem ID or its ident number, or - to leave the subslot empty (repeatable; slot 0 is the DAP; after --plug)" diff --git a/cmd/gsdml.go b/cmd/gsdml.go index 4dbdf9e..4c2520f 100644 --- a/cmd/gsdml.go +++ b/cmd/gsdml.go @@ -68,6 +68,15 @@ func loadModelDoc(gsdmlFile, dap, modelFile string) (*model.Device, *gsdml.Docum return nil, nil, err } m, err := gsdml.ToModel(doc, dap) + if errors.Is(err, profinet.ErrUnsupported) { + // A device access point that needs configurable submodules: + // its default configuration. + _, cm, cerr := configure(gsdmlFile, doc, dap, nil, nil) + if cerr != nil { + return nil, nil, cerr + } + return cm, doc, nil + } if err != nil { return nil, nil, gsdmlError(fmt.Sprintf("%s: %v", gsdmlFile, err), err) } @@ -213,7 +222,7 @@ func inspect(ctx context.Context, path string, doc *gsdml.Document, rep gsdml.Re if err := interrupted(ctx); err != nil { return inspectResult{}, err } - if m, err := gsdml.ToModel(doc, d.ID); err != nil { + if m, err := defaultModel(doc, d.ID); err != nil { v.Error = err.Error() } else { v.Name, v.MinDeviceInterval, v.Ports = m.Identity.TypeOfStation, m.Capabilities.MinDeviceInterval, m.Capabilities.Ports @@ -293,14 +302,18 @@ type moduleView struct { InputLen int `json:"input_length"` OutputLen int `json:"output_length"` Info string `json:"info,omitempty"` + // Configurable is the number of configurable submodules the module can + // choose (UseableSubmodules); Submodules and the lengths are those of + // its default configuration. + Configurable int `json:"configurable_submodules,omitempty"` } type modulesResult struct { DAP string `json:"dap"` Modules []moduleView `json:"modules"` - // Omitted are the modules the file lets the DAP use that are not in - // the model's catalog, with why: they need a configurable submodule, - // which go-profinet does not convert (--plug refuses them). + // Omitted are the modules the file lets the DAP use that --plug + // refuses, with why: go-profinet cannot place their configurable + // submodules. Omitted []omittedModuleView `json:"omitted_modules,omitempty"` } @@ -318,7 +331,11 @@ func (r modulesResult) MarshalTextOutput() (string, error) { if len(m.Slots) > 0 { slots = strings.Trim(fmt.Sprint(m.Slots), "[]") } - fmt.Fprintf(&b, "0x%08X %-32s slots %-8s %d submodule(s), %d in / %d out octets\n", m.IdentNumber, m.Name, slots, m.Submodules, m.InputLen, m.OutputLen) + conf := "" + if m.Configurable > 0 { + conf = fmt.Sprintf(", %d configurable", m.Configurable) + } + fmt.Fprintf(&b, "0x%08X %-32s slots %-8s %d submodule(s)%s, %d in / %d out octets\n", m.IdentNumber, m.Name, slots, m.Submodules, conf, m.InputLen, m.OutputLen) } fmt.Fprintf(&b, "%d module(s) usable with DAP %s\n", len(r.Modules), r.DAP) if len(r.Omitted) > 0 { @@ -513,11 +530,30 @@ profinetctl, and this is not PI's GSDML checker.`, return nil, err } r := modulesResult{DAP: orDash(dap), Modules: []moduleView{}} + configurable := map[uint32]int{} for _, om := range omittedModules(doc, dap) { r.Omitted = append(r.Omitted, omittedModuleView{ID: om.ID, IdentNumber: om.IdentNumber, Reason: om.Err.Error()}) } + if c, cm, cerr := configure(args[0], doc, dap, nil, nil); cerr == nil { + // The default configuration: its catalog has the + // modules with configurable submodules too, with their + // defaults; the modules it cannot place are omitted. + m, r.Omitted = cm, nil + seen := map[uint32]bool{} + for _, mt := range m.ModuleTypes() { + seen[mt.IdentNumber] = true + } + for _, mo := range c.Modules() { + id := mo.Module.IdentNumber + configurable[id] = max(configurable[id], len(mo.Submodules)) + if !seen[id] { + seen[id] = true + r.Omitted = append(r.Omitted, omittedModuleView{ID: mo.ID, IdentNumber: id, Reason: optionError(mo)}) + } + } + } for _, mt := range m.ModuleTypes() { - v := moduleView{Name: mt.Name, IdentNumber: mt.IdentNumber, Submodules: len(mt.Submodules), Info: mt.Info} + v := moduleView{Name: mt.Name, IdentNumber: mt.IdentNumber, Submodules: len(mt.Submodules), Info: mt.Info, Configurable: configurable[mt.IdentNumber]} for _, s := range mt.Submodules { v.InputLen += int(s.InputLen) v.OutputLen += int(s.OutputLen) @@ -621,6 +657,30 @@ file goes to stdout; with a directory it gets its conventional name generateCmd.Flags().StringVarP(&out, "output-file", "O", "", "Write to this file, or under the conventional name to this directory") generateCmd.Flags().StringVar(&version, "pnio-version", "", "Declared PNIO_Version (default V2.35)") generateCmd.Flags().BoolVar(&supervisor, "device-access", true, "Declare DeviceAccessSupported (supervisor AR)") - g.AddCommand(inspectCmd, validateCmd, newGSDMLCheckCmd(a), newGSDMLSchemaCmd(a), newGSDXCmd(a), modulesCmd, submodulesCmd, newGSDMLPlanCmd(a), generateCmd) + g.AddCommand(inspectCmd, validateCmd, newGSDMLCheckCmd(a), newGSDMLSchemaCmd(a), newGSDXCmd(a), modulesCmd, submodulesCmd, newGSDMLConfigCmd(a), newGSDMLPlanCmd(a), generateCmd) return g } + +// optionError is why the default configuration leaves a module out of its +// catalog: its own error, else that of its first configurable submodule +// that has one, else two submodules used in one subslot by default (their +// Defaults), which --plug-submodule decides. +func optionError(mo gsdml.ModuleOption) string { + if mo.Error != "" { + return mo.Error + } + reason := "not in the catalog of the default configuration" + by := map[uint16]string{} + for _, o := range mo.Submodules { + if o.Error != "" { + return "configurable submodule " + o.ID + ": " + o.Error + } + for _, s := range o.Defaults { + if other, dup := by[s]; dup && other != o.ID { + reason = fmt.Sprintf("configurable submodules %s and %s are both used in subslot %d by default: --plug with --plug-submodule chooses one", other, o.ID, s) + } + by[s] = o.ID + } + } + return reason +} diff --git a/cmd/omitted_test.go b/cmd/omitted_test.go index fb961d7..18a686c 100644 --- a/cmd/omitted_test.go +++ b/cmd/omitted_test.go @@ -6,55 +6,356 @@ import ( "strings" "testing" + "github.com/otfabric/go-profinet/device" "github.com/otfabric/go-profinet/gsdml" ) -// omittedGSDMLFile writes the test model's GSDML file with a configurable -// submodule (UseableSubmodules, UsedInSubslots) on the catalog module -// 0x40, which no slot plugs: gsdml.ToModel leaves it out of the catalog. -func omittedGSDMLFile(t *testing.T) string { +// configurableDoc is the test model's GSDML file with configurable +// submodules: a SubmoduleList with SM_WIDE (4 octets in) and SM_ALT (2 +// octets out), and the catalog module 0x40 allowed in slots 3 to 5 (of +// PhysicalSlots 0..5; a single allowed slot would plug it; slot 3 has a +// module the file fixes), where it uses SM_WIDE in subslot 2 by default and +// allows either in subslots 2 and 3. With inSlot1, the plugged module 0x10 +// uses SM_WIDE in subslot 2 too, which gsdml.ToModel refuses. +func configurableDoc(t *testing.T, inSlot1 bool) *gsdml.Document { t.Helper() doc, err := gsdml.FromModel(testModel(), gsdml.GenerateOptions{SupervisorAR: true}) if err != nil { t.Fatal(err) } - found := false - for _, mi := range doc.ProfileBody.ApplicationProcess.ModuleList.ModuleItems { - if v, err := gsdml.ParseUint32(mi.ModuleIdentNumber); err == nil && v == 0x40 { - mi.UseableSubmodules = &gsdml.UseableSubmodules{SubmoduleItemRefs: []*gsdml.SubmoduleItemRef{ - {SubmoduleItemTarget: "SM_CHANNEL", AllowedInSubslots: "2..3", UsedInSubslots: "2"}}} - found = true + ap := doc.ProfileBody.ApplicationProcess + var text string + items := map[uint32]*gsdml.ModuleItem{} + for _, mi := range ap.ModuleList.ModuleItems { + v, err := gsdml.ParseUint32(mi.ModuleIdentNumber) + if err != nil { + t.Fatal(err) } + items[v] = mi + text = mi.ModuleInfo.Name.TextID } - if !found { - t.Fatal("no module 0x40 in the generated file") + info := func() *gsdml.ModuleInfo { + return &gsdml.ModuleInfo{Name: &gsdml.Name{TextID: text}, InfoText: &gsdml.InfoText{TextID: text}} } + ap.SubmoduleList = &gsdml.SubmoduleList{SubmoduleItems: []*gsdml.SubmoduleItem{ + {ID: "SM_WIDE", SubmoduleIdentNumber: "0x00000042", MayIssueProcessAlarm: "false", ModuleInfo: info(), + IOData: &gsdml.IOData{Input: &gsdml.Input{DataItems: []*gsdml.DataItem{{DataType: "Unsigned32", TextID: text}}}}}, + {ID: "SM_ALT", SubmoduleIdentNumber: "0x00000043", MayIssueProcessAlarm: "false", ModuleInfo: info(), + IOData: &gsdml.IOData{Output: &gsdml.Output{DataItems: []*gsdml.DataItem{{DataType: "Unsigned16", TextID: text}}}}}, + }} + items[0x40].UseableSubmodules = &gsdml.UseableSubmodules{SubmoduleItemRefs: []*gsdml.SubmoduleItemRef{ + {SubmoduleItemTarget: "SM_WIDE", AllowedInSubslots: "2..3", UsedInSubslots: "2"}, + {SubmoduleItemTarget: "SM_ALT", AllowedInSubslots: "2..3"}}} + if inSlot1 { + items[0x10].UseableSubmodules = &gsdml.UseableSubmodules{SubmoduleItemRefs: []*gsdml.SubmoduleItemRef{ + {SubmoduleItemTarget: "SM_WIDE", AllowedInSubslots: "2", UsedInSubslots: "2"}}} + } + dap := ap.DeviceAccessPointList.DeviceAccessPointItems[0] + dap.PhysicalSlots = "0..5" + for _, ref := range dap.UseableModules.ModuleItemRefs { + if ref.ModuleItemTarget == items[0x40].ID { + ref.AllowedInSlots = "3..5" + } + } + return doc +} + +func docFile(t *testing.T, name string, doc *gsdml.Document) string { + t.Helper() b, err := gsdml.Marshal(doc) if err != nil { t.Fatal(err) } - return writeFile(t, "omitted.xml", b) + return writeFile(t, name, b) } -// A module the catalog leaves out: gsdml modules lists it apart with why, -// and --plug of it fails with that reason (unsupported_gsdml), in connect -// and plan, with and without --plug-any-slot. -func TestOmittedModule(t *testing.T) { +// configModel is the model gsdml config resolves, as JSON gives it. +func configModel(t *testing.T, n *testNet, args ...string) configResult { + t.Helper() + var r configResult + n.json(&r, append([]string{"gsdml", "config"}, args...)...) + return r +} + +func slotOf(r configResult, slot uint16) (configSlot, bool) { + for _, s := range r.Slots { + if s.Slot == slot { + return s, true + } + } + return configSlot{}, false +} + +func subslotsOf(s configSlot) string { + var b []string + for _, sm := range s.Submodules { + b = append(b, strings.TrimSpace(sm.ID+"@"+string(rune('0'+sm.Subslot)))) + } + return strings.Join(b, " ") +} + +// gsdml modules lists a module with configurable submodules among the +// usable ones, with their number; gsdml config shows the default +// configuration, what --plug and --plug-submodule make of it, and the +// choices. +func TestGSDMLConfig(t *testing.T) { t.Parallel() n := newTestNet(t) - n.device("dev-a", "192.168.0.10") - gf := omittedGSDMLFile(t) + gf := docFile(t, "configurable.xml", configurableDoc(t, false)) var mods modulesResult n.json(&mods, "gsdml", "modules", gf) - if len(mods.Modules) != 3 || len(mods.Omitted) != 1 || mods.Omitted[0].IdentNumber != 0x40 || mods.Omitted[0].ID == "" || - !strings.Contains(mods.Omitted[0].Reason, "configurable submodule SM_CHANNEL") { + if len(mods.Modules) != 4 || len(mods.Omitted) != 0 { t.Fatalf("modules %+v", mods) } for _, m := range mods.Modules { - if m.IdentNumber == 0x40 { - t.Fatalf("0x40 among the usable modules: %+v", mods) + if m.Configurable != map[uint32]int{0x40: 2}[m.IdentNumber] { + t.Fatalf("module %+v", m) + } + if m.IdentNumber == 0x40 && (m.Submodules != 2 || m.InputLen != 20) { + t.Fatalf("0x40 with its default %+v", m) + } + } + if out := n.ok("gsdml", "modules", gf); !strings.Contains(out, "2 submodule(s), 2 configurable, 20 in / 0 out octets") { + t.Fatalf("text:\n%s", out) + } + // The default configuration: the plugged modules, no choices but the + // DAP's (none). + r := configModel(t, n, gf) + if len(r.Slots) != 4 || len(r.Choices) != 0 { + t.Fatalf("default %+v", r) + } + // Module 0x40 in slot 4: SM_WIDE in subslot 2 by default; SM_ALT + // chosen in subslot 3, by ID and by ident number; subslot 2 cleared. + r = configModel(t, n, gf, "--plug", "4=0x40") + if s, _ := slotOf(r, 4); s.IdentNumber != 0x40 || subslotsOf(s) != "@1 SM_WIDE@2" || len(r.Choices) != 2 || r.Choices[1].ID != "SM_ALT" || r.Choices[1].Allowed != "2..3" { + t.Fatalf("plugged %+v", r) + } + for _, alt := range []string{"SM_ALT", "0x43"} { + r = configModel(t, n, gf, "--plug", "4=0x40", "--plug-submodule", "4:3="+alt, "--plug-submodule", "4:2=-") + if s, _ := slotOf(r, 4); subslotsOf(s) != "@1 SM_ALT@3" { + t.Fatalf("%s: %+v", alt, s) + } + } + out := n.ok("gsdml", "config", gf, "--plug", "4=0x40") + if !strings.Contains(out, "slot 4 0x00000040") || !strings.Contains(out, "[SM_WIDE]") || !strings.Contains(out, "configurable submodules (--plug-submodule SLOT:SUBSLOT=ID):") || + !strings.Contains(out, "slot 4 SM_ALT 0x00000043") || !strings.Contains(out, "(allowed 2..3, used 2)") { + t.Fatalf("text:\n%s", out) + } + if out := n.ok("gsdml", "config", gf); !strings.Contains(out, "no configurable submodules") { + t.Fatalf("text without choices:\n%s", out) + } + if out := n.ok("gsdml", "config", gf, "--plug", "4=0x40", "-o", "table"); !strings.Contains(out, "SM_WIDE") || !strings.Contains(out, "SUBMODULE") { + t.Fatalf("table:\n%s", out) + } + // Choices the file does not allow, and flags that do not parse. + for _, tc := range []struct { + code string + args []string + contains string + }{ + {"invalid_input", []string{"--plug", "4=0x40", "--plug-submodule", "4:5=SM_ALT"}, "not allowed in subslot 5"}, + {"invalid_input", []string{"--plug", "4=0x40", "--plug-submodule", "4:2=SM_NONE"}, "SM_NONE"}, + {"invalid_input", []string{"--plug-submodule", "4:2=SM_ALT"}, "slot 4 holds no module"}, + {"invalid_input", []string{"--plug", "3=0x40"}, "fixed there"}, + {"invalid_input", []string{"--plug", "4=0x99"}, "0x00000099"}, + {"invalid_input", []string{"--plug", "x"}, "want SLOT=IDENT"}, + {"invalid_input", []string{"--plug-submodule", "4=SM_ALT"}, "want SLOT:SUBSLOT=SUBMODULE"}, + {"invalid_input", []string{"--plug-submodule", "4:0=SM_ALT"}, "want SLOT:SUBSLOT=SUBMODULE"}, + {"invalid_input", []string{"--plug-submodule", "4:2="}, "want SLOT:SUBSLOT=SUBMODULE"}, + } { + if msg := n.fails(3, tc.code, append([]string{"gsdml", "config", gf}, tc.args...)...); !strings.Contains(msg, tc.contains) { + t.Fatalf("%v: %s", tc.args, msg) + } + } + n.fails(3, "input_file_open_failed", "gsdml", "config", "/no/such/file.xml") +} + +// Two submodules with one ident number: --plug-submodule needs the ID. +func TestPlugSubmoduleAmbiguousIdent(t *testing.T) { + t.Parallel() + n := newTestNet(t) + doc := configurableDoc(t, false) + doc.ProfileBody.ApplicationProcess.SubmoduleList.SubmoduleItems[1].SubmoduleIdentNumber = "0x00000042" + gf := docFile(t, "ambiguous.xml", doc) + if msg := n.fails(3, "invalid_input", "gsdml", "config", gf, "--plug", "4=0x40", "--plug-submodule", "4:3=0x42"); !strings.Contains(msg, "SM_WIDE and SM_ALT have SubmoduleIdentNumber 0x00000042: give the ID") { + t.Fatal(msg) + } + r := configModel(t, n, gf, "--plug", "4=0x40", "--plug-submodule", "4:3=SM_ALT") + // Which submodule is in a subslot shows in its IO data: gsdml config + // names neither, as both have the ident number. + if s, _ := slotOf(r, 4); subslotsOf(s) != "@1 @2 @3" || s.Submodules[1].InputLen != 4 || s.Submodules[2].OutputLen != 2 { + t.Fatalf("%+v", s) + } +} + +// connect and plan build the model with the configuration for +// --plug-submodule and for a --plug of a module with configurable +// submodules; the AR runs against a device of that model. +func TestConnectPlugSubmodule(t *testing.T) { + t.Parallel() + n := newTestNet(t) + doc := configurableDoc(t, false) + gf := docFile(t, "configurable.xml", doc) + c, err := gsdml.NewConfiguration(doc, "") + if err != nil { + t.Fatal(err) + } + if err := c.PlugIdent(4, 0x40); err != nil { + t.Fatal(err) + } + if err := c.Select(4, 3, "SM_ALT"); err != nil { + t.Fatal(err) + } + m, err := c.Resolve() + if err != nil { + t.Fatal(err) + } + n.device("dev-c", "192.168.0.11", func(cfg *device.Config) { cfg.Model = m }) + out := n.ok("-i", "pn0", "connect", "-s", "dev-c", "--gsdml", gf, "--plug", "4=0x40", "--plug-submodule", "4:3=SM_ALT", + "--output", "4:3:0102", "--duration", "500ms") + if !strings.Contains(out, "summary: state Running") || !strings.Contains(out, "input slot 4 subslot 0x0002") || strings.Contains(out, "module_diff") { + t.Fatalf("connect:\n%s", out) + } + // --plug of the module alone takes the configuration too; the plan + // writes the record of slot 2. + for _, extra := range [][]string{nil, {"--plug-submodule", "4:3=SM_ALT"}} { + var p planResult + n.json(&p, append([]string{"gsdml", "plan", gf, "--plug", "4=0x40", "--param-defaults"}, extra...)...) + if !p.Planned || len(p.Writes) != 1 || p.Writes[0].Slot != 2 || p.Writes[0].Index != 0x10 { + t.Fatalf("plan %v: %+v", extra, p) + } + } + // The configuration plugs only where the file allows: no + // --plug-any-slot; a model in JSON has no configurable submodules. + if msg := n.fails(2, "invalid_flag_combination", "-i", "pn0", "connect", "-s", "dev-c", "--gsdml", gf, "--plug", "4=0x40", "--plug-any-slot"); !strings.Contains(msg, "--plug-any-slot") { + t.Fatal(msg) + } + if msg := n.fails(2, "invalid_flag_combination", "-i", "pn0", "connect", "-s", "dev-c", "--model", modelFile(t), "--plug-submodule", "1:2=SM_WIDE"); !strings.Contains(msg, "needs --gsdml") { + t.Fatal(msg) + } + if msg := n.fails(3, "invalid_input", "gsdml", "plan", gf, "--plug", "4=0x40", "--plug-submodule", "4:9=SM_ALT"); !strings.Contains(msg, "--plug-submodule") { + t.Fatal(msg) + } + // Without configurable submodules, --plug-any-slot keeps ToModel's + // model, as before. + if msg := n.fails(3, "invalid_input", "-i", "pn0", "connect", "-s", "dev-c", "--gsdml", gf, "--plug", "9=0x30"); !strings.Contains(msg, "--plug-any-slot plugs it anyway") { + t.Fatal(msg) + } +} + +// A device access point gsdml.ToModel refuses for a configurable +// submodule in a plugged module: its default configuration is the model +// of gsdml modules, gsdml submodules and connect. +func TestRefusedDAPDefaultConfiguration(t *testing.T) { + t.Parallel() + n := newTestNet(t) + doc := configurableDoc(t, true) + if _, err := gsdml.ToModel(doc, ""); err == nil { + t.Fatal("ToModel converts it") + } + gf := docFile(t, "refused.xml", doc) + var mods modulesResult + n.json(&mods, "gsdml", "modules", gf) + if len(mods.Modules) != 4 || mods.Modules[0].Configurable != 1 || mods.Modules[0].InputLen != 12 { + t.Fatalf("modules %+v", mods) + } + var subs submodulesResult + n.json(&subs, "gsdml", "submodules", gf, "--module", "0x10") + if len(subs.Submodules) != 2 || subs.Submodules[1].IdentNumber != 0x42 { + t.Fatalf("submodules %+v", subs) + } + c, err := gsdml.NewConfiguration(doc, "") + if err != nil { + t.Fatal(err) + } + m, err := c.Resolve() + if err != nil { + t.Fatal(err) + } + n.device("dev-r", "192.168.0.12", func(cfg *device.Config) { cfg.Model = m }) + if out := n.ok("-i", "pn0", "connect", "-s", "dev-r", "--gsdml", gf, "--duration", "500ms"); !strings.Contains(out, "summary: state Running") || !strings.Contains(out, "input slot 1 subslot 0x0002") { + t.Fatalf("connect:\n%s", out) + } + // inspect and check convert it as --gsdml does. + var ins inspectResult + n.json(&ins, "gsdml", "inspect", gf) + if len(ins.DAPs) != 1 || ins.DAPs[0].Error != "" || ins.DAPs[0].PlugSlots != 3 || ins.DAPs[0].Modules != 4 { + t.Fatalf("inspect %+v", ins.DAPs) + } + var chk checkResult + out, _, _ := n.run("gsdml", "check", gf, "--format", "json") + decode(t, out, &chk) + for _, i := range chk.Issues { + if i.Rule == ruleModel { + t.Fatalf("check %+v", i) } } + // A subslot the default fills, left empty, is a choice: the model is + // that of the file without it. + r := configModel(t, n, gf, "--plug-submodule", "1:2=-") + if s, _ := slotOf(r, 1); subslotsOf(s) != "@1" { + t.Fatalf("%+v", s) + } +} + +// A default configuration that needs a choice (two submodules used in +// one subslot): --gsdml says how to choose, check reports it unvalidated, +// and --plug-submodule makes the choice. +func TestDefaultConfigurationNeedsChoice(t *testing.T) { + t.Parallel() + n := newTestNet(t) + doc := configurableDoc(t, true) + for _, mi := range doc.ProfileBody.ApplicationProcess.ModuleList.ModuleItems { + if mi.UseableSubmodules != nil && len(mi.UseableSubmodules.SubmoduleItemRefs) == 1 { + mi.UseableSubmodules.SubmoduleItemRefs = append(mi.UseableSubmodules.SubmoduleItemRefs, + &gsdml.SubmoduleItemRef{SubmoduleItemTarget: "SM_ALT", AllowedInSubslots: "2", UsedInSubslots: "2"}) + } + } + gf := docFile(t, "choice.xml", doc) + if msg := n.fails(3, "invalid_input", "gsdml", "modules", gf); !strings.Contains(msg, "--plug-submodule SLOT:SUBSLOT=ID chooses one") { + t.Fatal(msg) + } + if msg := n.fails(3, "invalid_input", "-i", "pn0", "connect", "-s", "x", "--gsdml", gf, "--duration", "100ms"); !strings.Contains(msg, "SM_WIDE") { + t.Fatal(msg) + } + var chk checkResult + out, _, _ := n.run("gsdml", "check", gf, "--format", "json") + decode(t, out, &chk) + found := false + for _, i := range chk.Issues { + if i.Rule == ruleModel { + found = i.Severity == gsdml.SeverityUnvalidated + } + } + if !found { + t.Fatalf("check %+v", chk.Issues) + } + var ins inspectResult + n.json(&ins, "gsdml", "inspect", gf) + if ins.DAPs[0].Error == "" { + t.Fatalf("inspect %+v", ins.DAPs) + } + r := configModel(t, n, gf, "--plug-submodule", "1:2=SM_ALT") + if s, _ := slotOf(r, 1); subslotsOf(s) != "@1 SM_ALT@2" { + t.Fatalf("%+v", s) + } +} + +// A module whose configurable submodule the file does not define: gsdml +// modules lists it apart with why, and --plug of it fails, in connect and +// plan. +func TestOmittedModule(t *testing.T) { + t.Parallel() + n := newTestNet(t) + n.device("dev-a", "192.168.0.10") + doc := configurableDoc(t, false) + doc.ProfileBody.ApplicationProcess.SubmoduleList = nil + gf := docFile(t, "omitted.xml", doc) + var mods modulesResult + n.json(&mods, "gsdml", "modules", gf) + if len(mods.Modules) != 3 || len(mods.Omitted) != 1 || mods.Omitted[0].IdentNumber != 0x40 || mods.Omitted[0].ID == "" || !strings.Contains(mods.Omitted[0].Reason, "SM_WIDE") { + t.Fatalf("modules %+v", mods) + } if out := n.ok("gsdml", "modules", gf); !strings.Contains(out, "3 module(s) usable") || !strings.Contains(out, "1 module(s) of the file not in the catalog (cannot be plugged):") || !strings.Contains(out, "0x00000040 "+mods.Omitted[0].ID+": ") { t.Fatalf("text:\n%s", out) @@ -62,26 +363,19 @@ func TestOmittedModule(t *testing.T) { if out := n.ok("gsdml", "modules", gf, "-o", "table"); !strings.Contains(out, "omitted") { t.Fatalf("table:\n%s", out) } - // The file without it lists none. + // The file without configurable submodules lists none. var plain modulesResult n.json(&plain, "gsdml", "modules", gsdmlFile(t)) if len(plain.Omitted) != 0 { t.Fatalf("plain %+v", plain) } - base := []string{"-i", "pn0", "connect", "-s", "dev-a", "--gsdml", gf, "--duration", "100ms"} - for _, extra := range [][]string{nil, {"--plug-any-slot"}} { - msg := n.fails(3, "unsupported_gsdml", append(append(append([]string{}, base...), "--plug", "3=0x40"), extra...)...) - if !strings.Contains(msg, `--plug "3=0x40": module `+mods.Omitted[0].ID+` (0x00000040) is not in the catalog`) || !strings.Contains(msg, "configurable submodule SM_CHANNEL") { - t.Fatalf("connect %v: %s", extra, msg) - } + base := []string{"-i", "pn0", "connect", "-s", "dev-a", "--gsdml", gf, "--duration", "100ms", "--plug", "4=0x40"} + if msg := n.fails(3, "invalid_gsdml", base...); !strings.Contains(msg, "SM_WIDE") { + t.Fatalf("connect: %s", msg) } - if msg := n.fails(3, "unsupported_gsdml", "gsdml", "plan", gf, "--plug", "3=0x40"); !strings.Contains(msg, "is not in the catalog") { + if msg := n.fails(3, "", "gsdml", "plan", gf, "--plug", "4=0x40"); !strings.Contains(msg, "SM_WIDE") { t.Fatalf("plan: %s", msg) } - // An ident the file does not have stays unknown. - if msg := n.fails(3, "invalid_input", append(append([]string{}, base...), "--plug", "3=0x99")...); !strings.Contains(msg, "no module type with ident number 0x00000099") { - t.Fatalf("unknown: %s", msg) - } } // omittedModules picks the named device access point, and none without a @@ -99,3 +393,66 @@ func TestOmittedModulesOf(t *testing.T) { t.Fatalf("%+v", got) } } + +// with0x40 is configurableDoc with the references of module 0x40 replaced. +func with0x40(t *testing.T, refs ...*gsdml.SubmoduleItemRef) *gsdml.Document { + t.Helper() + doc := configurableDoc(t, false) + for _, mi := range doc.ProfileBody.ApplicationProcess.ModuleList.ModuleItems { + if mi.UseableSubmodules != nil { + mi.UseableSubmodules.SubmoduleItemRefs = refs + } + } + return doc +} + +// Why gsdml modules leaves a module out: the module's own error, a +// submodule's, or a subslot two submodules are used in by default. +func TestOmittedModuleReasons(t *testing.T) { + t.Parallel() + n := newTestNet(t) + for _, tc := range []struct { + name string + refs []*gsdml.SubmoduleItemRef + reason string + }{ + {"on a built-in subslot", []*gsdml.SubmoduleItemRef{{SubmoduleItemTarget: "SM_WIDE", FixedInSubslots: "1"}}, "built-in"}, + {"two defaults", []*gsdml.SubmoduleItemRef{{SubmoduleItemTarget: "SM_WIDE", AllowedInSubslots: "2..3", UsedInSubslots: "2"}, + {SubmoduleItemTarget: "SM_ALT", AllowedInSubslots: "2..3", UsedInSubslots: "2"}}, "configurable submodules SM_WIDE and SM_ALT are both used in subslot 2 by default"}, + } { + gf := docFile(t, "reason.xml", with0x40(t, tc.refs...)) + var mods modulesResult + n.json(&mods, "gsdml", "modules", gf) + if len(mods.Omitted) != 1 || mods.Omitted[0].IdentNumber != 0x40 || !strings.Contains(mods.Omitted[0].Reason, tc.reason) { + t.Fatalf("%s: %+v", tc.name, mods.Omitted) + } + } +} + +// A configurable submodule go-profinet cannot convert is listed with why +// and refused as invalid_gsdml; an ident number no configurable submodule +// has is unknown; --plug of a model in JSON still parses. +func TestPlugSubmoduleErrors(t *testing.T) { + t.Parallel() + n := newTestNet(t) + doc := with0x40(t, &gsdml.SubmoduleItemRef{SubmoduleItemTarget: "SM_WIDE", AllowedInSubslots: "2..3", UsedInSubslots: "2"}, + &gsdml.SubmoduleItemRef{SubmoduleItemTarget: "SM_BAD", AllowedInSubslots: "3"}) + sl := doc.ProfileBody.ApplicationProcess.SubmoduleList + bad := *sl.SubmoduleItems[1] + bad.ID, bad.SubmoduleIdentNumber = "SM_BAD", "0x00000044" + bad.RecordDataList = &gsdml.RecordDataList{ParameterRecordDataItems: []*gsdml.ParameterRecordDataItem{{Index: "x", Length: "1", Name: bad.ModuleInfo.Name}}} + sl.SubmoduleItems = append(sl.SubmoduleItems, &bad) + gf := docFile(t, "bad.xml", doc) + if out := n.ok("gsdml", "config", gf, "--plug", "4=0x40"); !strings.Contains(out, "SM_BAD") || !strings.Contains(out, ": cannot be placed: ") { + t.Fatalf("text:\n%s", out) + } + if msg := n.fails(3, "invalid_gsdml", "gsdml", "config", gf, "--plug", "4=0x40", "--plug-submodule", "4:3=SM_BAD"); !strings.Contains(msg, `--plug-submodule "4:3=SM_BAD"`) { + t.Fatal(msg) + } + if msg := n.fails(3, "invalid_input", "gsdml", "config", gf, "--plug", "4=0x40", "--plug-submodule", "4:3=0x99"); !strings.Contains(msg, "0x99") { + t.Fatal(msg) + } + if msg := n.fails(3, "invalid_input", "-i", "pn0", "connect", "-s", "x", "--model", modelFile(t), "--plug", "x"); !strings.Contains(msg, "want SLOT=IDENT") { + t.Fatal(msg) + } +} diff --git a/cmd/plan.go b/cmd/plan.go index e64657d..ef8a4e3 100644 --- a/cmd/plan.go +++ b/cmd/plan.go @@ -275,15 +275,16 @@ func (r planResult) Partial() bool { return !r.Planned } func newGSDMLPlanCmd(a *app) *cobra.Command { var dap string - var plugs, values []string + var plugs, plugSubs, values []string var slots []uint var defaults bool c := &cobra.Command{ - Use: "plan FILE [--plug SLOT=IDENT]... [--param-value SLOT:SUBSLOT:INDEX:FIELD=VALUE]... [--param-defaults]", + Use: "plan FILE [--plug SLOT=IDENT]... [--plug-submodule SLOT:SUBSLOT=SUBMODULE]... [--param-value SLOT:SUBSLOT:INDEX:FIELD=VALUE]... [--param-defaults]", Short: "Show the parameter records an AR would write, from the GSDML file and chosen values; sends nothing", Long: `Build the parameter plan of a device configuration with go-profinet's PlanParameters, and show it without sending anything: the parameter records an -AR with the same --gsdml, --dap, --plug, --slot, --param-value and --param-defaults +AR with the same --gsdml, --dap, --plug, --plug-submodule, --slot, --param-value +and --param-defaults writes before PrmEnd, in the order it writes them, and the issues of the records. @@ -305,17 +306,10 @@ after the planned ones, as given.`, Args: cobra.ExactArgs(1), RunE: func(c *cobra.Command, args []string) error { return a.result(c, func(ctx context.Context) (any, error) { - m, doc, err := loadModelDoc(args[0], dap, "") + m, doc, err := buildModel(args[0], dap, "", modelChoices{plugs: plugs, subs: plugSubs}) if err != nil { return nil, err } - var omitted []omittedModule - if len(plugs) > 0 { - omitted = omittedModules(doc, dap) - } - if err := plug(m, plugs, slotRulesOf(doc, dap), omitted); err != nil { - return nil, err - } if m, err = withSlots(m, slots); err != nil { return nil, err } @@ -347,6 +341,7 @@ after the planned ones, as given.`, } f := c.Flags() f.StringVar(&dap, "dap", "", "Device access point ID (default: the first)") + f.StringArrayVar(&plugSubs, "plug-submodule", nil, plugSubmoduleUsage) f.StringArrayVar(&plugs, "plug", nil, "Plug the module with this ident number from the GSDML catalog: SLOT=IDENT (repeatable), in a slot the GSDML file allows it in") f.UintSliceVar(&slots, "slot", nil, "Only these slots besides the DAP, as the AR commands' --slot (shared device); repeatable or comma-separated") addPlanFlags(f, &values, &defaults) diff --git a/cmd/roadmap.go b/cmd/roadmap.go index 2704fc3..e7b7ef2 100644 --- a/cmd/roadmap.go +++ b/cmd/roadmap.go @@ -91,7 +91,7 @@ type checkResult struct { const checkScope = ", go-profinet's semantic rules (IO data length, slots, record indexes, ident numbers, subslots, reduction ratios, parameter records and their TransferSequence) and the conversion of the first 64 device access points to a model; not PI's GSDML checker" // ruleModel is the rule of a device access point that does not convert to -// a model (gsdml.ToModel), so that --gsdml with its ID fails. +// a model (defaultModel), so that --gsdml with its ID and no choices fails. const ruleModel = "model" // pathID quotes an ID in an issue path as go-profinet's Check does: the @@ -132,9 +132,11 @@ func modelIssues(ctx context.Context, doc *gsdml.Document) ([]gsdml.Issue, error if err := interrupted(ctx); err != nil { return nil, err } - if _, err := gsdml.ToModel(doc, d.ID); err != nil { + if _, err := defaultModel(doc, d.ID); err != nil { sev := gsdml.SeverityError - if errors.Is(err, profinet.ErrUnsupported) { + // What go-profinet does not support, or a configuration that + // needs a choice (--plug-submodule), is no fault of the file. + if errors.Is(err, profinet.ErrUnsupported) || errors.Is(err, profinet.ErrInvalidConfig) && !errors.Is(err, profinet.ErrMalformed) { sev = gsdml.SeverityUnvalidated } out = append(out, gsdml.Issue{ diff --git a/docs/exitcodes.md b/docs/exitcodes.md index 6eb59ec..9c723df 100644 --- a/docs/exitcodes.md +++ b/docs/exitcodes.md @@ -22,7 +22,7 @@ | `kind` | `code` values | |--------|---------------| | `usage` | `invalid_input`, `invalid_flag_combination`, `confirmation_required` | -| `invalid_input` | `invalid_input`, `invalid_format`, `invalid_flag_combination`, `invalid_gsdml`, `unsupported_gsdml` (a document type declaration with an internal subset, a file naming no schema version go-profinet has, for `gsdml schema validate` and `gsdml schema dump` without `--version`, a float value JSON cannot represent (INF, -INF or NaN) for `gsdml schema dump`, a Ref DefaultValue of a DataType whose encoding go-profinet does not know, a device access point or plugged module that needs a configurable submodule (`UseableSubmodules` with `FixedInSubslots` or `UsedInSubslots`), a `--plug` of a module the catalog leaves out for one: the file may be valid), `invalid_model`, `input_file_open_failed`, `output_file_create_failed`, `interface_open_failed` (no such interface) | +| `invalid_input` | `invalid_input`, `invalid_format`, `invalid_flag_combination`, `invalid_gsdml`, `unsupported_gsdml` (a document type declaration with an internal subset, a file naming no schema version go-profinet has, for `gsdml schema validate` and `gsdml schema dump` without `--version`, a float value JSON cannot represent (INF, -INF or NaN) for `gsdml schema dump`, a Ref DefaultValue of a DataType whose encoding go-profinet does not know, a configurable submodule go-profinet cannot place, such as a `PortSubmoduleItem` in a module: the file may be valid), `invalid_model`, `input_file_open_failed`, `output_file_create_failed`, `interface_open_failed` (no such interface) | | `transport` | `interface_open_failed`, `socket_failed` | | `timeout` | `request_timeout`, `connect_failed` | | `refused` | `pnio_error` (the message names the status: ErrorCode, ErrorDecode, ErrorCode1, ErrorCode2), `dcp_block_error`, `connect_failed`, `duplicate_station_name`, `invalid_input` (no IP address) | @@ -34,6 +34,8 @@ | `output` | `table_render_failed`, `output_write_failed`, `output_file_write_failed` | | `internal` | `internal_unexpected` | +Configurations (`--plug`, `--plug-submodule`, `gsdml config`): a `--plug` or `--plug-submodule` the GSDML file does not allow (a slot or subslot outside its lists, a module or submodule it fixes there, an unknown ID or ident number) and a default configuration that needs a choice (two submodules used in one subslot by default) are `invalid_input` (exit 3); `--plug-any-slot` with a configuration of configurable submodules and `--plug-submodule` with `--model` are `invalid_flag_combination` (exit 2). + **Partial exit:** only after a success payload was written. A failure to open the interface, to resolve the device or to write the result is fatal and uses the codes above, never `7`. `im write` is partial only when a record fails after others were written: when the first record fails, nothing was written and its error is fatal; an interruption stays `130`. **Streaming commands:** `connect`, `alarms`, `io monitor` and `hello listen` write one record at a time. `--duration` or Ctrl-C (SIGINT) and SIGTERM end the stream normally with exit code 0: the AR is released, and `connect` writes its summary. A failure before the AR runs is fatal. diff --git a/docs/json-output.md b/docs/json-output.md index 67bc6a8..d590002 100644 --- a/docs/json-output.md +++ b/docs/json-output.md @@ -44,7 +44,8 @@ These conventions are a **stable contract** for scripting. Field names are snake | `gsdml schema dump` | `{"file", "schema_version", "validated", "document"}`; `document` is the root element `ISO15745Profile` with the elements and attributes the file has, under the schema's names (absent optional ones are left out), in the schema's order; numeric and boolean types are JSON numbers and booleans, `xsd:integer` and `xsd:decimal` strings; `validated` is false with `--no-validate` | | `disconnect` | `{"station", "ar_uuid"}` | | `gsdml plan` | `{"file", "dap", "planned", "writes": [{"api", "slot", "subslot", "index", "name", "module_ident_number", "submodule_ident_number", "transfer_sequence", "values", "length", "data"}], "errors", "warnings", "unvalidated", "issues": [{"path", "line", "message", "severity", "rule"}]}`; `writes` in the order an AR writes them, `api` the API of the write's submodule in the plugged configuration, `data` the record in hex, `values` the number of fields `--param-value` set in it (0: defaults only), `transfer_sequence` 0 when the file gives none; `planned` is false when go-profinet refused the plan for the errors in `issues` (`writes` is then empty, exit code 7); `severity` is `"error"`, `"warning"` or `"unvalidated"` | -| `gsdml modules`, `gsdml submodules` | `{"dap", "modules": [...], "omitted_modules": [...]}`, `{"dap", "submodules": [...]}`; an omitted module (one the file lets the DAP use that needs a configurable submodule, so not in the catalog and refused by `--plug`) has `id`, `ident_number`, `reason`, and the key is absent when there is none; a submodule has `module`, `module_ident_number`, `name`, `ident_number`, `api`, `subslot`, `input_length`, `output_length`, `records` | +| `gsdml modules`, `gsdml submodules` | `{"dap", "modules": [...], "omitted_modules": [...]}`, `{"dap", "submodules": [...]}`; a module has `name`, `ident_number`, `plugged_in_slots`, `submodules`, `input_length`, `output_length`, `info` and `configurable_submodules` (the number of configurable submodules it can choose, absent for none; `submodules` and the lengths are its default configuration's); an omitted module (one the file lets the DAP use that go-profinet cannot place, refused by `--plug`) has `id`, `ident_number`, `reason`, and the key is absent when there is none; a submodule has `module`, `module_ident_number`, `name`, `ident_number`, `api`, `subslot`, `input_length`, `output_length`, `records` | +| `gsdml config` | `{"dap", "slots": [{"slot", "module", "ident_number", "submodules": [{"subslot", "name", "ident_number", "api", "input_length", "output_length", "records", "id"}]}], "choices": [{"slot", "module", "id", "name", "ident_number", "port", "allowed_in_subslots", "fixed_in_subslots", "used_in_subslots", "error"}]}`; slot 0 is the DAP; a submodule's `id` is the SubmoduleItem of a configurable submodule (absent for a built-in one, or when two configurable submodules with its ident number allow its subslot); `choices` are the configurable submodules of the DAP and of each plugged module (`module` is the module reference's ID, the DAP's name for slot 0), `error` (absent when none) why one cannot be placed; `port`, the subslot lists and `error` are absent when empty | | `ar` | `{"station", "mac", "ip", "ar": {"ar_uuid", "session_key", "ar_type", "rt_class", "advanced", "device_address", "local_alarm_ref", "remote_alarm_ref", "input": iocr, "output": iocr}, "module_diff", "differences"}`; an iocr has `frame_id`, `data_length`, `send_clock_factor`, `reduction_ratio`, `watchdog_factor`, `data_hold_factor`, `cycle_ms` | | `iocr` | `{"ar_uuid", "entries": [{"iocr", "frame_id", "kind": "data" \| "iocs", "slot", "subslot", "offset", "length"}]}` | | `io status` | `{"station", "state", "inputs": [{"slot", "subslot", "data", "iops"}], "outputs": [{"slot", "subslot", "iocs"}]}`; a status is `"good"`, `"bad (0x..)"` or `"-"` (not received yet) | diff --git a/go.mod b/go.mod index 008c88f..856e9f1 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/otfabric/profinetctl go 1.26 require ( - github.com/otfabric/go-profinet v0.23.0 + github.com/otfabric/go-profinet v0.24.0 github.com/spf13/cobra v1.10.2 github.com/spf13/pflag v1.0.10 ) diff --git a/go.sum b/go.sum index 20dfbd1..8b78940 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,8 @@ github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= -github.com/otfabric/go-profinet v0.23.0 h1:e87rkqdopUdSPEo1ig2TGe+EIhpPaMNYeRWykjMnrmU= -github.com/otfabric/go-profinet v0.23.0/go.mod h1:eLxHQxabRs/OloPKSXKo/0OOgMjwjJUwnkQstdfE2wI= +github.com/otfabric/go-profinet v0.24.0 h1:BRGixSpB2TDKFm49Txw4aHEL/+X9Zg1HtMeod1aFogQ= +github.com/otfabric/go-profinet v0.24.0/go.mod h1:eLxHQxabRs/OloPKSXKo/0OOgMjwjJUwnkQstdfE2wI= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/spf13/cobra v1.10.2 h1:DMTTonx5m65Ic0GOoRY2c16WCbHxOOw6xxezuLaBpcU= github.com/spf13/cobra v1.10.2/go.mod h1:7C1pvHqHw5A4vrJfjNwvOdzYu0Gml16OCs2GRiTUUS4=