diff options
author | Christian Pointner <equinox@helsinki.at> | 2016-11-17 01:51:03 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2016-11-17 01:51:03 (GMT) |
commit | aed7e2d70f10c20e3f9bbaa046594133aa29dda1 (patch) | |
tree | 4d9a376c3feb4bac7b3778ffac881deec2d79edf /src/rhctl/playout_server.go | |
parent | 8f39244ad12e47121324f881b9caa651d8d7e85f (diff) |
move serial port to external package
Diffstat (limited to 'src/rhctl/playout_server.go')
-rw-r--r-- | src/rhctl/playout_server.go | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/rhctl/playout_server.go b/src/rhctl/playout_server.go index b6054c6..b0cf433 100644 --- a/src/rhctl/playout_server.go +++ b/src/rhctl/playout_server.go @@ -25,6 +25,8 @@ import ( "fmt" "strings" "time" + + "code.helsinki.at/goserial" ) type ServerHealth bool @@ -61,7 +63,7 @@ type ServerState struct { type PlayoutServer struct { name string - device *SerialPort + device *goserial.Port hbtimeout time.Duration hbtimer *time.Timer hbthreshold uint @@ -90,7 +92,7 @@ func (srv *PlayoutServer) handleHeartbeat() { srv.StateChanges <- srv.state rhl.Printf("Server(%s): is back from the dead!", srv.name) if srv.state.Channel == "" { - srv.device.tx <- ServerChannelReq + srv.device.TX <- ServerChannelReq } } } @@ -145,7 +147,7 @@ func (srv *PlayoutServer) Run() { select { case <-stop: return - case data := <-srv.device.rx: + case data := <-srv.device.RX: srv.handleMessage(data) case <-srv.hbtimer.C: srv.handleHBTimeout() @@ -153,10 +155,10 @@ func (srv *PlayoutServer) Run() { if srv.state.Health == ServerDead { srv.StateChanges <- srv.state } else { - srv.device.tx <- ServerChannelReq + srv.device.TX <- ServerChannelReq } case update := <-srv.SwitchUpdates: - srv.device.tx <- update.Data + srv.device.TX <- update.Data } } } @@ -181,7 +183,7 @@ func ServerInit(name string, conf *Config) (srv *PlayoutServer, err error) { srv.UpdateRequest = make(chan bool, 8) srv.SwitchUpdates = make(chan SwitchUpdate, 32) - if srv.device, err = SerialOpen(conf.Servers[name].Device, conf.Servers[name].Baudrate, "\n"); err != nil { + if srv.device, err = goserial.Open(conf.Servers[name].Device, conf.Servers[name].Baudrate, "\n"); err != nil { err = fmt.Errorf("Server(%s): error opening serial port: %s", srv.name, err) return } |