Solved. File has been opened for read-only operations. Fixed.
2018-08-16 15:50 GMT+03:00 Олег Бахарев <[email protected]>:
> Not work (
> Program itself:
>
> package main
>
> import(
> "flag"
> "fmt"
> "os"
> )
>
> func main() {
>
> var color = flag.Int("color", 0x00000000, "Color value")
> flag.Parse()
>
> var hexColor uint32 = uint32(*color)
>
> var rgb [3]byte;
> rgb[2] = byte(hexColor & 0x000000ff)
> rgb[1] = byte((hexColor & 0x0000ff00) >> 8)
> rgb[0] = byte((hexColor & 0x00ff0000) >> 16)
>
> usbControl, controlErr := os.Open("/dev/eiaU5/eiaUctl")
>
> if controlErr != nil {
> fmt.Println(controlErr)
> os.Exit(1)
> }
> defer usbControl.Close()
>
> usbControl.WriteString("b9600")
> usbControl.Sync()
>
> usbFile, usbErr := os.Open("/dev/eiaU5/eiaU")
>
> if usbErr != nil {
> fmt.Println(usbErr)
> os.Exit(1)
> }
> defer usbFile.Close()
>
> fmt.Print(rgb[0])
> fmt.Print(rgb[1])
> fmt.Print(rgb[2])
>
> usbFile.Write(rgb[:])
> }
>
> 2018-08-16 14:26 GMT+03:00 Richard Miller <[email protected]>:
>
>> > I encountered some problem: there is a trivial program on Go that
>> > writes to the files / dev / eiaU4 / eiaUctl and / dev / eiaU the
>>
>> I hope you meant /dev/eiaU4/eiaU, not /dev/eiaU
>>
>> Unless you do a "bind -a /dev/eiaU4 /dev" after starting the usb
>> serial driver, which allows you to reference the device files
>> as /dev/eiaUctl and /dev/eiaU and not have to remember the unit number.
>>
>>
>>
>