}
func main() {
- cmd_chans, sub_chans := ZmqsInit(cmd_port_, sub_port_)
+ zmqctx, cmd_chans, sub_chans := ZmqsInit(cmd_port_, sub_port_)
defer cmd_chans.Close()
defer sub_chans.Close()
+ defer zmqctx.Close()
var listen bool
var ignore_next bool
// ---------- ZeroMQ Code -------------
-func ZmqsInit(cmd_port, sub_port string) (cmd_chans, sub_chans *zmq.Channels) {
-
- ctx, err := zmq.NewContext()
+func ZmqsInit(cmd_port, sub_port string) (ctx *zmq.Context, cmd_chans, sub_chans *zmq.Channels) {
+ var subfilter []byte
+ var err error
+ ctx, err = zmq.NewContext()
if err != nil {
panic(err)
}
panic(err)
}
+ sub_sock.Subscribe(subfilter)
+
if err = sub_sock.Connect(sub_port); err != nil {
panic(err)
}
os.Exit(1);
}
- cmd_chans, pub_chans := ZmqsInit(cmd_port_, pub_port_)
+ zmqctx, cmd_chans, pub_chans := ZmqsInit(cmd_port_, pub_port_)
+ defer cmd_chans.Close()
+ defer pub_chans.Close()
+ defer zmqctx.Close()
serial_wr, err := OpenAndHandleSerial(args[0], pub_chans.Out())
defer close(serial_wr)
// ---------- ZeroMQ Code -------------
-func ZmqsInit(cmd_port, pub_port string) (cmd_chans, pub_chans *zmq.Channels) {
+func ZmqsInit(cmd_port, pub_port string) (ctx *zmq.Context, cmd_chans, pub_chans *zmq.Channels) {
- ctx, err := zmq.NewContext()
+ var err error
+ ctx, err = zmq.NewContext()
if err != nil {
panic(err)
}