27 lines
No EOL
685 B
C++
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();
|
|
} |