Skip to content

Commit 84133d0

Browse files
umbynoscmaglie
authored andcommitted
cleanup and optimizations
1 parent c818cef commit 84133d0

File tree

2 files changed

+4
-25
lines changed

2 files changed

+4
-25
lines changed

dummy-monitor/main.go

-18
Original file line numberDiff line numberDiff line change
@@ -101,21 +101,3 @@ func (d *dummyMonitor) Close() error {
101101
// In a real implementation it can be used to tear down resources
102102
// used to monitor Ports.
103103
func (d *dummyMonitor) Quit() {}
104-
105-
var dummyCounter = 0
106-
107-
// createDummyPort creates a Port with fake data
108-
func createDummyPort() *monitor.Port {
109-
dummyCounter++
110-
return &monitor.Port{
111-
Address: fmt.Sprintf("%d", dummyCounter),
112-
AddressLabel: "Dummy upload port",
113-
Protocol: "dummy",
114-
ProtocolLabel: "Dummy protocol",
115-
Properties: properties.NewFromHashmap(map[string]string{
116-
"vid": "0x2341",
117-
"pid": "0x0041",
118-
"mac": fmt.Sprintf("%d", dummyCounter*384782),
119-
}),
120-
}
121-
}

monitor.go

+4-7
Original file line numberDiff line numberDiff line change
@@ -169,13 +169,12 @@ func (d *Server) hello(cmd string) {
169169

170170
func (d *Server) describe() {
171171
if !d.initialized {
172-
d.outputChan <- messageError("describe", "Monitor not STARTed")
172+
d.outputChan <- messageError("describe", "Monitor not initialized")
173173
return
174174
}
175-
var portDescription *PortDescriptor
176175
portDescription, err := d.impl.Describe()
177176
if err != nil {
178-
d.outputChan <- messageError("hello", err.Error())
177+
d.outputChan <- messageError("describe", err.Error())
179178
return
180179
}
181180
d.outputChan <- &message{
@@ -187,10 +186,10 @@ func (d *Server) describe() {
187186

188187
func (d *Server) configure(cmd string) {
189188
if !d.initialized {
190-
d.outputChan <- messageError("configure", "Monitor not STARTed")
189+
d.outputChan <- messageError("configure", "Monitor not initialized")
191190
return
192191
}
193-
re := regexp.MustCompile(`^(\w+) (\w+)$`)
192+
re := regexp.MustCompile(`^([\w.-]+) (.+)$`)
194193
matches := re.FindStringSubmatch(cmd)
195194
if len(matches) != 3 {
196195
d.outputChan <- messageError("configure", "Invalid CONFIGURE command")
@@ -216,8 +215,6 @@ func (d *Server) close() {
216215

217216
}
218217

219-
func (d *Server) errorEvent(msg string) {
220-
d.outputChan <- messageError("start_sync", msg)
221218
}
222219

223220
func (d *Server) outputProcessor(outWriter io.Writer) {

0 commit comments

Comments
 (0)