Last active
August 29, 2015 14:14
-
-
Save bakins/5cca7f87798b99bd50e9 to your computer and use it in GitHub Desktop.
stoker parser - very rough
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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