1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2025-02-19 23:46:02 +01:00

Revert "add RinStream::peek()"

This reverts commit 26fc11d1a6.
This commit is contained in:
Harald Barth 2022-07-31 09:23:02 +02:00
parent 2ad0d7ab76
commit 8916d1415f
2 changed files with 8 additions and 11 deletions

View File

@ -95,22 +95,21 @@ _count=prevCount+plength;
return plength; return plength;
} }
int RingStream::read(byte advance) { int RingStream::read() {
if (_flashInsert) { if (_flashInsert) {
// we are reading out of a flash string // we are reading out of a flash string
byte fb=GETFLASH(_flashInsert); byte fb=GETFLASH(_flashInsert);
_flashInsert+=advance; _flashInsert++;
if (fb) return fb; // we have a byte from the flash if (fb) return fb; // we have a byte from the flash
// flash insert complete, clear and drop through to next buffer byte // flash insert complete, clear and drop through to next buffer byte
_flashInsert=NULL; _flashInsert=NULL;
} }
if ((_pos_read==_pos_write) && !_overflow) return -1; // empty if ((_pos_read==_pos_write) && !_overflow) return -1; // empty
byte b=readRawByte(advance); byte b=readRawByte();
if (b!=FLASH_INSERT_MARKER) return b; if (b!=FLASH_INSERT_MARKER) return b;
// Detected a flash insert // Detected a flash insert
// read address bytes LSB first (size depends on CPU) // read address bytes LSB first (size depends on CPU)
if (advance == 0) readRawByte(); // read past it anyway
uintptr_t iFlash=0; uintptr_t iFlash=0;
for (byte f=0; f<sizeof(iFlash); f++) { for (byte f=0; f<sizeof(iFlash); f++) {
uintptr_t bf=readRawByte(); uintptr_t bf=readRawByte();
@ -120,12 +119,12 @@ int RingStream::read(byte advance) {
} }
_flashInsert=reinterpret_cast<char * >( iFlash); _flashInsert=reinterpret_cast<char * >( iFlash);
// and try again... so will read the first byte of the insert. // and try again... so will read the first byte of the insert.
return read(advance); return read();
} }
byte RingStream::readRawByte(byte advance) { byte RingStream::readRawByte() {
byte b=_buffer[_pos_read]; byte b=_buffer[_pos_read];
_pos_read+=advance; _pos_read++;
if (_pos_read==_len) _pos_read=0; if (_pos_read==_len) _pos_read=0;
_overflow=false; _overflow=false;
return b; return b;

View File

@ -39,8 +39,7 @@ class RingStream : public Print {
virtual int availableForWrite() override; virtual int availableForWrite() override;
using Print::write; using Print::write;
size_t printFlash(const FSH * flashBuffer); size_t printFlash(const FSH * flashBuffer);
inline int read() { return read(1); }; int read();
inline int peek() { return read(0); };
int count(); int count();
int freeSpace(); int freeSpace();
void mark(uint8_t b); void mark(uint8_t b);
@ -48,9 +47,8 @@ class RingStream : public Print {
uint8_t peekTargetMark(); uint8_t peekTargetMark();
void flush(); void flush();
void info(); void info();
byte readRawByte();
private: private:
int read(byte advance);
byte readRawByte(byte advance=1);
int _len; int _len;
int _pos_write; int _pos_write;
int _pos_read; int _pos_read;