|
18 | 18 | package main |
19 | 19 |
|
20 | 20 | import ( |
21 | | - "errors" |
22 | 21 | "fmt" |
23 | 22 | "os" |
24 | | - "time" |
25 | 23 |
|
26 | 24 | "github.com/arduino/go-properties-orderedmap" |
27 | 25 | monitor "github.com/arduino/pluggable-monitor-protocol-handler" |
@@ -53,94 +51,30 @@ func (d *dummyMonitor) Hello(userAgent string, protocol int) error { |
53 | 51 | return nil |
54 | 52 | } |
55 | 53 |
|
56 | | -// Quit does nothing. |
57 | | -// In a real implementation it can be used to tear down resources |
58 | | -// used to monitor Ports. |
59 | | -func (d *dummyMonitor) Quit() {} |
60 | | - |
61 | 54 | //TODO implement |
62 | | -func (d *dummyMonitor) Describe() { |
63 | | - |
| 55 | +func (d *dummyMonitor) Describe() (*monitor.PortDescriptor, error) { |
| 56 | + return nil, nil |
64 | 57 | } |
65 | 58 |
|
66 | 59 | //TODO implement |
67 | | -func (d *dummyMonitor) Configure() { |
68 | | - |
| 60 | +func (d *dummyMonitor) Configure(parameterName string, value string) error { |
| 61 | + return nil |
69 | 62 | } |
70 | 63 |
|
71 | 64 | //TODO implement |
72 | | -func (d *dummyMonitor) Open() { |
73 | | - |
| 65 | +func (d *dummyMonitor) Open(ipAddress string, boardPort string) error { |
| 66 | + return nil |
74 | 67 | } |
75 | 68 |
|
76 | 69 | //TODO implement |
77 | | -func (d *dummyMonitor) Close() { |
78 | | - |
79 | | -} |
80 | | - |
81 | | -//TODO remove |
82 | | -// Stop is used to stop the goroutine started by StartSync |
83 | | -// used to discover ports. |
84 | | -func (d *dummyMonitor) Stop() error { |
85 | | - if d.closeChan != nil { |
86 | | - d.closeChan <- true |
87 | | - close(d.closeChan) |
88 | | - d.closeChan = nil |
89 | | - } |
| 70 | +func (d *dummyMonitor) Close() error { |
90 | 71 | return nil |
91 | 72 | } |
92 | 73 |
|
93 | | -//TODO remove |
94 | | -// StartSync starts the goroutine that generates fake Ports. |
95 | | -func (d *dummyMonitor) StartSync(eventCB monitor.EventCallback, errorCB monitor.ErrorCallback) error { |
96 | | - d.startSyncCount++ |
97 | | - if d.startSyncCount%5 == 0 { |
98 | | - return errors.New("could not start_sync every 5 times") |
99 | | - } |
100 | | - |
101 | | - c := make(chan bool) |
102 | | - d.closeChan = c |
103 | | - |
104 | | - // Run synchronous event emitter |
105 | | - go func() { |
106 | | - var closeChan <-chan bool = c |
107 | | - |
108 | | - // Output initial port state |
109 | | - eventCB("add", createDummyPort()) |
110 | | - eventCB("add", createDummyPort()) |
111 | | - |
112 | | - // Start sending events |
113 | | - count := 0 |
114 | | - for count < 2 { |
115 | | - count++ |
116 | | - |
117 | | - select { |
118 | | - case <-closeChan: |
119 | | - return |
120 | | - case <-time.After(2 * time.Second): |
121 | | - } |
122 | | - |
123 | | - port := createDummyPort() |
124 | | - eventCB("add", port) |
125 | | - |
126 | | - select { |
127 | | - case <-closeChan: |
128 | | - return |
129 | | - case <-time.After(2 * time.Second): |
130 | | - } |
131 | | - |
132 | | - eventCB("remove", &monitor.Port{ |
133 | | - Address: port.Address, |
134 | | - Protocol: port.Protocol, |
135 | | - }) |
136 | | - } |
137 | | - |
138 | | - errorCB("unrecoverable error, cannot send more events") |
139 | | - <-closeChan |
140 | | - }() |
141 | | - |
142 | | - return nil |
143 | | -} |
| 74 | +// Quit does nothing. |
| 75 | +// In a real implementation it can be used to tear down resources |
| 76 | +// used to monitor Ports. |
| 77 | +func (d *dummyMonitor) Quit() {} |
144 | 78 |
|
145 | 79 | var dummyCounter = 0 |
146 | 80 |
|
|
0 commit comments