~ruther/CTU-FEE-B0B35APO-Semestral-project

ref: 584549e4cfab9c1764e22e7b11ca94c8d36459f7 CTU-FEE-B0B35APO-Semestral-project/lib-pheripherals/include/nonblocking_io.h -rw-r--r-- 831 bytes
584549e4 — František Boháček feat: add filoperation error get text 3 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#ifndef _NONBLOCKING_IO_H
#define _NONBLOCKING_IO_H

#include <stdbool.h>
#include <stdint.h>
#include <termios.h>
#include <unistd.h>

/**
 * @brief Set file to nonblocking using cfmakeraw
 *
 * @param file to set
 * @param old termios struct to save old data to
 * @return int
 */
int file_set_nonblocking(int file, struct termios *old);

/**
 * @brief Set file to old termios data
 *
 * @param file to set
 * @param old termios struct to load old data from
 * @return int
 */
int file_set_blocking(int file, struct termios *old);

/**
 * @brief Read from nonblocking file, if no data, return 0 instead of -1
 *
 * @param file to read from
 * @param max_size size of buffer
 * @param data buffer to write data to
 * @return int
 */
int file_read_nonblocking(int file, size_t max_size, uint8_t *data);

#endif //_NONBLOCKING_IO_H
Do not follow this link