added config file for list purposes

This commit is contained in:
2022-07-06 23:09:58 -04:00
parent 0d243683fe
commit 7a3f194cd5
4 changed files with 249 additions and 9 deletions
+16 -7
View File
@@ -1,10 +1,10 @@
// =============================================================================
// Auth: Alex Celani
// File: led.go
// Revn: 07-04-2022 2.0
// Revn: 07-05-2022 3.0
// Func: receive data as an endpoint, send response back to middleman
//
// TODO:
// TODO: implement rainbow
// =============================================================================
// CHANGE LOG
// -----------------------------------------------------------------------------
@@ -28,6 +28,7 @@
// added support for white, cyan, yellow, and magenta
// finished comments for tell() and ask() and even simple
// parsing stuff in handleClient()
//*07-05-2022: added support for kill messages
//
// =============================================================================
@@ -163,8 +164,9 @@ func tell( comm []string ) string {
default: // user asks for else, bail out
response = "status unknown"
}
case "kill": // user wants to stop running
os.Exit( 2 ) // FIXME
// user wants to stop running
case "kill", "quit", "end", "die", "stop":
response = "kill"
default: // user enters incorrect command
response = "command unknown"
}
@@ -201,8 +203,6 @@ func handleClient( conn net.Conn ) {
os.Exit( 2 ) // if not, exit
}
// TODO differentiate ask commands from tell commands
// initiate response variable
var resp string
@@ -230,6 +230,10 @@ func handleClient( conn net.Conn ) {
if *verbose { // XXX identical verbose print
fmt.Println( "sent: ", resp ) // print response
}
if resp == "kill" { // if user sent back kill
os.Exit( 1 ) // end process
}
}
}
@@ -258,7 +262,7 @@ func main() {
lg = flag.Int( "lg", 9, "GPIO pin for green LED" )
lb = flag.Int( "lb", 25, "GPIO pin for blue LED" )
verbose = flag.Bool( "v", false, "verbose printing" )
ip = flag.String( "ip", ":1202", "ip and port of self" )
ip = flag.String( "ip", ":1212", "ip and port of self" )
flag.Parse()
// initialize pins to GPIO 11, 9, and 25
@@ -280,6 +284,11 @@ func main() {
pinG.Output()
pinB.Output()
// Initialize output to "off"
pinR.High()
pinG.High()
pinB.High()
// "resolve" ip & host according to TCP rules
tcpAddr, err := net.ResolveTCPAddr( "tcp", *ip )
check( err ) // check error