Skip to content

Commit 34455ab

Browse files
committed
Merge branch 'devel'
2 parents fb6ad13 + 17e2075 commit 34455ab

16 files changed

+185
-35
lines changed

.gitmodules

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +0,0 @@
1-
[submodule "arduino"]
2-
path = arduino
3-
url = https://github.com/facchinm/arduino-flash-tools

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Please use the current latest version:
2323

2424
## Submitting an issue
2525

26-
Please attach the output of the commands running at http://localhost:8989 if useful.
26+
Please attach the output of the commands running at the debug console if useful.
2727

2828
## Submitting a pull request
2929

arduino

Lines changed: 0 additions & 1 deletion
This file was deleted.

bufferflow.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
//"time"
66
)
77

8-
var availableBufferAlgorithms = []string{"default"}
8+
var availableBufferAlgorithms = []string{"default", "timed"}
99

1010
type BufferMsg struct {
1111
Cmd string
@@ -16,6 +16,7 @@ type BufferMsg struct {
1616
}
1717

1818
type Bufferflow interface {
19+
Init()
1920
BlockUntilReady(cmd string, id string) (bool, bool) // implement this method
2021
//JustQueue(cmd string, id string) bool // implement this method
2122
OnIncomingData(data string) // implement this method

bufferflow_timed.go

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
package main
2+
3+
import (
4+
"encoding/json"
5+
"time"
6+
7+
log "github.com/Sirupsen/logrus"
8+
)
9+
10+
type BufferflowTimed struct {
11+
Name string
12+
Port string
13+
Output chan []byte
14+
Input chan string
15+
ticker *time.Ticker
16+
}
17+
18+
var (
19+
bufferedOutput string
20+
)
21+
22+
func (b *BufferflowTimed) Init() {
23+
log.Println("Initting timed buffer flow (output once every 16ms)")
24+
bufferedOutput = ""
25+
26+
go func() {
27+
for data := range b.Input {
28+
bufferedOutput = bufferedOutput + data
29+
}
30+
}()
31+
32+
go func() {
33+
b.ticker = time.NewTicker(16 * time.Millisecond)
34+
for _ = range b.ticker.C {
35+
if bufferedOutput != "" {
36+
m := SpPortMessage{bufferedOutput}
37+
buf, _ := json.Marshal(m)
38+
b.Output <- []byte(buf)
39+
bufferedOutput = ""
40+
}
41+
}
42+
}()
43+
44+
}
45+
46+
func (b *BufferflowTimed) BlockUntilReady(cmd string, id string) (bool, bool) {
47+
//log.Printf("BlockUntilReady() start\n")
48+
return true, false
49+
}
50+
51+
func (b *BufferflowTimed) OnIncomingData(data string) {
52+
b.Input <- data
53+
}
54+
55+
// Clean out b.sem so it can truly block
56+
func (b *BufferflowTimed) ClearOutSemaphore() {
57+
}
58+
59+
func (b *BufferflowTimed) BreakApartCommands(cmd string) []string {
60+
return []string{cmd}
61+
}
62+
63+
func (b *BufferflowTimed) Pause() {
64+
return
65+
}
66+
67+
func (b *BufferflowTimed) Unpause() {
68+
return
69+
}
70+
71+
func (b *BufferflowTimed) SeeIfSpecificCommandsShouldSkipBuffer(cmd string) bool {
72+
return false
73+
}
74+
75+
func (b *BufferflowTimed) SeeIfSpecificCommandsShouldPauseBuffer(cmd string) bool {
76+
return false
77+
}
78+
79+
func (b *BufferflowTimed) SeeIfSpecificCommandsShouldUnpauseBuffer(cmd string) bool {
80+
return false
81+
}
82+
83+
func (b *BufferflowTimed) SeeIfSpecificCommandsShouldWipeBuffer(cmd string) bool {
84+
return false
85+
}
86+
87+
func (b *BufferflowTimed) SeeIfSpecificCommandsReturnNoResponse(cmd string) bool {
88+
return false
89+
}
90+
91+
func (b *BufferflowTimed) ReleaseLock() {
92+
}
93+
94+
func (b *BufferflowTimed) IsBufferGloballySendingBackIncomingData() bool {
95+
return true
96+
}
97+
98+
func (b *BufferflowTimed) Close() {
99+
b.ticker.Stop()
100+
close(b.Input)
101+
}

compile_webidebridge.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ createZipEmbeddableFileArduino()
3232
cp fakecerts/*.pem arduino/
3333
mv arduino/arduino/tools* arduino/arduino/tools
3434
cd arduino
35-
zip -r arduino.zip arduino/* config.ini *.pem > /dev/null
35+
zip -r arduino.zip config.ini *.pem > /dev/null
3636
cd ..
3737
#cat arduino/arduino.zip >> $3
3838
#zip --adjust-sfx $3

config.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
addr = :8989 # http service address
21
configUpdateInterval = 0 # Update interval for re-reading config file set via -config flag. Zero disables config file re-reading.
32
gc = std # Type of garbage collection. std = Normal garbage collection allowing system to decide (this has been known to cause a stop the world in the middle of a CNC job which can cause lost responses from the CNC controller and thus stalled jobs. use max instead to solve.), off = let memory grow unbounded (you have to send in the gc command manually to garbage collect or you will run out of RAM eventually), max = Force garbage collection on each recv or send on a serial port (this minimizes stop the world events and thus lost serial responses, but increases CPU usage)
43
hostname = unknown-hostname # Override the hostname we get from the OS

download.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,10 @@ func spDownloadTool(name string, url string) {
110110
log.Info("Tool already present, skipping download")
111111
}
112112

113-
// will be something like ${tempfolder}/avrdude/bin/avrdude
114-
globalToolsMap["{runtime.tools."+name+".path}"] = filepath.ToSlash(tempToolsPath + "/" + name)
113+
folders, _ := ioutil.ReadDir(tempToolsPath)
114+
for _, f := range folders {
115+
globalToolsMap["{runtime.tools."+f.Name()+".path}"] = filepath.ToSlash(tempToolsPath + "/" + f.Name())
116+
}
115117

116118
log.Info("Map Updated")
117119
mapD := map[string]string{"DownloadStatus": "Success", "Msg": "Map Updated"}

hub.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ func checkCmd(m []byte) {
197197
} else if strings.HasPrefix(sl, "broadcast") {
198198
go broadcast(s)
199199
} else if strings.HasPrefix(sl, "restart") {
200+
log.Println("Received restart from the daemon. Why? Boh")
200201
restart("")
201202
} else if strings.HasPrefix(sl, "exit") {
202203
exit()
@@ -266,6 +267,7 @@ func exit() {
266267
}
267268

268269
func restart(path string) {
270+
log.Println("called restart", path)
269271
// relaunch ourself and exit
270272
// the relaunch works because we pass a cmdline in
271273
// that has serial-port-json-server only initialize 5 seconds later
@@ -321,7 +323,7 @@ func restart(path string) {
321323
hiberString = "-hibernate"
322324
}
323325

324-
cmd = exec.Command(exePath, "-ls", "-addr", *addr, "-regex", *regExpFilter, "-gc", *gcType, hiberString)
326+
cmd = exec.Command(exePath, "-ls", "-regex", *regExpFilter, "-gc", *gcType, hiberString)
325327

326328
fmt.Println(cmd)
327329

info.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package main
2+
3+
import (
4+
"github.com/gin-gonic/gin"
5+
)
6+
7+
func infoHandler(c *gin.Context) {
8+
c.JSON(200, gin.H{
9+
"http": "http://localhost" + port,
10+
"https": "https://localhost" + port,
11+
"ws": "ws://localhost" + port,
12+
"wss": "wss://localhost" + portSSL,
13+
})
14+
}

0 commit comments

Comments
 (0)