mirror of
https://github.com/tio/tio.git
synced 2026-05-01 14:57:59 +02:00
Add lua send(string)
This commit is contained in:
parent
00c8124a0a
commit
418a43d96e
2 changed files with 26 additions and 1 deletions
|
|
@ -384,7 +384,8 @@ available:
|
||||||
Send file using x/y-modem protocol.
|
Send file using x/y-modem protocol.
|
||||||
|
|
||||||
Protocol can be any of XMODEM_1K, XMODEM_CRC, YMODEM.
|
Protocol can be any of XMODEM_1K, XMODEM_CRC, YMODEM.
|
||||||
|
.IP "\fBsend(string)"
|
||||||
|
Send string.
|
||||||
.IP "\fBhigh(line)"
|
.IP "\fBhigh(line)"
|
||||||
Set tty line high.
|
Set tty line high.
|
||||||
.IP "\fBlow(line)"
|
.IP "\fBlow(line)"
|
||||||
|
|
|
||||||
24
src/script.c
24
src/script.c
|
|
@ -19,6 +19,7 @@
|
||||||
* 02110-1301, USA.
|
* 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
@ -186,6 +187,28 @@ static int modem_send(lua_State *L)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// lua: send(string)
|
||||||
|
static int send(lua_State *L)
|
||||||
|
{
|
||||||
|
const char *string = lua_tostring(L, 1);
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (string == NULL)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = write(serial_fd, string, strlen(string));
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
tio_error_print("%s\n", strerror(errno));
|
||||||
|
}
|
||||||
|
|
||||||
|
lua_pushnumber(L, ret);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
static void script_buffer_run(lua_State *L, const char *script_buffer)
|
static void script_buffer_run(lua_State *L, const char *script_buffer)
|
||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
|
|
@ -210,6 +233,7 @@ static const struct luaL_Reg tio_lib[] =
|
||||||
{ "config_low", config_low},
|
{ "config_low", config_low},
|
||||||
{ "config_apply", config_apply},
|
{ "config_apply", config_apply},
|
||||||
{ "modem_send", modem_send},
|
{ "modem_send", modem_send},
|
||||||
|
{ "send", send},
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue