MCPcopy Create free account
hub / github.com/ForestHubAI/edge-agents / Execute

Method Execute

go/engine/node/serialread.go:48–65  ·  view source on GitHub ↗
(ctx context.Context, scope *engine.Scope)

Source from the content-addressed store, hash-verified

46}
47
48func (r *SerialRead) Execute(ctx context.Context, scope *engine.Scope) (string, error) {
49 if err := r.uart.Flush(); err != nil {
50 return "", fmt.Errorf("serialRead %s: flushing input: %w", r.ID(), err)
51 }
52 if r.prompt != "" {
53 if err := r.uart.Write(r.prompt); err != nil {
54 return "", fmt.Errorf("serialRead %s: writing prompt: %w", r.ID(), err)
55 }
56 }
57 line, err := r.uart.Read(ctx)
58 if err != nil {
59 return "", fmt.Errorf("serialRead %s: %w", r.ID(), err)
60 }
61 if err := engine.ApplyOutput(scope, r.ID(), serialReadOutID, r.binding, expr.StringVal(line)); err != nil {
62 return "", fmt.Errorf("serialRead %s: applying output: %w", r.ID(), err)
63 }
64 return r.Next(engine.PortCtrl, scope)
65}
66
67// Outputs declares the single "output" slot — a string line. Returns it only
68// if the binding is emit-mode (assign/discard don't materialize a variable).

Callers

nothing calls this directly

Calls 5

NextMethod · 0.80
FlushMethod · 0.65
IDMethod · 0.65
WriteMethod · 0.65
ReadMethod · 0.65

Tested by

no test coverage detected