Merge pull request 'ServiceInterfaceBuffer Bugfix #149' (#150) from gaisser_fix_service_interface_149 into master
This commit is contained in:
commit
a87a8f527f
@ -78,9 +78,9 @@ int ServiceInterfaceBuffer::sync(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
size_t preambleSize = 0;
|
size_t preambleSize = 0;
|
||||||
auto preamble = getPreamble(&preambleSize);
|
std::string* preamble = getPreamble(&preambleSize);
|
||||||
// Write logMessage and time
|
// Write logMessage and time
|
||||||
this->putChars(preamble.data(), preamble.data() + preambleSize);
|
this->putChars(preamble->data(), preamble->data() + preambleSize);
|
||||||
// Handle output
|
// Handle output
|
||||||
this->putChars(pbase(), pptr());
|
this->putChars(pbase(), pptr());
|
||||||
// This tells that buffer is empty again
|
// This tells that buffer is empty again
|
||||||
@ -92,7 +92,7 @@ bool ServiceInterfaceBuffer::isBuffered() const {
|
|||||||
return buffered;
|
return buffered;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ServiceInterfaceBuffer::getPreamble(size_t * preambleSize) {
|
std::string* ServiceInterfaceBuffer::getPreamble(size_t * preambleSize) {
|
||||||
Clock::TimeOfDay_t loggerTime;
|
Clock::TimeOfDay_t loggerTime;
|
||||||
Clock::getDateAndTime(&loggerTime);
|
Clock::getDateAndTime(&loggerTime);
|
||||||
size_t currentSize = 0;
|
size_t currentSize = 0;
|
||||||
@ -110,18 +110,18 @@ std::string ServiceInterfaceBuffer::getPreamble(size_t * preambleSize) {
|
|||||||
loggerTime.usecond /1000);
|
loggerTime.usecond /1000);
|
||||||
if(charCount < 0) {
|
if(charCount < 0) {
|
||||||
printf("ServiceInterfaceBuffer: Failure parsing preamble\r\n");
|
printf("ServiceInterfaceBuffer: Failure parsing preamble\r\n");
|
||||||
return "";
|
return &preamble;
|
||||||
}
|
}
|
||||||
if(charCount > MAX_PREAMBLE_SIZE) {
|
if(charCount > MAX_PREAMBLE_SIZE) {
|
||||||
printf("ServiceInterfaceBuffer: Char count too large for maximum "
|
printf("ServiceInterfaceBuffer: Char count too large for maximum "
|
||||||
"preamble size");
|
"preamble size");
|
||||||
return "";
|
return &preamble;
|
||||||
}
|
}
|
||||||
currentSize += charCount;
|
currentSize += charCount;
|
||||||
if(preambleSize != nullptr) {
|
if(preambleSize != nullptr) {
|
||||||
*preambleSize = currentSize;
|
*preambleSize = currentSize;
|
||||||
}
|
}
|
||||||
return preamble;
|
return &preamble;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ private:
|
|||||||
//! In this function, the characters are parsed.
|
//! In this function, the characters are parsed.
|
||||||
void putChars(char const* begin, char const* end);
|
void putChars(char const* begin, char const* end);
|
||||||
|
|
||||||
std::string getPreamble(size_t * preambleSize = nullptr);
|
std::string* getPreamble(size_t * preambleSize = nullptr);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -9,7 +9,7 @@ void ServiceInterfaceStream::setActive( bool myActive) {
|
|||||||
this->streambuf.isActive = myActive;
|
this->streambuf.isActive = myActive;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ServiceInterfaceStream::getPreamble() {
|
std::string* ServiceInterfaceStream::getPreamble() {
|
||||||
return streambuf.getPreamble();
|
return streambuf.getPreamble();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ public:
|
|||||||
* the unbuffered mode.
|
* the unbuffered mode.
|
||||||
* @return Preamle consisting of log message and timestamp.
|
* @return Preamle consisting of log message and timestamp.
|
||||||
*/
|
*/
|
||||||
std::string getPreamble();
|
std::string* getPreamble();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This prints an error with a preamble. Useful if using the unbuffered
|
* This prints an error with a preamble. Useful if using the unbuffered
|
||||||
|
Loading…
Reference in New Issue
Block a user