tinyproto
tiny_serial.h
Go to the documentation of this file.
1 /*
2  Copyright 2017-2025 (C) Alexey Dynda
3 
4  This file is part of Tiny Protocol Library.
5 
6  GNU General Public License Usage
7 
8  Protocol Library is free software: you can redistribute it and/or modify
9  it under the terms of the GNU Lesser General Public License as published by
10  the Free Software Foundation, either version 3 of the License, or
11  (at your option) any later version.
12 
13  Protocol Library is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU Lesser General Public License for more details.
17 
18  You should have received a copy of the GNU Lesser General Public License
19  along with Protocol Library. If not, see <http://www.gnu.org/licenses/>.
20 
21  Commercial License Usage
22 
23  Licensees holding valid commercial Tiny Protocol licenses may use this file in
24  accordance with the commercial license agreement provided in accordance with
25  the terms contained in a written agreement between you and Alexey Dynda.
26  For further information contact via email on github account.
27 */
28 
36 #pragma once
37 
38 #ifdef __cplusplus
39 
40 extern "C"
41 {
42 #endif
43 
49 #include <stdint.h>
50 #if defined(ARDUINO) || defined(__AVR__)
51 #include "arduino/arduino_serial.h"
52 #elif defined(__linux__)
53 #include "linux/linux_serial.h"
54 #elif defined(__APPLE__) && defined(__MACH__)
55 #include "macos/macos_serial.h"
56 #elif defined(_WIN32)
57 #include "win32/win32_serial.h"
58 #elif defined(__XTENSA__)
59 #include "esp32/esp32_serial.h"
60 #else
61 #include "no_platform/noplatform_serial.h"
62 #endif
63 
80  extern tiny_serial_handle_t tiny_serial_open(const char *name, uint32_t baud);
81 
88  extern void tiny_serial_close(tiny_serial_handle_t port);
89 
100  extern int tiny_serial_send(tiny_serial_handle_t port, const void *buf, int len);
101 
113  extern int tiny_serial_send_timeout(tiny_serial_handle_t port, const void *buf, int len, uint32_t timeout_ms);
114 
125  extern int tiny_serial_read(tiny_serial_handle_t port, void *buf, int len);
126 
138  extern int tiny_serial_read_timeout(tiny_serial_handle_t port, void *buf, int len, uint32_t timeout_ms);
139 
144 #ifdef __cplusplus
145 }
146 #endif
int tiny_serial_read(tiny_serial_handle_t port, void *buf, int len)
Receive data from serial connection.
Definition: arduino_serial.inl:47
void tiny_serial_close(tiny_serial_handle_t port)
Closes serial connection.
Definition: arduino_serial.inl:24
int tiny_serial_send(tiny_serial_handle_t port, const void *buf, int len)
Sends data over serial connection.
Definition: arduino_serial.inl:36
int tiny_serial_read_timeout(tiny_serial_handle_t port, void *buf, int len, uint32_t timeout_ms)
Receive data from serial connection.
Definition: arduino_serial.inl:57
This is UART support implementation.
tiny_serial_handle_t tiny_serial_open(const char *name, uint32_t baud)
Opens serial port.
Definition: arduino_serial.inl:29
int tiny_serial_send_timeout(tiny_serial_handle_t port, const void *buf, int len, uint32_t timeout_ms)
Sends data over serial connection.
Definition: arduino_serial.inl:41