Skip to content

Instantly share code, notes, and snippets.

@bakins
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bakins/5cca7f87798b99bd50e9 to your computer and use it in GitHub Desktop.
Save bakins/5cca7f87798b99bd50e9 to your computer and use it in GitHub Desktop.
stoker parser - very rough
// https://www.rocksbarbque.com - the stoker
// when you connect to telnet port, it is streaming updates about
// once per second. I was able to figure out which field was temperature
// and how to tell food and pit probes apart.
// Plan is to dump data to statsd(?) and/or into something like Circonus.
package main
import (
"bufio"
"fmt"
"io"
"net"
"strings"
)
func reader(i io.Reader) {
r := bufio.NewReaderSize(i, 1024)
for {
line, _, err := r.ReadLine()
if err != nil {
return
}
parts := strings.Split(string(line), " ")
l := len(parts)
switch {
case l == 11:
//foodprobe
fmt.Println("food: ", parts[9])
case l > 12:
//pit
if parts[10] == "PID:" {
fmt.Println("pit: ", parts[9])
}
}
}
}
func main() {
c, err := net.Dial("tcp", "192.168.1.69:23")
if err != nil {
panic(err)
}
defer c.Close()
reader(c)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment