From ac5234abe456612ac617a218675e926fa45879eb Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Mon, 11 Jan 2010 22:07:08 +0000 Subject: luaclient send to cmd fd works now diff --git a/l_cmd.c b/l_cmd.c index baf8db7..2d2a139 100644 --- a/l_cmd.c +++ b/l_cmd.c @@ -122,7 +122,17 @@ static int l_cmd_recv_data(lua_State* L) static int l_cmd_send_string(lua_State* L) { - return 0; + int ret = send_string(cmd_fd, luaL_checkstring(L,1)); + if (ret > 0) + do { + ret = write(cmd_fd, "\n", 1); + } while(!ret || (ret == -1 && errno == EINTR)); + + if(ret > 0) + ret = 0; + + lua_pushinteger(L, ret); + return 1; } static const struct luaL_reg cmd_funcs [] = { diff --git a/mode-leds.lua b/mode-leds.lua index 1b43184..fd52eca 100644 --- a/mode-leds.lua +++ b/mode-leds.lua @@ -32,6 +32,8 @@ function main_loop(opt) local sig = signal.init() local cmdfd = cmd.init() + cmd.send_string("hello world"); + local return_value = 0 while return_value == 0 do local readable, _, err = socket.select({ sig , cmdfd }, nil) -- cgit v0.10.2