Skip to content

Merge from devel #88

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 26 commits into from
Apr 15, 2016
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
1130ea8
Add bufferflow timedraw
facchinm Nov 12, 2015
6c1c6fa
add sendjsonraw command
facchinm Nov 12, 2015
d710b2d
Use a POST request to trigger update.
matteosuppo Mar 1, 2016
272cd49
Return something before rebooting after an update
matteosuppo Mar 1, 2016
781d8ae
Handle error when looking for path
matteosuppo Mar 1, 2016
981fd38
Merge branch 'devel' into updater
matteosuppo Mar 3, 2016
7c55c5e
Merge pull request #30 from facchinm/timedraw
matteosuppo Mar 3, 2016
8d60ac4
Add autoupdater to vendor folder
matteosuppo Mar 3, 2016
7376967
Update drone to notify arduino-create
matteosuppo Mar 3, 2016
9c7581c
Update drone.sec
matteosuppo Mar 3, 2016
a10a5f8
Fix event hook for notify
matteosuppo Mar 3, 2016
83bc945
Merge pull request #80 from arduino/drone
mastrolinux Mar 7, 2016
d47afcd
Merge branch 'devel' into updater
matteosuppo Mar 10, 2016
6a575f8
Add CORS origins for Scratch and ScratchX
khanning Mar 25, 2016
95f9053
Merge pull request #82 from khanning/devel
matteosuppo Mar 25, 2016
90677b6
Merge pull request #73 from arduino/updater
mastrolinux Apr 7, 2016
68f63b4
Trigger build jenkins
matteosuppo Apr 8, 2016
3497f58
Allow update for dev
matteosuppo Apr 11, 2016
712843b
Remove Scratch and ScratchX CORS entries
khanning Apr 11, 2016
82a4b4e
Remove useless function
matteosuppo Apr 11, 2016
d72645e
Merge pull request #85 from khanning/devel
mastrolinux Apr 12, 2016
9cd874b
Merge pull request #84 from arduino/allowupdatefordev
mastrolinux Apr 12, 2016
e169600
Add info to install libappindicator
mastrolinux Apr 13, 2016
14f88c9
Merge pull request #86 from arduino/fake-commit
Apr 13, 2016
67b28a7
Use a goroutine to detach the restart from the request
matteosuppo Apr 13, 2016
64849f6
Merge pull request #87 from arduino/fixrestart
mastrolinux Apr 14, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .drone.sec
Original file line number Diff line number Diff line change
@@ -1 +1 @@
eyJhbGciOiJSU0EtT0FFUCIsImVuYyI6IkExMjhHQ00ifQ.js55JcNOTOEYUK7TvkYbNUbvZvoKkze6nB0ql2b3ZWkMn6LGRdlfo3e7ktMiRf8e9RAffm86SQSEMorTw78h8iFmub7JI0Z8Xwm1A960SmkW-ULLrzE0uT6il7_pYzjOAxboUiH0ToCElvsTYEUBicc7p4a3gIhgZAezd1w52JIYxzbFQ0ca0fws3KH3H4iR6-N0d7Cc5xEXFIzHgH_OhJUXYiaCW-g5GLgbPQPu29Ofv3-_sZzXTJj4VSjvgRNzkudJieM5KjN_5L9KU6wSJyGECVsTd-kaM0yOesl9NbWq-6SMORIK43kBEgu679OWuMzJ6HbbW6Bk5I8XQASp0w.FvNQmCS3b0mq8MGN.uS9nMU1WjTWxIvkOr41zAGp6OY7MzxWQ2KteBaRm9hE3XDSWvOAwVO7i6BJOQNUX--SMCBs6tdhYyaC-x7PSGze0Ki33LU7pPc-yBhbLUdzGrxYLm1JF_IQ5QlVK2YRk5nFRSIimzylsPEkGHCd-nQciHC_m0Wetzldb-d49MNw6wZFsby8MQKVQJoWUVXM7LM-jZ5tmAmzxV1S0Py6LqUT7AAGL2RNax22YsNaOY214KTiSnIrT8eo3zmvzi28CdsapOIYxCFP8Z_JUAkjYAuow5ysxFkVvEGxr9d-W8TCyL36Sa4GgfEVvtzpcKpVmhzMllIXiXVh8ZdLJ_EuWomNSV_9veIy_ULmKo8B8tB6Uv2nlnFqGAxaf5DNYcqqQj4isHpEWFSR0ZIGU5ksoH_bY0pzQsf3wwii3KlzOJg.7WbHe_TOAdzgMW16sBvzIg
eyJhbGciOiJSU0EtT0FFUCIsImVuYyI6IkExMjhHQ00ifQ.pr9ZMRbPGFZ6rTQOAmHQJN4RRE8Hmnl6Sn6ek2DogiLA6qIZCCei6RHLppto2tpM1ApM5pLpW64TjGf_mCLIesk_GtnUF6baxrHodcI8EB3VV3CsXU3EJF3_FOk3uSJUOi7hbtn54ztMBL2QKeccUiO-KBC2BHiD8VVpjnY5C-TLYV-1Td2fUZc3QB4eoqeTlvglu0nSvHHGCL89RQU0ZEW_-h_tXXaDrvXS648g-U2B9uwnVgBgBPhQqOzP02cW2-ojgkAC7xNpO_BOWoYouT56kkeM5MEx1XyJ-tAdP0AU8mG3x6mRBbng2nwTiXt9RqIJ01RKysMdgth17SZQ8A.apeQnLTu98uqD1Xl.se-xrnl2-B63chHdq719TO98hjxVIN6qTkCnTv5y__LM7ku-FBmlUnZLKy6jDZfO3Fz0jUNwSxuU2LGJWuJ5-PEQkqhsjJuDNBbrAKbt9oqFpXUKXOyu5yw8f64GHgG0bmlrZS6X04P4JAx6t9pXE0rKV5yktoYLLcTgoHnWm3C8eX7H1ayewDJ_CD2ricdZ5J-YAe4sz1AR2mRPRiyx-LTheTc2sALqZv39_ctOI9weNIGy013Jc_6MchmERmT2c4QKlIhy2ra9CPZsOgyn6d008qse14Q32IP97VJ3KLCq69P7u3y28KGz6btjfurLFP1EuipKhWxpIsE4YWQcf_l-eXxpd-l2SUPFMMNBI6aXItKpPofgjMAPeJzlIkhkXCtfRRWIgDaHlS_eAk0nWaXSQyUljUnR7qaVyCqh.FAYZK3PkD_9u3cXwsD8WSw
71 changes: 47 additions & 24 deletions .drone.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,42 @@
build:
image: arduino/golang-linux-32
commands:
- apt-get update && apt-get install libgtk-3-dev libappindicator3-dev
- GOOS=linux GOARCH=386 CC=gcc CXX=gcc CGO_ENABLED=1 go build -o artifacts/linux-386/arduino-create-agent
- cp config.ini artifacts/linux-386
build:
image: arduino/golang-cross
auth_config:
username: $$DOCKER_USERNAME
password: $$DOCKER_PASSWORD
email: $$DOCKER_EMAIL
commands:
- apt-get update && apt-get install libgtk-3-dev libappindicator3-dev zip
# Linux amd64
- GOOS=linux GOARCH=amd64 CC=gcc CXX=gcc CGO_ENABLED=1 go build -o artifacts/linux-amd64/arduino-create-agent
- cp config.ini artifacts/linux-amd64
# Darwin amd64
- GOOS=darwin GOARCH=amd64 CC=o64-clang CXX=o64-clang CGO_ENABLED=1 go build -o artifacts/osx/arduino-create-agent
- cp config.ini artifacts/osx
# Windows 386
- GOOS=windows GOARCH=386 CC=i686-w64-mingw32-gcc CXX=i686-w64-mingw32-gcc CGO_ENABLED=1 go build -o artifacts/windows/arduino-create-agent.exe -ldflags -H=windowsgui
- cp config.ini artifacts/windows
- zip -r arduino-create-agent.zip artifacts/*
crosscompilation:
image: arduino/golang-cross
auth_config:
username: $$DOCKER_USERNAME
password: $$DOCKER_PASSWORD
email: $$DOCKER_EMAIL
commands:
- go get github.com/kardianos/govendor
- govendor vet +local
- govendor test +local
# Linux amd64
- GOOS=linux GOARCH=amd64 CC=gcc CXX=gcc CGO_ENABLED=1 go build -o artifacts/linux-amd64/arduino-create-agent
- cp config.ini artifacts/linux-amd64
# Darwin amd64
- GOOS=darwin GOARCH=amd64 CC=o64-clang CXX=o64-clang CGO_ENABLED=1 go build -o artifacts/osx/arduino-create-agent
- cp config.ini artifacts/osx
# Windows 386
- GOOS=windows GOARCH=386 CC=i686-w64-mingw32-gcc CXX=i686-w64-mingw32-gcc CGO_ENABLED=1 go build -o artifacts/windows/arduino-create-agent.exe -ldflags -H=windowsgui
- cp config.ini artifacts/windows
- zip -r arduino-create-agent.zip artifacts/*
linux32:
image: arduino/golang-linux-32
commands:
- GOOS=linux GOARCH=386 CC=gcc CXX=gcc CGO_ENABLED=1 go build -o artifacts/linux-386/arduino-create-agent
- cp config.ini artifacts/linux-386
notify:
slack:
webhook_url: $$SLACK_WEBHOOK
channel: $$SLACK_CHANNEL
username: drone
when:
event: pull_request
template: |
{{#success build.status}}
[{{ repo.name}}] Congrats {{ build.author }}! Your PR works: {{ build.link_url}}
{{else}}
[{{ repo.name}}] Damn {{ build.author }}! Something went wrong with your PR: {{ build.link_url}}
{{/success}}
publish:
github_release:
api_key: $$GITHUB_API_KEY
Expand All @@ -35,4 +45,17 @@ publish:
checksum:
- md5
when:
branch: [master, devel, test]
event: tag
notify:
slack:
webhook_url: $$SLACK_WEBHOOK
channel: $$SLACK_CHANNEL
username: drone
when:
event: tag
template: |
{{#success build.status}}
[{{ repo.name}}/{{ build.branch }}] A new release is available: {{ build.link_url}}
{{else}}
[{{ repo.name}}/{{ build.branch }}] Something went wrong while building a new release: {{ build.link_url}}
{{/success}}
2 changes: 1 addition & 1 deletion bufferflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
//"time"
)

var availableBufferAlgorithms = []string{"default", "timed"}
var availableBufferAlgorithms = []string{"default", "timed", "timedraw"}

type BufferMsg struct {
Cmd string
Expand Down
102 changes: 102 additions & 0 deletions bufferflow_timedraw.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
package main

import (
"encoding/json"
"time"

log "github.com/Sirupsen/logrus"
)

type BufferflowTimedRaw struct {
Name string
Port string
Output chan []byte
Input chan string
ticker *time.Ticker
}

var (
bufferedOutputRaw []byte
)

func (b *BufferflowTimedRaw) Init() {
log.Println("Initting timed buffer flow (output once every 16ms)")

go func() {
for data := range b.Input {
bufferedOutputRaw = append(bufferedOutputRaw, []byte(data)...)
}
}()

go func() {
b.ticker = time.NewTicker(16 * time.Millisecond)
for _ = range b.ticker.C {
if len(bufferedOutputRaw) != 0 {
m := SpPortMessageRaw{bufferedOutputRaw}
buf, _ := json.Marshal(m)
// data is now encoded in base64 format
// need a decoder on the other side
b.Output <- []byte(buf)
bufferedOutputRaw = nil
}
}
}()

}

func (b *BufferflowTimedRaw) BlockUntilReady(cmd string, id string) (bool, bool) {
//log.Printf("BlockUntilReady() start\n")
return true, false
}

func (b *BufferflowTimedRaw) OnIncomingData(data string) {
b.Input <- data
}

// Clean out b.sem so it can truly block
func (b *BufferflowTimedRaw) ClearOutSemaphore() {
}

func (b *BufferflowTimedRaw) BreakApartCommands(cmd string) []string {
return []string{cmd}
}

func (b *BufferflowTimedRaw) Pause() {
return
}

func (b *BufferflowTimedRaw) Unpause() {
return
}

func (b *BufferflowTimedRaw) SeeIfSpecificCommandsShouldSkipBuffer(cmd string) bool {
return false
}

func (b *BufferflowTimedRaw) SeeIfSpecificCommandsShouldPauseBuffer(cmd string) bool {
return false
}

func (b *BufferflowTimedRaw) SeeIfSpecificCommandsShouldUnpauseBuffer(cmd string) bool {
return false
}

func (b *BufferflowTimedRaw) SeeIfSpecificCommandsShouldWipeBuffer(cmd string) bool {
return false
}

func (b *BufferflowTimedRaw) SeeIfSpecificCommandsReturnNoResponse(cmd string) bool {
return false
}

func (b *BufferflowTimedRaw) ReleaseLock() {
}

func (b *BufferflowTimedRaw) IsBufferGloballySendingBackIncomingData() bool {
return true
}

func (b *BufferflowTimedRaw) Close() {
b.ticker.Stop()
close(b.Input)
}
4 changes: 4 additions & 0 deletions hub.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ func checkCmd(m []byte) {
// kill the running process (assumes singleton for now)
go spHandlerProgramKill()

} else if strings.HasPrefix(sl, "sendjsonraw") {
// will catch sendjsonraw
go spWriteJsonRaw(s)

} else if strings.HasPrefix(sl, "sendjson") {
// will catch sendjson
go spWriteJson(s)
Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,8 @@ const homeTemplateHtml = `<!DOCTYPE html>
return false;
}
socket.emit("command", msg.val());
if (msg.val().indexOf("log off") != -1) {only_log = true;}
if (msg.val().indexOf("log on") != -1) {only_log = false;}
if (msg.val().indexOf("log off") != -1) {only_log = true}
if (msg.val().indexOf("log on") != -1) {only_log = false}
msg.val("");
return false
});
Expand Down
86 changes: 79 additions & 7 deletions serial.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,24 @@ type writeRequestJson struct {
Data []writeRequestJsonData
}

type writeRequestJsonRaw struct {
p *serport
P string
Data []writeRequestJsonDataRaw
}

type writeRequestJsonData struct {
D string
Id string
Buf string
}

type writeRequestJsonDataRaw struct {
D []byte
Id string
Buf string
}

type qReportJson struct {
Cmd string
QCnt int
Expand Down Expand Up @@ -73,7 +85,8 @@ type serialhub struct {
unregister chan *serport

// regexp for json trimming
reJsonTrim *regexp.Regexp
reJsonTrim *regexp.Regexp
reJsonRawTrim *regexp.Regexp
}

type SpPortList struct {
Expand Down Expand Up @@ -103,12 +116,13 @@ var NetworkPorts SpPortList

var sh = serialhub{
//write: make(chan *serport, chan []byte),
write: make(chan writeRequest),
writeJson: make(chan writeRequestJson),
register: make(chan *serport),
unregister: make(chan *serport),
ports: make(map[*serport]bool),
reJsonTrim: regexp.MustCompile("sendjson"),
write: make(chan writeRequest),
writeJson: make(chan writeRequestJson),
register: make(chan *serport),
unregister: make(chan *serport),
ports: make(map[*serport]bool),
reJsonTrim: regexp.MustCompile("sendjson"),
reJsonRawTrim: regexp.MustCompile("sendjsonraw"),
}

func (sh *serialhub) run() {
Expand Down Expand Up @@ -615,6 +629,64 @@ func spWriteJson(arg string) {
sh.writeJson <- m
}

func spWriteJsonRaw(arg string) {

log.Printf("spWriteJson. arg:%v\n", arg)

// remove sendjson string
arg = sh.reJsonRawTrim.ReplaceAllString(arg, "")
//log.Printf("string we're going to parse:%v\n", arg)

// this is a structured command now for sending in serial commands multiple at a time
// with an ID so we can send back the ID when the command is done
var m writeRequestJsonRaw
/*
m.P = "COM22"
var data writeRequestJsonData
data.Id = "234"
str := "yeah yeah"
data.D = str //[]byte(str) //[]byte(string("blah blah"))
m.Data = append(m.Data, data)
//m.Data = append(m.Data, data)
bm, err2 := json.Marshal(m)
if err2 == nil {
log.Printf("Test json serialize:%v\n", string(bm))
}
*/

err := json.Unmarshal([]byte(arg), &m)

if err != nil {
log.Printf("Problem decoding json. giving up. json:%v, err:%v\n", arg, err)
spErr(fmt.Sprintf("Problem decoding json. giving up. json:%v, err:%v", arg, err))
return
}

// see if we have this port open
portname := m.P
myport, isFound := findPortByName(portname)

if !isFound {
// we couldn't find the port, so send err
spErr("We could not find the serial port " + portname + " that you were trying to write to.")
return
}

// we found our port
m.p = myport

var mr writeRequestJson

mr.p = m.p
mr.P = m.P
var data writeRequestJsonData
data.D = string(m.Data[0].D)
mr.Data = append(mr.Data, data)

// send it to the writeJson channel
sh.writeJson <- mr
}

func spWrite(arg string) {
// we will get a string of comXX asdf asdf asdf
log.Println("Inside spWrite arg: " + arg)
Expand Down
7 changes: 7 additions & 0 deletions serialport.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ type SpPortMessage struct {
D string // the data, i.e. G0 X0 Y0
}

type SpPortMessageRaw struct {
// P string // the port, i.e. com22
D []byte // the data, i.e. G0 X0 Y0
}

func (p *serport) reader() {

//var buf bytes.Buffer
Expand Down Expand Up @@ -344,6 +349,8 @@ func spHandlerOpen(portname string, baud int, buftype string, isSecondary bool)

if buftype == "timed" {
bw = &BufferflowTimed{Name: "timed", Port: portname, Output: h.broadcastSys, Input: make(chan string)}
} else if buftype == "timedraw" {
bw = &BufferflowTimedRaw{Name: "timedraw", Port: portname, Output: h.broadcastSys, Input: make(chan string)}
} else {
bw = &BufferflowDefault{Port: portname}
}
Expand Down