From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: <96b9ce32468d844a80c002c470af9e0a@hamnavoe.com> References: <96b9ce32468d844a80c002c470af9e0a@hamnavoe.com> From: =?UTF-8?B?0J7Qu9C10LMg0JHQsNGF0LDRgNC10LI=?= Date: Thu, 16 Aug 2018 15:50:23 +0300 Message-ID: To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: multipart/alternative; boundary="000000000000f59d7605738ce20e" Subject: Re: [9fans] How read data from USB-device ? Topicbox-Message-UUID: dabf129e-ead9-11e9-9d60-3106f5b1d025 --000000000000f59d7605738ce20e Content-Type: text/plain; charset="UTF-8" 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 <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. > > > --000000000000f59d7605738ce20e Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Not work (
Program itself:

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 col= or =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(hexColo= r & 0x000000ff)
=C2=A0=C2=A0=C2=A0 rgb[1] =3D byte((hexColor & 0= x0000ff00) >> 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 usbControl.Close()

= =C2=A0=C2=A0=C2=A0 usbControl.WriteString("b9600")
=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.Exit(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.Print(rgb[1])
=C2=A0=C2=A0= =C2=A0 fmt.Print(rgb[2])
=C2=A0=C2=A0=C2=A0
=C2=A0=C2=A0=C2=A0 usbFi= le.Write(rgb[:])
}

2018-08-16 14:26 GMT+03:00 Richard Miller &= lt;9fans@hamnavoe.c= om>:
> = 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<= 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.



--000000000000f59d7605738ce20e--