<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -2,9 +2,9 @@
 #ifndef __LUARPC_CONFIG_H__
 #define __LUARPC_CONFIG_H__
 
-#define LUARPC_ENABLE_SOCKET
+/*#define LUARPC_ENABLE_SOCKET */
 /* #define LUARPC_ENABLE_FIFO  -- not implemented!!! */
-/* #define LUARPC_ENABLE_SERIAL */
+#define LUARPC_ENABLE_SERIAL
 
 /* signed and unsigned 8, 16 and 32 bit types */
 </diff>
      <filename>config.h</filename>
    </modified>
    <modified>
      <diff>@@ -633,9 +633,12 @@ static int rpc_connect( lua_State *L )
   Try
   {
     char header[ 5 ];
+		printf(&quot;Pre handle\n&quot;);
     handle = handle_create (L );
+		printf(&quot;Post handle\n&quot;);
     transport_open_connection( L, handle );
-    
+		printf(&quot;Post-open-connection\n&quot;);
+
     /* write the protocol header */
     header[0] = 'L';
     header[1] = 'R';
@@ -643,6 +646,7 @@ static int rpc_connect( lua_State *L )
     header[3] = 'C';
     header[4] = RPC_PROTOCOL_VERSION;
     transport_write_string( &amp;handle-&gt;tpt, header, sizeof( header ) );
+		printf(&quot;post-wrote-string\n&quot;);
   }
   Catch( e )
   {     
@@ -1028,11 +1032,6 @@ static const luaL_reg rpc_helper[] =
   { NULL, NULL }
 };
 
-static const luaL_reg rpc_server_handle[] =
-{
-  { NULL, NULL }
-};
-
 static const luaL_reg rpc_map[] =
 {
   { &quot;connect&quot;, rpc_connect },
@@ -1059,13 +1058,12 @@ LUALIB_API int luaopen_luarpc(lua_State *L)
   luaL_register( L, &quot;rpc&quot;, rpc_map );
 
   luaL_newmetatable( L, &quot;rpc.helper&quot; );
-  luaL_openlib( L, NULL, rpc_helper, 0 );
+  luaL_register( L, NULL, rpc_helper );
   
   luaL_newmetatable( L, &quot;rpc.handle&quot; );
-  luaL_openlib( L, NULL, rpc_handle, 0 );
+  luaL_register( L, NULL, rpc_handle );
   
   luaL_newmetatable( L, &quot;rpc.server_handle&quot; );
-  luaL_openlib( L, NULL, rpc_server_handle, 0 );
 
   if ( sizeof( double ) != 8 )
     debug ( &quot;internal error: sizeof(double) != 8&quot; );</diff>
      <filename>luarpc.c</filename>
    </modified>
    <modified>
      <diff>@@ -158,7 +158,7 @@ int transport_open_connection(lua_State *L, Handle *handle);
 void transport_accept (Transport *tpt, Transport *atpt);
 
 /* Read &amp; Write to Transport */
-void transport_read_buffer (Transport *tpt, const u8 *buffer, int length);
+void transport_read_buffer (Transport *tpt, u8 *buffer, int length);
 void transport_write_buffer (Transport *tpt, const u8 *buffer, int length);
 
 /* Check if data is available on connection without reading:</diff>
      <filename>luarpc_rpc.h</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,7 @@
 #include &lt;stdio.h&gt;
 #include &lt;unistd.h&gt;
 #include &lt;stdlib.h&gt;
+#include &lt;fcntl.h&gt;
 #include &lt;sys/fcntl.h&gt;
 #include &lt;sys/file.h&gt;
 #include &lt;sys/time.h&gt;
@@ -12,6 +13,8 @@
 #include &lt;string.h&gt;
 #include &lt;alloca.h&gt;
 
+/* FIXME:  I know not all of the above is necessary, should pare it down sometime */
+
 #include &quot;lua.h&quot;
 #include &quot;lualib.h&quot;
 #include &quot;lauxlib.h&quot;
@@ -32,7 +35,7 @@ void transport_open( Transport *tpt, const char *path )
 	struct termios options;
 	struct exception e;
 	
-	tpt-&gt;fd = open(path , O_RDWR | O_NOCTTY );
+	tpt-&gt;fd = open(path , O_RDWR | O_NOCTTY | O_NDELAY );
 	
 	if( tpt-&gt;fd == INVALID_TRANSPORT)
 	{
@@ -83,12 +86,13 @@ int transport_open_connection(lua_State *L, Handle *handle)
 /* Accept Connection */
 void transport_accept (Transport *tpt, Transport *atpt)
 {
+	struct exception e;
 	TRANSPORT_VERIFY_OPEN;
 	atpt-&gt;fd = tpt-&gt;fd;
 }
 
 /* Read &amp; Write to Transport */
-void transport_read_buffer (Transport *tpt, const u8 *buffer, int length)
+void transport_read_buffer (Transport *tpt, u8 *buffer, int length)
 {
 	int n;
 	struct exception e;</diff>
      <filename>luarpc_serial.c</filename>
    </modified>
    <modified>
      <diff>@@ -288,7 +288,7 @@ void transport_accept (Transport *tpt, Transport *atpt)
 
 /* read from the socket into a buffer */
 
-void transport_read_buffer (Transport *tpt, const u8 *buffer, int length)
+void transport_read_buffer (Transport *tpt, u8 *buffer, int length)
 {
 	struct exception e;
   TRANSPORT_VERIFY_OPEN;</diff>
      <filename>luarpc_socket.c</filename>
    </modified>
    <modified>
      <diff>@@ -17,8 +17,9 @@ function doStuff()
 	rpc.on_error (error_handler);
 	io.write (&quot;error set\n&quot;)
 
-	local slave,err = rpc.connect (&quot;localhost&quot;,12345);
-	-- local slave,err = rpc.connect (&quot;/dev/ttys0&quot;);
+	-- local slave,err = rpc.connect (&quot;localhost&quot;,12345);
+	--local slave,err = rpc.connect (&quot;/dev/ttys0&quot;);
+	local slave,err = rpc.connect (&quot;/dev/tty.usbserial-ftCYPMYJ&quot;);
 	-- local slave,err = rpc.connect (&quot;/dev/pts/4&quot;);
 	if not slave then
 		io.write (&quot;error: &quot; .. err .. &quot;\n&quot;);
@@ -44,10 +45,7 @@ function doStuff()
 	
 	print (slave.testvar)
 	
-	function squareval(x) 
-		print(x^2)
-		return x^2
-	end
+	function squareval(x) return x^2 end
 	
 	print(slave.execfunc( string.dump(squareval), 8 ))
 	</diff>
      <filename>test-client.lua</filename>
    </modified>
    <modified>
      <diff>@@ -32,9 +32,9 @@ testvar = 23
 
 io.write (&quot;server started\n&quot;)
 
--- rpc.server (&quot;/dev/ptys0&quot;); -- use for serial mode
+rpc.server (&quot;/dev/ptys0&quot;); -- use for serial mode
 -- rpc.server (&quot;/dev/ptmx&quot;); -- use for serial mode
-rpc.server (12345); -- use for socket mode
+-- rpc.server (12345); -- use for socket mode
 
 -- an alternative way
 </diff>
      <filename>test-server.lua</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>b04d7f710926530e6be72f407215499e6c49ffc3</id>
    </parent>
  </parents>
  <author>
    <name>James Snyder</name>
    <email>jbsnyder@fanplastic.org</email>
  </author>
  <url>http://github.com/jsnyder/luarpc/commit/c80ec38f990e4af222db6fa5c5122ef15ff039d9</url>
  <id>c80ec38f990e4af222db6fa5c5122ef15ff039d9</id>
  <committed-date>2009-06-01T11:29:43-07:00</committed-date>
  <authored-date>2009-06-01T11:29:43-07:00</authored-date>
  <message>Very simple working RPC.

TODOs:
- redirect stderr/stdout in some way that works better
- deal with connection state in a way that's more resilient (packetize?)
- set up _index in addition to _call to allow recursive calls to subtables</message>
  <tree>1272a47aefa16582e7ae8acf764c83ec6c6b2da7</tree>
  <committer>
    <name>James Snyder</name>
    <email>jbsnyder@fanplastic.org</email>
  </committer>
</commit>
