This repository has been archived on 2023-12-22. You can view files and clone it, but cannot push or open issues or pull requests.
old-monorepo/modules/control/Firmware/lib/StreamCommunicator/StreamCommunicator.h

25 lines
683 B
C
Raw Normal View History

2022-02-04 16:01:30 +01:00
#include "Stream.h"
2022-02-05 20:50:54 +01:00
#ifndef _STREAM_COMMUNICATOR_INCLUDED_
#define _STREAM_COMMUNICATOR_INCLUDED_
2022-02-05 19:08:51 +01:00
class StreamCommunicator
2022-02-04 16:01:30 +01:00
{
protected:
Stream &stream;
2022-02-05 19:08:51 +01:00
char *messageBuffer;
__SIZE_TYPE__ bufferSize;
__SIZE_TYPE__ calculateMessageOutSize(__SIZE_TYPE__ numberOfValues);
void parseIDs(const int values[], __SIZE_TYPE__ numberOfValues, char *out);
2022-02-04 16:01:30 +01:00
public:
StreamCommunicator(Stream &s_out, __SIZE_TYPE__ bufferSize);
2022-02-05 19:08:51 +01:00
void sendMessage(int *values, __SIZE_TYPE__ numberOfValues);
void sendMessage(const char message[]);
2022-02-04 16:01:30 +01:00
char *receiveMessage();
2022-02-05 19:08:51 +01:00
char *getBuffer();
2022-02-05 20:50:54 +01:00
void clearBuffer();
2022-02-05 19:08:51 +01:00
int getBufferSize();
Stream *getStream();
2022-02-05 20:50:54 +01:00
};
#endif