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