1
0
mirror of https://github.com/thooge/esp32-nmea2000-obp60.git synced 2025-12-16 07:23:07 +01:00

use nonblocking write for serial

This commit is contained in:
andreas
2021-10-25 21:20:41 +02:00
parent 8c02b21277
commit 60eabb05ab
5 changed files with 161 additions and 25 deletions

24
lib/serial/GwSerial.h Normal file
View File

@@ -0,0 +1,24 @@
#ifndef _GWSERIAL_H
#define _GWSERIAL_H
#include "driver/uart.h"
#include "GwLog.h"
#include "GwBuffer.h"
class SerialWriter;
class GwSerial{
private:
GwBuffer *buffer;
GwLog *logger;
SerialWriter *writer;
uart_port_t num;
bool initialized=false;
public:
static const int bufferSize=200;
GwSerial(GwLog *logger,uart_port_t num);
~GwSerial();
int setup(int baud,int rxpin,int txpin);
bool isInitialized();
size_t enqueue(const uint8_t *data, size_t len);
GwBuffer::WriteStatus write();
const char *read();
};
#endif