Read usb Data in Lua on raspberry Pi

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Read usb Data in Lua on raspberry Pi

Robert Brown

Hi
Now that I have libusb working I am wanting to read string data from the
usb port on the Raspberry Pi. The string looks like :
(node sol_adv ? (p_1 0.00)(e_1 0.00)(p_2 0.00)(e_2 0.00)(p_3 0.00)(e_3
0.00)(p_4 0.00)(e_4 0.00))
(node sol_adv ? (temp_1 16.94) (temp_2 17.19) )
(node sol_adv ? (p_1 0.00)(e_1 0.00)(p_2 0.00)(e_2 0.00)(p_3 0.00)(e_3
0.00)(p_4 0.00)(e_4 0.00))
(node sol_adv ? (temp_1 16.94) (temp_2 17.19) )

as indicated using minicom

After a bit of reading I have played around with a few basic commands
but really am just stabbing in the dark with my near zero knowledge of
lua and limited programming skills.

require('libusb')
continuous=0
local buses=libusb.get_busses()
local handle=libusb.open(device)
libusb.bulk_read(handle, ENDPOINT_IN, ts, 1)

My hope is to get some basic code working and then try to merge it into
a script that has been written to read from uart and push the data to a
web site. I.e. replace the "read from uart" function. Doubtless some
will respond with "go away" but from any patient/tolerant people out
there prepared to help any tips or pointers would be much appreciated.

Thanks
Rob

Reply | Threaded
Open this post in threaded view
|

Re: Read usb Data in Lua on raspberry Pi

KHMan
On 8/29/2014 6:20 AM, Robert Brown wrote:

> Now that I have libusb working I am wanting to read string data
> from the usb port on the Raspberry Pi. The string looks like :
> (node sol_adv ? (p_1 0.00)(e_1 0.00)(p_2 0.00)(e_2 0.00)(p_3
> 0.00)(e_3 0.00)(p_4 0.00)(e_4 0.00))
> (node sol_adv ? (temp_1 16.94) (temp_2 17.19) )
> (node sol_adv ? (p_1 0.00)(e_1 0.00)(p_2 0.00)(e_2 0.00)(p_3
> 0.00)(e_3 0.00)(p_4 0.00)(e_4 0.00))
> (node sol_adv ? (temp_1 16.94) (temp_2 17.19) )
>
> as indicated using minicom
>
> After a bit of reading I have played around with a few basic
> commands but really am just stabbing in the dark with my near zero
> knowledge of lua and limited programming skills.
>
> require('libusb')
> continuous=0
> local buses=libusb.get_busses()
> local handle=libusb.open(device)
> libusb.bulk_read(handle, ENDPOINT_IN, ts, 1)
>
> My hope is to get some basic code working and then try to merge it
> into a script that has been written to read from uart and push the
> data to a web site. I.e. replace the "read from uart" function.
> Doubtless some will respond with "go away" but from any
> patient/tolerant people out there prepared to help any tips or
> pointers would be much appreciated.

USB is a bit more involved compared to serial I/O. I normally see
a lot more code than that in getting a USB device running. It's
better to copy from a working example, if possible. Enumerate,
then open the device with the correct vendor and product ID,
configure/setup, then you can perform I/O.

What is plugged into the USB port? If your hardware was previously
using serial, and you are now using some FTDI-like serial-to-USB
dongle, then I don't believe they are accessed via libusb, there
are drivers available.

--
Cheers,
Kein-Hong Man (esq.)
Kuala Lumpur, Malaysia