1 /* 2 * Copyright (c) 2022 Trackunit Corporation 3 * Copyright (c) 2025 Nordic Semiconductor ASA 4 * 5 * SPDX-License-Identifier: Apache-2.0 6 */ 7 8 #include <fcntl.h> 9 #include <poll.h> 10 modem_backend_tty_poll_bottom(int fd)11int modem_backend_tty_poll_bottom(int fd) 12 { 13 struct pollfd pd = { .fd = fd, .events = POLLIN }; 14 int ret; 15 16 ret = poll(&pd, 1, 0); 17 18 if ((ret > 0) && !(pd.revents & POLLIN)) { 19 /* we are only interested in POLLIN events */ 20 ret = 0; 21 } 22 23 return ret; 24 } 25 modem_backend_tty_open_bottom(const char * tty_path)26int modem_backend_tty_open_bottom(const char *tty_path) 27 { 28 return open(tty_path, (O_RDWR | O_NONBLOCK), 0644); 29 } 30