Adding Code for freeRTOS

This commit is contained in:
2018-07-13 15:56:37 +02:00
parent d1bc3a71a1
commit db1f93a155
37 changed files with 1332 additions and 73 deletions

View File

@ -2,8 +2,8 @@
#include <framework/serviceinterface/ServiceInterfaceBuffer.h>
#include <cstring>
//TODO Think of something different
#include <framework/osal/rtems/Interrupt.h>
// to be implemented by bsp
extern "C" void printChar(const char*);
int ServiceInterfaceBuffer::overflow(int c) {
// Handle output
@ -28,7 +28,7 @@ int ServiceInterfaceBuffer::sync(void) {
this->log_message.c_str(), (unsigned long) loggerTime.hour,
(unsigned long) loggerTime.minute,
(unsigned long) loggerTime.second,
(unsigned long) loggerTime.ticks);
(unsigned long) loggerTime.usecond /1000);
// Write log_message and time
this->putChars(preamble, preamble + sizeof(preamble));
// Handle output
@ -39,6 +39,27 @@ int ServiceInterfaceBuffer::sync(void) {
return 0;
}
ServiceInterfaceBuffer::ServiceInterfaceBuffer(std::string set_message, uint16_t port) {
this->log_message = set_message;
this->isActive = true;
setp( buf, buf + BUF_SIZE );
}
void ServiceInterfaceBuffer::putChars(char const* begin, char const* end) {
char array[BUF_SIZE];
uint32_t length = end - begin;
if (length > sizeof(array)) {
length = sizeof(array);
}
memcpy(array, begin, length);
for( ; begin != end; begin++){
printChar(begin);
}
}
#ifdef UT699
ServiceInterfaceBuffer::ServiceInterfaceBuffer(std::string set_message, uint16_t port) {
this->log_message = set_message;

View File

@ -6,6 +6,46 @@
#include <sstream>
#include <cstdio>
class ServiceInterfaceBuffer: public std::basic_streambuf<char,
std::char_traits<char> > {
friend class ServiceInterfaceStream;
public:
ServiceInterfaceBuffer(std::string set_message, uint16_t port);
protected:
bool isActive;
// This is called when buffer becomes full. If
// buffer is not used, then this is called every
// time when characters are put to stream.
virtual int overflow(int c = Traits::eof());
// This function is called when stream is flushed,
// for example when std::endl is put to stream.
virtual int sync(void);
private:
// For additional message information
std::string log_message;
// For EOF detection
typedef std::char_traits<char> Traits;
// Work in buffer mode. It is also possible to work without buffer.
static size_t const BUF_SIZE = 128;
char buf[BUF_SIZE];
// In this function, the characters are parsed.
void putChars(char const* begin, char const* end);
};
#ifdef UT699
class ServiceInterfaceBuffer: public std::basic_streambuf<char,
std::char_traits<char> > {