func GpioOut(ch <-chan int) { g := GpioS{0, 0, 0} header := unsafe.Pointer(&g) g.io = 28 for { g.value = <-ch ioctl.IOCTL(uintptr(file.Fd()), IOCTL_GPIO_SET_OUTPUT, uintptr(header)) fmt.Println(">>>power stat : ", g.value) } }
func GpioOut(ch chan []jconfig) { g := GpioS{0, 0, 0} header := unsafe.Pointer(&g) g.io = 28 for { buf := <-ch fmt.Println(">>>Send String: ", buf) for _, tmp := range buf { if tmp.Data == "on" { g.value = 1 } else if tmp.Data == "off" { g.value = 0 } ioctl.IOCTL(uintptr(file.Fd()), IOCTL_GPIO_SET_OUTPUT, uintptr(header)) } fmt.Println(">>>power stat : ", g.value) } }