Added reset_buffer()

This commit is contained in:
Davis C 2024-04-17 09:21:20 -05:00
parent 21dea47f42
commit ee56d1280d
3 changed files with 14 additions and 0 deletions

View file

@ -265,6 +265,9 @@ In addition to the Lua API tio makes the following functions available:
help to make the lines physically switch as simultaneously as possible.
This may solve timing issues on some platforms.
reset_buffer()
Flush the internal ring buffer.
Note: Line can be any of DTR, RTS, CTS, DSR, CD, RI
```

View file

@ -401,6 +401,8 @@ Set tty line state configuration to low.
Apply tty line state configuration. Using the line state configuration API
instead of high()/low() will help to make the lines physically switch as
simultaneously as possible. This may solve timing issues on some platforms.
.IP "\fBreset_buffer()"
Flush the internal ring buffer.
.TP 0n
Note: Line can be any of DTR, RTS, CTS, DSR, CD, RI

View file

@ -256,6 +256,14 @@ bool match_regex(regex_t *regex)
return false;
}
// lua: reset_buffer()
static int reset_buffer(lua_State *L)
{
(void)L;
buffer_size = 0;
return 1;
}
// lua: expect(string, timeout)
static int expect(lua_State *L)
{
@ -352,6 +360,7 @@ static const struct luaL_Reg tio_lib[] =
{ "modem_send", modem_send},
{ "send", send},
{ "expect", expect},
{ "reset_buffer", reset_buffer},
{ "exit", exit_},
{NULL, NULL}
};