Debian Codegraph @

dummy-monitor/dummy_port.go

raw symbols SCIP
1 // This file is part of dummy-monitor.
2 //
3 // SPDX-FileCopyrightText: Arduino s.r.l. and/or its affiliated companies
4 // SPDX-License-Identifier: GPL-3.0-or-later
5
6 package mainscip-go gomod github.com/arduino/pluggable-monitor-protocol-handler . `github.com/arduino/pluggable-monitor-protocol-handler/dummy-monitor`/
7
8 import (
9 "ioscip-go gomod github.com/golang/go/src go1.16 io/"
10 )
11
12 type dummyPortscip-go gomod github.com/arduino/pluggable-monitor-protocol-handler . `github.com/arduino/pluggable-monitor-protocol-handler/dummy-monitor`/dummyPort# struct {
13 echoscip-go gomod github.com/arduino/pluggable-monitor-protocol-handler . `github.com/arduino/pluggable-monitor-protocol-handler/dummy-monitor`/dummyPort#echo. chan string
14 portNamescip-go gomod github.com/arduino/pluggable-monitor-protocol-handler . `github.com/arduino/pluggable-monitor-protocol-handler/dummy-monitor`/dummyPort#portName. string
15 }
16
17 func newDummyPortscip-go gomod github.com/arduino/pluggable-monitor-protocol-handler . `github.com/arduino/pluggable-monitor-protocol-handler/dummy-monitor`/newDummyPort().(portName string) *dummyPortscip-go gomod github.com/arduino/pluggable-monitor-protocol-handler . `github.com/arduino/pluggable-monitor-protocol-handler/dummy-monitor`/dummyPort# {
18 return &dummyPortscip-go gomod github.com/arduino/pluggable-monitor-protocol-handler . `github.com/arduino/pluggable-monitor-protocol-handler/dummy-monitor`/dummyPort#{
19 echoscip-go gomod github.com/arduino/pluggable-monitor-protocol-handler . `github.com/arduino/pluggable-monitor-protocol-handler/dummy-monitor`/dummyPort#echo.: make(chan string, 20),
20 portNamescip-go gomod github.com/arduino/pluggable-monitor-protocol-handler . `github.com/arduino/pluggable-monitor-protocol-handler/dummy-monitor`/dummyPort#portName.: portName,
21 }
22 }
23
24 func (d *dummyPortscip-go gomod github.com/arduino/pluggable-monitor-protocol-handler . `github.com/arduino/pluggable-monitor-protocol-handler/dummy-monitor`/dummyPort#) Closescip-go gomod github.com/arduino/pluggable-monitor-protocol-handler . `github.com/arduino/pluggable-monitor-protocol-handler/dummy-monitor`/dummyPort#Close().() error {
25 close(d.echoscip-go gomod github.com/arduino/pluggable-monitor-protocol-handler . `github.com/arduino/pluggable-monitor-protocol-handler/dummy-monitor`/dummyPort#echo.)
26 return nil
27 }
28
29 func (d *dummyPortscip-go gomod github.com/arduino/pluggable-monitor-protocol-handler . `github.com/arduino/pluggable-monitor-protocol-handler/dummy-monitor`/dummyPort#) Readscip-go gomod github.com/arduino/pluggable-monitor-protocol-handler . `github.com/arduino/pluggable-monitor-protocol-handler/dummy-monitor`/dummyPort#Read().(p []byte) (int, error) {
30 data, ok := <-d.echoscip-go gomod github.com/arduino/pluggable-monitor-protocol-handler . `github.com/arduino/pluggable-monitor-protocol-handler/dummy-monitor`/dummyPort#echo.
31 if !ok {
32 return 0, ioscip-go gomod github.com/golang/go/src go1.16 io/.EOFscip-go gomod github.com/golang/go/src go1.16 io/EOF.
33 }
34 n := copy(p, []byte(data))
35 // if p is too small data loss may happen.. ¯\_(ツ)_/¯
36 return n, nil
37 }
38
39 func (d *dummyPortscip-go gomod github.com/arduino/pluggable-monitor-protocol-handler . `github.com/arduino/pluggable-monitor-protocol-handler/dummy-monitor`/dummyPort#) Writescip-go gomod github.com/arduino/pluggable-monitor-protocol-handler . `github.com/arduino/pluggable-monitor-protocol-handler/dummy-monitor`/dummyPort#Write().(p []byte) (int, error) {
40 d.echoscip-go gomod github.com/arduino/pluggable-monitor-protocol-handler . `github.com/arduino/pluggable-monitor-protocol-handler/dummy-monitor`/dummyPort#echo. <- string(p)
41 return len(p), nil
42 }