Files
zephyr/subsys/modem/backends/modem_backend_tty_bottom.c
Alberto Escolar Piedras 6ef08d1221 modem: backend: tty: Support building with any C library
Ensure we call into the host C library open/close/read/write
independently of which embedded C library the code is built with.

We do this by:
a) Using the native simulator nsi_host* trampolines when we just want
   to call straight into the host libC.
b) Building in the native_simulator runner context (and therefore with
   the host C library) two functions which we call from the embedded
   side.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2025-12-23 19:49:50 +00:00

30 lines
547 B
C

/*
* Copyright (c) 2022 Trackunit Corporation
* Copyright (c) 2025 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <fcntl.h>
#include <poll.h>
int modem_backend_tty_poll_bottom(int fd)
{
struct pollfd pd = { .fd = fd, .events = POLLIN };
int ret;
ret = poll(&pd, 1, 0);
if ((ret > 0) && !(pd.revents & POLLIN)) {
/* we are only interested in POLLIN events */
ret = 0;
}
return ret;
}
int modem_backend_tty_open_bottom(const char *tty_path)
{
return open(tty_path, (O_RDWR | O_NONBLOCK), 0644);
}