lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi all
Thanks for the replies and support.
On 21/08/14 17:27, lua-l-request@lists.lua.org wrote:
Message: 1
Date: Wed, 20 Aug 2014 21:04:43 +1000
From: Robert Brown <rebrown@exemail.com.au>
Subject: Lua and libusb on Raspberry Pi
To: lua-l@lists.lua.org
Message-ID: 53F480CB.8010801@exemail.com.au"><53F480CB.8010801@exemail.com.au>
Content-Type: text/plain; charset=utf-8; format=flowed

Hi
I wish to run a couple of lua scripts written by a competent person (as 
opposed to noob me) on a raspberry pi (kernel 3.10.25+) using a usb 
connection from an Arduino shield. The scripts were originally written 
to read data from the Arduino uart port and I want to read from the usb 
port instead so I will need to do some hacking.

First step after installing lua was to get libusb installed.
I chose to use libusb-1.0.19 from 
http://sourceforge.net/projects/libusb/files/latest/ which compiled ok 
from a tar.gz file.

Then I did
cp /home/pi/libusb-1.0.19/libusb/.libs/libusb-1.0.so libusb.so

and then
sudo cp /home/pi/libusb-1.0.19/libusb.so /usr/local/lib/lua/5.1/

At this point I get an error when I run
lua
Lua 5.1.5  Copyright (C) 1994-2012 Lua.org, PUC-Rio
 > require('libusb')
error loading module 'libusb' from file './libusb.so':
     ./libusb.so: undefined symbol: luaopen_libusb
stack traceback:
     [C]: ?
     [C]: in function 'require'
     stdin:1: in main chunk
     [C]: ?

Can anyone offer some advice on where I go from here?

Thanks





------------------------------

Message: 2
Date: Wed, 20 Aug 2014 07:26:06 -0400
From: Rena <hyperhacker@gmail.com>
Subject: Re: Lua and libusb on Raspberry Pi
To: Lua mailing list <lua-l@lists.lua.org>

------------------------------

Message: 3
Date: Wed, 20 Aug 2014 13:36:42 +0200
From: Dirk Laurie <dirk.laurie@gmail.com>
Subject: Re: Lua and libusb on Raspberry Pi
To: Lua mailing list <lua-l@lists.lua.org>
Message-ID:
	<CABcj=t=SPWhxxbjw+eBxEwNNS6vwuR2o9JgU+3C9CTSk_c1e=A@mail.gmail.com>
Content-Type: text/plain; charset=UTF-8

2014-08-20 13:26 GMT+02:00 Rena <hyperhacker@gmail.com>:
On 2014-08-20 7:05 AM, "Robert Brown" <rebrown@exemail.com.au> wrote:
require('libusb')
error loading module 'libusb' from file './libusb.so':
    ./libusb.so: undefined symbol: luaopen_libusb
The problem is Lua can't load libusb.so directly. Like the message says, it
can't find the luaopen_libusb function in that module. You need a library
which binds libusb to Lua.
LuaJIT can – but I doubt whether it has been ported to your
platform yet.



------------------------------

Message: 4
Date: Wed, 20 Aug 2014 13:42:17 +0200
From: steve donovan <steve.j.donovan@gmail.com>
Subject: Re: Lua and libusb on Raspberry Pi
To: Lua mailing list <lua-l@lists.lua.org>
Message-ID:
	<CA+ZMS_upTpftVpS_b_ES2BzncmhFPRN3=SNtnvZbGc1mF2FYqQ@mail.gmail.com>
Content-Type: text/plain; charset=UTF-8

On Wed, Aug 20, 2014 at 1:36 PM, Dirk Laurie <dirk.laurie@gmail.com> wrote:
LuaJIT can – but I doubt whether it has been ported to your
platform yet.
Very much available on Raspberry Pi!

http://lua-users.org/lists/lua-l/2012-04/msg01122.html
Seems to be installed ok:
dpkg-query -l luajit
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version      Architecture Description
+++-==============-============-============-=================================
ii  luajit         2.0.0~beta11 armhf        Just in time compiler for Lua pro

------------------------------

Message: 5
Date: Wed, 20 Aug 2014 13:46:05 +0200
From: steve donovan <steve.j.donovan@gmail.com>
Subject: Re: Lua and libusb on Raspberry Pi
To: Lua mailing list <lua-l@lists.lua.org>
Message-ID:
	<CA+ZMS_u6dVz1YX8W-sffiLrR-Frp_Z3KzjYj=e+q+jjZ-VLeyQ@mail.gmail.com>
Content-Type: text/plain; charset=UTF-8

On Wed, Aug 20, 2014 at 1:42 PM, steve donovan
<steve.j.donovan@gmail.com> wrote:
Very much available on Raspberry Pi!
And in fact the default Raspian image has LuaJIT 2.0 out of the box.



------------------------------

Message: 6
Date: Wed, 20 Aug 2014 16:53:46 +0100
From: Jerome Vuarand <jerome.vuarand@gmail.com>
Subject: Re: Lua and libusb on Raspberry Pi
To: Lua mailing list <lua-l@lists.lua.org>
Message-ID:
	<CAAq=FnfaSw0_bdHmp7z-9N=-NkVQyEdk2RDZMi7SqZT_5EqLWQ@mail.gmail.com>
Content-Type: text/plain; charset=UTF-8

2014-08-20 12:04 GMT+01:00 Robert Brown <rebrown@exemail.com.au>:
First step after installing lua was to get libusb installed.
I chose to use libusb-1.0.19 from
http://sourceforge.net/projects/libusb/files/latest/ which compiled ok from
a tar.gz file.
Libusb is a library for the C programming language. You need a library
for the Lua programming language.

Then I did
cp /home/pi/libusb-1.0.19/libusb/.libs/libusb-1.0.so libusb.so

and then
sudo cp /home/pi/libusb-1.0.19/libusb.so /usr/local/lib/lua/5.1/

At this point I get an error when I run
lua
Lua 5.1.5  Copyright (C) 1994-2012 Lua.org, PUC-Rio
require('libusb')
error loading module 'libusb' from file './libusb.so':
    ./libusb.so: undefined symbol: luaopen_libusb
stack traceback:
    [C]: ?
    [C]: in function 'require'
    stdin:1: in main chunk
    [C]: ?
I'm not sure why you expect this to work. If you're not familiar with
programming: it's usually not possible to use a library written for
one language into another language. If you're familiar with
programming, but not with Lua: Lua cannot access any compiled dynamic
libraries, only ones specifically designed for Lua (ie. implementing a
predefined API).

Can anyone offer some advice on where I go from here?
I wrote a libusb binding for Lua that you can use: http://piratery.net/luausb/

You'll probably have to get the sources and compile it yourself,
unless you have a working LuaRocks installation and a system-installed
libusb.
Also seems to be ok:
dpkg-query -l luarocks
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version      Architecture Description
+++-==============-============-============-=================================
ii  luarocks       2.0.9-1      all          deployment and management system

and the system installed libusb:
libusb-1.0-0 is already the newest version.
libusb-1.0-0-dev is already the newest version.





------------------------------

Message: 7
Date: Wed, 20 Aug 2014 14:02:04 -0400
From: Tom N Harris <telliamed@whoopdedo.org>
Subject: Re: Lua and libusb on Raspberry Pi
To: lua-l@lists.lua.org
Message-ID: <1692169.hAz6HVNdEk@green>
Content-Type: text/plain; charset="us-ascii"

On Wednesday, August 20, 2014 04:53:46 PM Jerome Vuarand wrote:
I wrote a libusb binding for Lua that you can use:
http://piratery.net/luausb/

You'll probably have to get the sources and compile it yourself,
unless you have a working LuaRocks installation and a system-installed
libusb.
Another option: https://code.google.com/p/lualibusb1/

I will check this one out.
Thanks
Rob