mirror of
https://github.com/tio/tio.git
synced 2026-05-01 14:57:59 +02:00
fix: lua script stops output if it includes null terminate
This commit is contained in:
parent
f887756a71
commit
2fb788f817
1 changed files with 4 additions and 2 deletions
|
|
@ -187,7 +187,9 @@ static int modem_send(lua_State *L)
|
||||||
// lua: send(string)
|
// lua: send(string)
|
||||||
static int write_(lua_State *L)
|
static int write_(lua_State *L)
|
||||||
{
|
{
|
||||||
const char *string = lua_tostring(L, 1);
|
size_t len = 0;
|
||||||
|
const char *string = lua_tolstring(L, 1, &len);
|
||||||
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (string == NULL)
|
if (string == NULL)
|
||||||
|
|
@ -195,7 +197,7 @@ static int write_(lua_State *L)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = write(device_fd, string, strlen(string));
|
ret = write(device_fd, string, len);
|
||||||
fsync(device_fd); // flush these characters now
|
fsync(device_fd); // flush these characters now
|
||||||
tcdrain(device_fd); //ensure we flushed characters to our device
|
tcdrain(device_fd); //ensure we flushed characters to our device
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue