I've put a version of LuaRPC into the trunk in order to get a version
of this into the mainstream eLua. It has been tested on STM32, and seems to be working reasonably well there for both floating point and integer-only targets, though I'm pretty sure there are ways to cause it to blow up if one tries :-) At the moment it is set up to simply take over the serial console UART and read/write over that link. This means among other things that printing things out to the console will not make the RPC code very happy. Some sort of work-around should probably be issued to either encapsulate console printed stuff to be forwarded or muted. To fire it up on STM32, burn the image, start lua on the target and then issue the command: rpc.server() At this point any further characters sent will be going to the rpc handler (as long as it lives). A desktop-side Lua REPL can be compiled using: scons -f remote-lua.py This will result in a lua file in your eLua root. It should mostly behave like a standard lua interpreter, except that it has an rpc table registered that allows for interacting with a LuaRPC server. Currently the code for this uses POSIX serial port setup, but it should be very easy to use other link types see (luarpc_posix_serial.c and luarpc_elua_uart.c). To test out a connection to a target running an RPC server start with the example at test/test-rpc.lua This shows a few simple ways in which you can interact with a server instance. Some other caveats include that currently, ARM7TDMI float ordering isn't handled yet, but general big endian vs little endian should work (I'd certainly appreciate bug reports if it doesn't work :-) I have some thoughts on how to test for ARM7TDMI floating point, but suggestions are welcome as far as how one could do so with a minimum exchange of bytes. Basics: slave,err = rpc.connect ("/path/to/serial/port") print("CPU Clock: " .. slave.cpu.clock()/1000000 .. " MHz") slave.foo = {1, 2, 3, 4, "234"} -- newindex assignments work for most lua types including string.dump-able functions local_foo = slave.foo:get() -- a get method allows one to copy remote values (including functions) to the local machine for i,v in pairs(local_foo) do print(i,v) end -- roll through and print the now local copy of the table -- index events that don't have the :get() method attached return a handle, so you can use these to reference remote methods locally, or for lazy evaluation adc = slave.adc adc.setblocking(0,1) adc.setclock(0, 64 ,2) adc.sample(0,128) for i=1,128 do retsamp = adc.getsample(0) if not (retsamp == nil) then print(retsamp) end end -- the above behaves much like having local adc :-) -jsnyder -- James Snyder Biomedical Engineering Northwestern University [hidden email] http://fanplastic.org/key.txt ph: 847.448.0386 _______________________________________________ Elua-dev mailing list [hidden email] https://lists.berlios.de/mailman/listinfo/elua-dev |
Nice! =)
I'll try it tonight! --Pedro Bittencourt On Mon, Jun 22, 2009 at 9:50 PM, James Snyder <[hidden email]> wrote: I've put a version of LuaRPC into the trunk in order to get a version _______________________________________________ Elua-dev mailing list [hidden email] https://lists.berlios.de/mailman/listinfo/elua-dev |
In reply to this post by jbsnyder
Thanks, James, excellent work! Can't wait to get my hands on this (hopefully in the near future) :)
Best, Bogdan On Tue, Jun 23, 2009 at 3:50 AM, James Snyder <[hidden email]> wrote: I've put a version of LuaRPC into the trunk in order to get a version _______________________________________________ Elua-dev mailing list [hidden email] https://lists.berlios.de/mailman/listinfo/elua-dev |
Free forum by Nabble | Edit this page |