Tiny protocol  0.11.0
Tiny communication protocol for microcontrollers
tiny_serial.h
Go to the documentation of this file.
1 /*
2  Copyright 2017,2020 (C) Alexey Dynda
3 
4  This file is part of Tiny Protocol Library.
5 
6  Protocol Library is free software: you can redistribute it and/or modify
7  it under the terms of the GNU Lesser General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  Protocol Library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public License
17  along with Protocol Library. If not, see <http://www.gnu.org/licenses/>.
18 */
26 #pragma once
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 #include <stdint.h>
33 #if defined(__linux__)
34 #include "serial/linux_serial.h"
35 #elif defined(_WIN32)
36 #include "serial/win32_serial.h"
37 #else
38 #include "serial/noplatform_serial.h"
39 #endif
40 
41 
53 extern tiny_serial_handle_t tiny_serial_open(const char* name, uint32_t baud);
54 
61 extern void tiny_serial_close(tiny_serial_handle_t port);
62 
73 extern int tiny_serial_send(tiny_serial_handle_t port, const void *buf, int len);
74 
86 extern int tiny_serial_send_timeout(tiny_serial_handle_t port, const void *buf, int len, uint32_t timeout_ms);
87 
98 extern int tiny_serial_read(tiny_serial_handle_t port, void *buf, int len);
99 
111 extern int tiny_serial_read_timeout(tiny_serial_handle_t port, void *buf, int len, uint32_t timeout_ms);
112 
113 
114 #ifdef __cplusplus
115 }
116 #endif
int tiny_serial_send(tiny_serial_handle_t port, const void *buf, int len)
Sends data over serial connection.
int tiny_serial_read(tiny_serial_handle_t port, void *buf, int len)
Receive data from serial connection.
UART serial API.
int tiny_serial_read_timeout(tiny_serial_handle_t port, void *buf, int len, uint32_t timeout_ms)
Receive data from serial connection.
void tiny_serial_close(tiny_serial_handle_t port)
Closes serial connection.
int tiny_serial_send_timeout(tiny_serial_handle_t port, const void *buf, int len, uint32_t timeout_ms)
Sends data over serial connection.
tiny_serial_handle_t tiny_serial_open(const char *name, uint32_t baud)
Opens serial port.