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/Devices/Control/Firmware/lib/StreamCommunicator/StreamCommunicator.cpp

27 lines
No EOL
685 B
C++

#include <StreamCommunicator.h>
StreamCommunicator::StreamCommunicator(Stream &s_out, __SIZE_TYPE__ bufferSize) : Communicator(bufferSize), stream(s_out)
{
}
void StreamCommunicator::sendMessage(int *values, int numberOfValues)
{
char message[calculateMessageOutSize(numberOfValues)];
parseIDs(values, numberOfValues, message);
stream.println(message);
}
void StreamCommunicator::sendMessage(char *message)
{
stream.println(message);
}
char *StreamCommunicator::receiveMessage()
{
if (stream.available())
{
memset(getBuffer(), '\0', getBufferSize());
stream.readBytesUntil('\n', getBuffer(), getBufferSize());
}
return getBuffer();
}