From a93e0e36fec6bd4ba583bf9791e35033e096ce13 Mon Sep 17 00:00:00 2001 From: Thiago Naves Date: Wed, 18 May 2011 01:32:00 -0300 Subject: [PATCH 1/2] Fix uart ID on transport_write_buffer. Added uart setup to transport_open_connection and transport_open_listener --- src/luarpc_elua_uart.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/luarpc_elua_uart.c b/src/luarpc_elua_uart.c index 096eede4..aead3d8a 100644 --- a/src/luarpc_elua_uart.c +++ b/src/luarpc_elua_uart.c @@ -52,6 +52,9 @@ void transport_open_listener(lua_State *L, ServerHandle *handle) handle->ltpt.fd = ( int )uart_id; handle->ltpt.tmr_id = tmr_id; + + // Setup uart + platform_uart_setup( (unsigned int) uart_id, 115200, 8, PLATFORM_UART_PARITY_NONE, PLATFORM_UART_STOPBITS_1 ); } // Open Connection / Client @@ -75,6 +78,10 @@ int transport_open_connection(lua_State *L, Handle *handle) handle->tpt.fd = ( int )uart_id; handle->tpt.tmr_id = tmr_id; + + // Setup uart + platform_uart_setup( (unsigned int) uart_id, 115200, 8, PLATFORM_UART_PARITY_NONE, PLATFORM_UART_STOPBITS_1 ); + return 1; } @@ -132,7 +139,8 @@ void transport_write_buffer( Transport *tpt, const u8 *buffer, int length ) TRANSPORT_VERIFY_OPEN; for( i = 0; i < length; i ++ ) - platform_uart_send( CON_UART_ID, buffer[ i ] ); + platform_uart_send( tpt->fd, buffer[ i ] ); +// platform_uart_send( CON_UART_ID, buffer[ i ] ); } // Check if data is available on connection without reading: From b8201d9c6e130fa691fcaff882adcc951aeb0d9c Mon Sep 17 00:00:00 2001 From: Thiago Naves Date: Wed, 18 May 2011 18:55:10 -0300 Subject: [PATCH 2/2] Fix connection problem on adispatch() --- src/modules/luarpc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/modules/luarpc.c b/src/modules/luarpc.c index a4bdd6ee..d5eb06b3 100644 --- a/src/modules/luarpc.c +++ b/src/modules/luarpc.c @@ -1142,6 +1142,8 @@ static int rpc_connect( lua_State *L ) handle = handle_create ( L ); transport_open_connection( L, handle ); + set_adispatch_buff( -1 ); + transport_write_u8( &handle->tpt, RPC_CMD_CON ); client_negotiate( &handle->tpt ); } @@ -1584,7 +1586,6 @@ static int rpc_adispatch_helper( lua_State *L, ServerHandle * handle ) connect = 1; } -// c = platform_uart_recv( t->fd, t->tmr_id, 0 ); c = transport_get_char( t ); if ( c < 0 ) @@ -1599,6 +1600,7 @@ static int rpc_adispatch_helper( lua_State *L, ServerHandle * handle ) if ( connect ) // Are we connecting ? { // We got a connection + set_adispatch_buff( c ); if ( transport_read_u8( &handle->atpt ) == RPC_CMD_CON ) server_negotiate( &handle->atpt );