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

introduce write lock for USB channel

This commit is contained in:
andreas
2024-11-24 16:07:27 +01:00
parent 874dcffba8
commit 8cb012eac0
4 changed files with 30 additions and 7 deletions

View File

@@ -4,6 +4,7 @@
#include "GwLog.h"
#include "GwBuffer.h"
#include "GwChannelInterface.h"
#include "GwSynchronized.h"
#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S3
#include "hal/usb_serial_jtag_ll.h"
#endif
@@ -26,8 +27,12 @@ class GwSerial : public GwChannelInterface{
virtual long getFlushTimeout(){return 2000;}
virtual int availableForWrite()=0;
int type=0;
SemaphoreHandle_t lock=nullptr;
public:
GwSerial(GwLog *logger,Stream *stream,int id,int type,bool allowRead=true);
void enableWriteLock(){
lock=xSemaphoreCreateMutex();
}
virtual ~GwSerial();
bool isInitialized();
virtual size_t sendToClients(const char *buf,int sourceId,bool partial=false);