-
Notifications
You must be signed in to change notification settings - Fork 174
/
bufferflow_dummypause.go
100 lines (80 loc) · 2.27 KB
/
bufferflow_dummypause.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
package main
import (
"log"
"time"
)
type BufferflowDummypause struct {
Name string
Port string
NumLines int
Paused bool
}
func (b *BufferflowDummypause) Init() {
}
func (b *BufferflowDummypause) RewriteSerialData(cmd string, id string) string {
return ""
}
func (b *BufferflowDummypause) BlockUntilReady(cmd string, id string) (bool, bool, string) {
log.Printf("BlockUntilReady() start. numLines:%v\n", b.NumLines)
log.Printf("buffer:%v\n", b)
//for b.Paused {
log.Println("We are paused for 3 seconds. Yeilding send.")
time.Sleep(3000 * time.Millisecond)
//}
log.Printf("BlockUntilReady() end\n")
return true, false, ""
}
func (b *BufferflowDummypause) OnIncomingData(data string) {
log.Printf("OnIncomingData() start. data:%v\n", data)
b.NumLines++
//time.Sleep(3000 * time.Millisecond)
log.Printf("OnIncomingData() end. numLines:%v\n", b.NumLines)
}
// Clean out b.sem so it can truly block
func (b *BufferflowDummypause) ClearOutSemaphore() {
}
func (b *BufferflowDummypause) BreakApartCommands(cmd string) []string {
return []string{cmd}
}
func (b *BufferflowDummypause) Pause() {
return
}
func (b *BufferflowDummypause) Unpause() {
return
}
func (b *BufferflowDummypause) SeeIfSpecificCommandsShouldSkipBuffer(cmd string) bool {
return false
}
func (b *BufferflowDummypause) SeeIfSpecificCommandsShouldPauseBuffer(cmd string) bool {
return false
}
func (b *BufferflowDummypause) SeeIfSpecificCommandsShouldUnpauseBuffer(cmd string) bool {
return false
}
func (b *BufferflowDummypause) SeeIfSpecificCommandsShouldWipeBuffer(cmd string) bool {
return false
}
func (b *BufferflowDummypause) SeeIfSpecificCommandsReturnNoResponse(cmd string) bool {
/*
// remove comments
cmd = b.reComment.ReplaceAllString(cmd, "")
cmd = b.reComment2.ReplaceAllString(cmd, "")
if match := b.reNoResponse.MatchString(cmd); match {
log.Printf("Found cmd that does not get a response from TinyG. cmd:%v\n", cmd)
return true
}
*/
return false
}
func (b *BufferflowDummypause) ReleaseLock() {
}
func (b *BufferflowDummypause) IsBufferGloballySendingBackIncomingData() bool {
return false
}
func (b *BufferflowDummypause) Close() {
}
func (b *BufferflowDummypause) GetManualPaused() bool {
return false
}
func (b *BufferflowDummypause) SetManualPaused(isPaused bool) {
}