mirror of
https://github.com/thooge/esp32-nmea2000-obp60.git
synced 2025-12-14 06:23:07 +01:00
intermediate: udp reader
This commit is contained in:
@@ -21,7 +21,7 @@ GwBuffer::~GwBuffer(){
|
||||
}
|
||||
void GwBuffer::reset(String reason)
|
||||
{
|
||||
LOG_DEBUG(GwLog::LOG,"reseting buffer %s, reason %s",this->name.c_str(),reason.c_str());
|
||||
if (! reason.isEmpty())LOG_DEBUG(GwLog::LOG,"reseting buffer %s, reason %s",this->name.c_str(),reason.c_str());
|
||||
writePointer = buffer;
|
||||
readPointer = buffer;
|
||||
lp("reset");
|
||||
@@ -33,6 +33,16 @@ size_t GwBuffer::freeSpace()
|
||||
}
|
||||
return readPointer - writePointer - 1;
|
||||
}
|
||||
size_t GwBuffer::continousSpace() const{
|
||||
if (readPointer <= writePointer){
|
||||
return bufferSize-offset(writePointer);
|
||||
}
|
||||
return readPointer-writePointer-1;
|
||||
}
|
||||
void GwBuffer::moveWp(size_t offset){
|
||||
if (offset > continousSpace()) return;
|
||||
writePointer+=offset;
|
||||
}
|
||||
size_t GwBuffer::usedSpace()
|
||||
{
|
||||
if (readPointer <= writePointer)
|
||||
|
||||
@@ -33,7 +33,7 @@ class GwBuffer{
|
||||
uint8_t *buffer;
|
||||
uint8_t *writePointer;
|
||||
uint8_t *readPointer;
|
||||
size_t offset(uint8_t* ptr){
|
||||
size_t offset(uint8_t* ptr) const{
|
||||
return (size_t)(ptr-buffer);
|
||||
}
|
||||
GwLog *logger;
|
||||
@@ -54,6 +54,9 @@ class GwBuffer{
|
||||
* find the first occurance of x in the buffer, -1 if not found
|
||||
*/
|
||||
int findChar(char x);
|
||||
uint8_t *getWp(){return writePointer;}
|
||||
size_t continousSpace() const; //free space from wp
|
||||
void moveWp(size_t offset); //move the wp forward
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user