9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] How read data from USB-device ?
@ 2018-08-13 22:45 Олег Бахарев
  2018-08-14  7:45 ` Steve Simon
  2018-08-14  7:54 ` Richard Miller
  0 siblings, 2 replies; 13+ messages in thread
From: Олег Бахарев @ 2018-08-13 22:45 UTC (permalink / raw)
  To: 9fans

[-- Attachment #1: Type: text/plain, Size: 127 bytes --]

How can I read data from USB device (USB device is used as Serial device
with baudrate 9600 ) ?
P.S: device is arduino bord

[-- Attachment #2: Type: text/html, Size: 164 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [9fans] How read data from USB-device ?
  2018-08-13 22:45 [9fans] How read data from USB-device ? Олег Бахарев
@ 2018-08-14  7:45 ` Steve Simon
  2018-08-14  7:54 ` Richard Miller
  1 sibling, 0 replies; 13+ messages in thread
From: Steve Simon @ 2018-08-14  7:45 UTC (permalink / raw)
  To: 9fans

this is what I use:

con -b 115200 -C /dev/eiaU0/eiaU

I use this daily on 'Silicon Labs' 'CP2102' devices.

the -C may not be necessary in your case.

NB: There where some historic issues with usb serial
on Richard Miller's raspberry pi build, but
this is all sorted in the current release.

-Steve



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [9fans] How read data from USB-device ?
  2018-08-13 22:45 [9fans] How read data from USB-device ? Олег Бахарев
  2018-08-14  7:45 ` Steve Simon
@ 2018-08-14  7:54 ` Richard Miller
  2018-08-14  8:32   ` Олег Бахарев
  1 sibling, 1 reply; 13+ messages in thread
From: Richard Miller @ 2018-08-14  7:54 UTC (permalink / raw)
  To: 9fans

> How can I read data from USB device (USB device is used as Serial device
> with baudrate 9600 ) ?

When you plug in the device, you should see a console message "usb/serial..."
and it will appear as /dev/eiaU*/eiaU if usb/serial has a built-in driver
for it.  Otherwise, try the usb/probe command to find the USB vid and did,
and post them here to see if anyone has support for that device.




^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [9fans] How read data from USB-device ?
  2018-08-14  7:54 ` Richard Miller
@ 2018-08-14  8:32   ` Олег Бахарев
  2018-08-14  9:46     ` Richard Miller
  0 siblings, 1 reply; 13+ messages in thread
From: Олег Бахарев @ 2018-08-14  8:32 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

[-- Attachment #1: Type: text/plain, Size: 629 bytes --]

Message "usb/serial..." don't appear.
usb/probe result:
ep5.0 255 csp 0x0000ff csp 0x0201ff vid 0x1a86 did 0x7523 none <nil> dwcotg

2018-08-14 10:54 GMT+03:00 Richard Miller <9fans@hamnavoe.com>:

> > How can I read data from USB device (USB device is used as Serial device
> > with baudrate 9600 ) ?
>
> When you plug in the device, you should see a console message
> "usb/serial..."
> and it will appear as /dev/eiaU*/eiaU if usb/serial has a built-in driver
> for it.  Otherwise, try the usb/probe command to find the USB vid and did,
> and post them here to see if anyone has support for that device.
>
>
>

[-- Attachment #2: Type: text/html, Size: 1030 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [9fans] How read data from USB-device ?
  2018-08-14  8:32   ` Олег Бахарев
@ 2018-08-14  9:46     ` Richard Miller
  2018-08-14 11:09       ` Олег Бахарев
  0 siblings, 1 reply; 13+ messages in thread
From: Richard Miller @ 2018-08-14  9:46 UTC (permalink / raw)
  To: 9fans

> usb/probe result:
> ep5.0 255 csp 0x0000ff csp 0x0201ff vid 0x1a86 did 0x7523 none <nil> dwcotg

That's a CH341 adapter.  I have a driver which should work.  You can fetch an
updated usb/serial command from http://www.hamnavoe.com/usbserial (use hget).
If you want to build from source, updates to /sys/src/cmd/usb/serial are in
http://www.hamnavoe.com/serial.tar

I would put a patch on sources but the Bell Labs server is unresponsive
at present.




^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [9fans] How read data from USB-device ?
  2018-08-14  9:46     ` Richard Miller
@ 2018-08-14 11:09       ` Олег Бахарев
  2018-08-14 11:19         ` Олег Бахарев
  0 siblings, 1 reply; 13+ messages in thread
From: Олег Бахарев @ 2018-08-14 11:09 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

[-- Attachment #1: Type: text/plain, Size: 829 bytes --]

Thank you very much, Richard! You correctly understood about the
adapter. Tell me, please, how to perform the installation (there is no
Internet on Raspberry Pi, but I can transfer files via drawterm)? And
how do I read data (if possible, not through C)?



2018-08-14 12:46 GMT+03:00 Richard Miller <9fans@hamnavoe.com>:

> > usb/probe result:
> > ep5.0 255 csp 0x0000ff csp 0x0201ff vid 0x1a86 did 0x7523 none <nil>
> dwcotg
>
> That's a CH341 adapter.  I have a driver which should work.  You can fetch
> an
> updated usb/serial command from http://www.hamnavoe.com/usbserial (use
> hget).
> If you want to build from source, updates to /sys/src/cmd/usb/serial are in
> http://www.hamnavoe.com/serial.tar
>
> I would put a patch on sources but the Bell Labs server is unresponsive
> at present.
>
>
>

[-- Attachment #2: Type: text/html, Size: 1678 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [9fans] How read data from USB-device ?
  2018-08-14 11:09       ` Олег Бахарев
@ 2018-08-14 11:19         ` Олег Бахарев
  2018-08-14 12:16           ` Richard Miller
  0 siblings, 1 reply; 13+ messages in thread
From: Олег Бахарев @ 2018-08-14 11:19 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

[-- Attachment #1: Type: text/plain, Size: 1012 bytes --]

mk: don't know how to make 'acm.h' in directory /sys/src/cmd/usb/serial

2018-08-14 14:09 GMT+03:00 Олег Бахарев <disconnectix@gmail.com>:

> Thank you very much, Richard! You correctly understood about the adapter. Tell me, please, how to perform the installation (there is no Internet on Raspberry Pi, but I can transfer files via drawterm)? And how do I read data (if possible, not through C)?
>
>
>
> 2018-08-14 12:46 GMT+03:00 Richard Miller <9fans@hamnavoe.com>:
>
>> > usb/probe result:
>> > ep5.0 255 csp 0x0000ff csp 0x0201ff vid 0x1a86 did 0x7523 none <nil>
>> dwcotg
>>
>> That's a CH341 adapter.  I have a driver which should work.  You can
>> fetch an
>> updated usb/serial command from http://www.hamnavoe.com/usbserial (use
>> hget).
>> If you want to build from source, updates to /sys/src/cmd/usb/serial are
>> in
>> http://www.hamnavoe.com/serial.tar
>>
>> I would put a patch on sources but the Bell Labs server is unresponsive
>> at present.
>>
>>
>>
>

[-- Attachment #2: Type: text/html, Size: 2401 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [9fans] How read data from USB-device ?
  2018-08-14 11:19         ` Олег Бахарев
@ 2018-08-14 12:16           ` Richard Miller
  2018-08-14 16:36             ` Олег Бахарев
  0 siblings, 1 reply; 13+ messages in thread
From: Richard Miller @ 2018-08-14 12:16 UTC (permalink / raw)
  To: 9fans

> mk: don't know how to make 'acm.h' in directory /sys/src/cmd/usb/serial

Sorry, I thought that was already in the distributed version.  I've updated
the serial.tar file, so it should be complete now if you try again.

> And how do I read data (if possible, not through C)?

Set the baud rate with
  echo b9600 >/dev/eiaU?/eiaUctl
and then you can receive data with
  cat /dev/eiaU?/eiaU
or set up an interactive conversation, as Steve Simon suggested, with
  con /dev/eiaU?/eiaU

More information is in the manual - uart(3), usb(4), con(3)




^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [9fans] How read data from USB-device ?
  2018-08-14 12:16           ` Richard Miller
@ 2018-08-14 16:36             ` Олег Бахарев
  2018-08-15 23:03               ` Олег Бахарев
  0 siblings, 1 reply; 13+ messages in thread
From: Олег Бахарев @ 2018-08-14 16:36 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

[-- Attachment #1: Type: text/plain, Size: 693 bytes --]

Thanks ! It's really works !


2018-08-14 15:16 GMT+03:00 Richard Miller <9fans@hamnavoe.com>:

> > mk: don't know how to make 'acm.h' in directory /sys/src/cmd/usb/serial
>
> Sorry, I thought that was already in the distributed version.  I've updated
> the serial.tar file, so it should be complete now if you try again.
>
> > And how do I read data (if possible, not through C)?
>
> Set the baud rate with
>   echo b9600 >/dev/eiaU?/eiaUctl
> and then you can receive data with
>   cat /dev/eiaU?/eiaU
> or set up an interactive conversation, as Steve Simon suggested, with
>   con /dev/eiaU?/eiaU
>
> More information is in the manual - uart(3), usb(4), con(3)
>
>
>

[-- Attachment #2: Type: text/html, Size: 1114 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [9fans] How read data from USB-device ?
  2018-08-14 16:36             ` Олег Бахарев
@ 2018-08-15 23:03               ` Олег Бахарев
  2018-08-16 11:26                 ` Richard Miller
  0 siblings, 1 reply; 13+ messages in thread
From: Олег Бахарев @ 2018-08-15 23:03 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

[-- Attachment #1: Type: text/plain, Size: 1151 bytes --]

I encountered some problem: there is a trivial program on Go that
writes to the files / dev / eiaU4 / eiaUctl and / dev / eiaU the
control parameters and data respectively. But in fact the records are
not produced at all, it is known that this has nothing to do with the
program itself.
Are there any ideas how to tackle the problem?



2018-08-14 19:36 GMT+03:00 Олег Бахарев <disconnectix@gmail.com>:

> Thanks ! It's really works !
>
>
> 2018-08-14 15:16 GMT+03:00 Richard Miller <9fans@hamnavoe.com>:
>
>> > mk: don't know how to make 'acm.h' in directory /sys/src/cmd/usb/serial
>>
>> Sorry, I thought that was already in the distributed version.  I've
>> updated
>> the serial.tar file, so it should be complete now if you try again.
>>
>> > And how do I read data (if possible, not through C)?
>>
>> Set the baud rate with
>>   echo b9600 >/dev/eiaU?/eiaUctl
>> and then you can receive data with
>>   cat /dev/eiaU?/eiaU
>> or set up an interactive conversation, as Steve Simon suggested, with
>>   con /dev/eiaU?/eiaU
>>
>> More information is in the manual - uart(3), usb(4), con(3)
>>
>>
>>
>

[-- Attachment #2: Type: text/html, Size: 2192 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [9fans] How read data from USB-device ?
  2018-08-15 23:03               ` Олег Бахарев
@ 2018-08-16 11:26                 ` Richard Miller
  2018-08-16 12:50                   ` Олег Бахарев
  0 siblings, 1 reply; 13+ messages in thread
From: Richard Miller @ 2018-08-16 11:26 UTC (permalink / raw)
  To: 9fans

> 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.




^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [9fans] How read data from USB-device ?
  2018-08-16 11:26                 ` Richard Miller
@ 2018-08-16 12:50                   ` Олег Бахарев
  2018-08-16 13:00                     ` Олег Бахарев
  0 siblings, 1 reply; 13+ messages in thread
From: Олег Бахарев @ 2018-08-16 12:50 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

[-- Attachment #1: Type: text/plain, Size: 1394 bytes --]

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.
>
>
>

[-- Attachment #2: Type: text/html, Size: 2099 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [9fans] How read data from USB-device ?
  2018-08-16 12:50                   ` Олег Бахарев
@ 2018-08-16 13:00                     ` Олег Бахарев
  0 siblings, 0 replies; 13+ messages in thread
From: Олег Бахарев @ 2018-08-16 13:00 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

[-- Attachment #1: Type: text/plain, Size: 1640 bytes --]

Solved. File has been opened for read-only operations. Fixed.

2018-08-16 15:50 GMT+03:00 Олег Бахарев <disconnectix@gmail.com>:

> 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.
>>
>>
>>
>

[-- Attachment #2: Type: text/html, Size: 2585 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2018-08-16 13:00 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-13 22:45 [9fans] How read data from USB-device ? Олег Бахарев
2018-08-14  7:45 ` Steve Simon
2018-08-14  7:54 ` Richard Miller
2018-08-14  8:32   ` Олег Бахарев
2018-08-14  9:46     ` Richard Miller
2018-08-14 11:09       ` Олег Бахарев
2018-08-14 11:19         ` Олег Бахарев
2018-08-14 12:16           ` Richard Miller
2018-08-14 16:36             ` Олег Бахарев
2018-08-15 23:03               ` Олег Бахарев
2018-08-16 11:26                 ` Richard Miller
2018-08-16 12:50                   ` Олег Бахарев
2018-08-16 13:00                     ` Олег Бахарев

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).