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/Communicator/Communicator.cpp

48 lines
No EOL
1.1 KiB
C++

#include <Communicator.h>
Communicator::Communicator(__SIZE_TYPE__ bufferSize)
{
this->messageBuffer = new char[bufferSize];
this->bufferSize = bufferSize;
}
char *Communicator::getBuffer()
{
return messageBuffer;
}
int Communicator::getBufferSize()
{
return this->bufferSize;
}
__SIZE_TYPE__ Communicator::calculateMessageOutSize(__SIZE_TYPE__ numberOfValues)
{
return numberOfValues + (numberOfValues - 1) + 1;
}
void Communicator::parseIDs(int *values, __SIZE_TYPE__ numberOfValues, char *output)
{
__SIZE_TYPE__ outputSize = calculateMessageOutSize(numberOfValues);
__SIZE_TYPE__ outputCharPointer = 0;
output[outputSize - 1] = '\0';
for (__SIZE_TYPE__ i = 0; i < numberOfValues; i++)
{
output[outputCharPointer++] = values[i] + '0';
if (outputCharPointer < outputSize - 1)
output[outputCharPointer++] = ',';
}
}
void Communicator::sendMessage(int *values, __SIZE_TYPE__ numberOfValues)
{
}
void Communicator::sendMessage(char *message)
{
}
char *Communicator::receiveMessage()
{
return nullptr;
}