Merge pull request #11297 from SteveCEvans/baro_state
[betaflight.git] / src / main / drivers / serial_tcp.h
blob4e70f242b0d97f791381bc7885744ba0d794f913
1 /*
2 * This file is part of Cleanflight and Betaflight.
4 * Cleanflight and Betaflight are free software. You can redistribute
5 * this software and/or modify this software under the terms of the
6 * GNU General Public License as published by the Free Software
7 * Foundation, either version 3 of the License, or (at your option)
8 * any later version.
10 * Cleanflight and Betaflight are distributed in the hope that they
11 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
12 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this software.
18 * If not, see <http://www.gnu.org/licenses/>.
21 #pragma once
23 #include <netinet/in.h>
24 #include <pthread.h>
25 #include "dyad.h"
27 #define RX_BUFFER_SIZE 1400
28 #define TX_BUFFER_SIZE 1400
30 typedef struct {
31 serialPort_t port;
32 uint8_t rxBuffer[RX_BUFFER_SIZE];
33 uint8_t txBuffer[TX_BUFFER_SIZE];
35 dyad_Stream *serv;
36 dyad_Stream *conn;
37 pthread_mutex_t txLock;
38 pthread_mutex_t rxLock;
39 bool connected;
40 uint16_t clientCount;
41 uint8_t id;
42 } tcpPort_t;
44 serialPort_t *serTcpOpen(int id, serialReceiveCallbackPtr rxCallback, void *rxCallbackData, uint32_t baudRate, portMode_e mode, portOptions_e options);
46 // tcpPort API
47 void tcpDataIn(tcpPort_t *instance, uint8_t* ch, int size);
48 void tcpDataOut(tcpPort_t *instance);
50 bool tcpIsStart(void);
51 bool* tcpGetUsed(void);
52 tcpPort_t* tcpGetPool(void);