From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: References: <96b9ce32468d844a80c002c470af9e0a@hamnavoe.com> From: =?UTF-8?B?0J7Qu9C10LMg0JHQsNGF0LDRgNC10LI=?= Date: Thu, 16 Aug 2018 16:00:13 +0300 Message-ID: To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: multipart/alternative; boundary="00000000000019d02205738d0640" Subject: Re: [9fans] How read data from USB-device ? Topicbox-Message-UUID: dacadac0-ead9-11e9-9d60-3106f5b1d025 --00000000000019d02205738d0640 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Solved. File has been opened for read-only operations. Fixed. 2018-08-16 15:50 GMT+03:00 =D0=9E=D0=BB=D0=B5=D0=B3 =D0=91=D0=B0=D1=85=D0= =B0=D1=80=D0=B5=D0=B2 : > Not work ( > Program itself: > > package main > > import( > "flag" > "fmt" > "os" > ) > > func main() { > > var color =3D flag.Int("color", 0x00000000, "Color value") > flag.Parse() > > var hexColor uint32 =3D uint32(*color) > > var rgb [3]byte; > rgb[2] =3D byte(hexColor & 0x000000ff) > rgb[1] =3D byte((hexColor & 0x0000ff00) >> 8) > rgb[0] =3D byte((hexColor & 0x00ff0000) >> 16) > > usbControl, controlErr :=3D os.Open("/dev/eiaU5/eiaUctl") > > if controlErr !=3D nil { > fmt.Println(controlErr) > os.Exit(1) > } > defer usbControl.Close() > > usbControl.WriteString("b9600") > usbControl.Sync() > > usbFile, usbErr :=3D os.Open("/dev/eiaU5/eiaU") > > if usbErr !=3D 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 <9fans@hamnavoe.com>: > >> > 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. >> >> >> > --00000000000019d02205738d0640 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Solved. File has been opened for read-only operations. Fix= ed.

2018= -08-16 15:50 GMT+03:00 =D0=9E=D0=BB=D0=B5=D0=B3 =D0=91=D0=B0=D1=85=D0=B0=D1= =80=D0=B5=D0=B2 <disconnectix@gmail.com>:
Not work (
Program its= elf:

package main

import(
=C2=A0=C2=A0=C2=A0 = "flag"
=C2=A0=C2=A0=C2=A0 "fmt"
=C2=A0=C2=A0=C2= =A0 "os"
)

func main() {
=C2=A0=C2=A0=C2=A0
=C2= =A0=C2=A0=C2=A0 var color =3D flag.Int("color", 0x00000000, "= ;Color value")
=C2=A0=C2=A0=C2=A0 flag.Parse()
=C2=A0=C2=A0=C2= =A0
=C2=A0=C2=A0=C2=A0 var hexColor uint32 =3D uint32(*color)
=C2=A0= =C2=A0=C2=A0
=C2=A0=C2=A0=C2=A0 var rgb [3]byte;
=C2=A0=C2=A0=C2=A0 = rgb[2] =3D byte(hexColor & 0x000000ff)
=C2=A0=C2=A0=C2=A0 rgb[1] =3D= byte((hexColor & 0x0000ff00) >> 8)
=C2=A0=C2=A0=C2=A0 rgb[0] = =3D byte((hexColor & 0x00ff0000) >> 16)

=C2=A0=C2=A0=C2=A0= usbControl, controlErr :=3D os.Open("/dev/eiaU5/eiaUctl")
=C2=A0=C2=A0=C2=A0 if controlErr !=3D nil {
=C2=A0=C2=A0=C2=A0 =C2=A0= =C2=A0=C2=A0 fmt.Println(controlErr)
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 os.Exit(1)
=C2=A0=C2=A0=C2=A0 }
=C2=A0=C2=A0=C2=A0 defer u= sbControl.Close()

=C2=A0=C2=A0=C2=A0 usbControl.WriteString("b9= 600")
=C2=A0=C2=A0=C2=A0 usbControl.Sync()

=C2=A0=C2=A0= =C2=A0 usbFile, usbErr :=3D os.Open("/dev/eiaU5/eiaU")

=C2= =A0=C2=A0=C2=A0 if usbErr !=3D nil {
=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 fmt.Println(usbErr)
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 os.E= xit(1)
=C2=A0=C2=A0=C2=A0 }
=C2=A0=C2=A0=C2=A0 defer usbFile.Close()=

=C2=A0=C2=A0=C2=A0 fmt.Print(rgb[0])
=C2=A0=C2=A0=C2=A0 fmt.Prin= t(rgb[1])
=C2=A0=C2=A0=C2=A0 fmt.Print(rgb[2])
=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 usbFile.Write(rgb[:])
}

2018-08-16 14:26 GMT+03:00 Richard Miller <9fans@hamnavoe.com>= :
> I encountered some pr= oblem: 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<= br> serial driver, which allows you to reference the device files
as /dev/eiaUctl and /dev/eiaU and not have to remember the unit number.




--00000000000019d02205738d0640--