2021-12-09 05:04:56 +00:00
|
|
|
package manager
|
2021-12-09 02:35:44 +00:00
|
|
|
|
|
|
|
import (
|
2021-12-09 05:04:56 +00:00
|
|
|
"context"
|
2021-12-09 02:35:44 +00:00
|
|
|
"fmt"
|
|
|
|
"time"
|
|
|
|
|
2021-12-09 05:04:56 +00:00
|
|
|
"git.godopu.net/lab/etri-smartfarm-poc-controller-serial/puserial"
|
2021-12-09 02:35:44 +00:00
|
|
|
"github.com/rjeczalik/notify"
|
|
|
|
)
|
|
|
|
|
2021-12-09 05:04:56 +00:00
|
|
|
func Run() {
|
|
|
|
fmt.Println("Hello world")
|
2021-12-09 02:35:44 +00:00
|
|
|
|
2021-12-09 05:04:56 +00:00
|
|
|
ctx, _ := context.WithTimeout(context.Background(), time.Second*10)
|
|
|
|
ch_discover := make(chan notify.EventInfo)
|
|
|
|
go puserial.WatchNewDevice(ctx, ch_discover)
|
2021-12-09 02:35:44 +00:00
|
|
|
|
|
|
|
for {
|
2021-12-09 05:04:56 +00:00
|
|
|
e, ok := <-ch_discover
|
|
|
|
if !ok {
|
|
|
|
fmt.Println("byebye~!")
|
|
|
|
return
|
2021-12-09 02:35:44 +00:00
|
|
|
}
|
2021-12-09 05:04:56 +00:00
|
|
|
fmt.Println(e)
|
2021-12-09 02:35:44 +00:00
|
|
|
}
|
|
|
|
}
|