retval replacements
This commit is contained in:
@ -14,6 +14,8 @@
|
||||
|
||||
#include "OBSWConfig.h"
|
||||
|
||||
using namespace returnvalue;
|
||||
|
||||
ScexUartReader::ScexUartReader(object_id_t objectId)
|
||||
: SystemObject(objectId),
|
||||
decodeRingBuf(4096, true),
|
||||
@ -58,7 +60,7 @@ ReturnValue_t ScexUartReader::performOperation(uint8_t operationCode) {
|
||||
sif::info << "Received " << bytesRead
|
||||
<< " bytes from the Solar Cell Experiment:" << std::endl;
|
||||
}
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
if (result != OK) {
|
||||
sif::warning << "ScexUartReader::performOperation: Passing data to DLE parser failed"
|
||||
<< std::endl;
|
||||
}
|
||||
@ -67,13 +69,13 @@ ReturnValue_t ScexUartReader::performOperation(uint8_t operationCode) {
|
||||
// task block comes here
|
||||
sif::info << "task was stopped" << std::endl;
|
||||
}
|
||||
return RETURN_OK;
|
||||
return OK;
|
||||
}
|
||||
|
||||
ReturnValue_t ScexUartReader::initializeInterface(CookieIF *cookie) {
|
||||
UartCookie *uartCookie = dynamic_cast<UartCookie *>(cookie);
|
||||
if (uartCookie == nullptr) {
|
||||
return RETURN_FAILED;
|
||||
return FAILED;
|
||||
}
|
||||
std::string devname = uartCookie->getDeviceFile();
|
||||
/* Get file descriptor */
|
||||
@ -81,7 +83,7 @@ ReturnValue_t ScexUartReader::initializeInterface(CookieIF *cookie) {
|
||||
if (serialPort < 0) {
|
||||
sif::warning << "ScexUartReader::initializeInterface: open call failed with error [" << errno
|
||||
<< ", " << strerror(errno) << std::endl;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
return FAILED;
|
||||
}
|
||||
// Setting up UART parameters
|
||||
tty.c_cflag &= ~PARENB; // Clear parity bit
|
||||
@ -111,46 +113,46 @@ ReturnValue_t ScexUartReader::initializeInterface(CookieIF *cookie) {
|
||||
}
|
||||
// Flush received and unread data
|
||||
tcflush(serialPort, TCIOFLUSH);
|
||||
return RETURN_OK;
|
||||
return OK;
|
||||
}
|
||||
|
||||
ReturnValue_t ScexUartReader::sendMessage(CookieIF *cookie, const uint8_t *sendData,
|
||||
size_t sendLen) {
|
||||
if (sendData == nullptr or sendLen == 0) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
return FAILED;
|
||||
}
|
||||
lock->lockMutex();
|
||||
if (state == States::NOT_READY or state == States::RUNNING) {
|
||||
lock->unlockMutex();
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
return FAILED;
|
||||
}
|
||||
state = States::RUNNING;
|
||||
lock->unlockMutex();
|
||||
size_t encodedLen = 0;
|
||||
ReturnValue_t result =
|
||||
dleEncoder.encode(sendData, sendLen, cmdbuf.data(), cmdbuf.size(), &encodedLen, true);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
if (result != OK) {
|
||||
sif::warning << "ScexUartReader::sendMessage: Encoding failed" << std::endl;
|
||||
return RETURN_FAILED;
|
||||
return FAILED;
|
||||
}
|
||||
arrayprinter::print(cmdbuf.data(), encodedLen);
|
||||
size_t bytesWritten = write(serialPort, cmdbuf.data(), encodedLen);
|
||||
if (bytesWritten != encodedLen) {
|
||||
sif::warning << "ScexUartReader::sendMessage: Sending ping command to solar experiment failed"
|
||||
<< std::endl;
|
||||
return RETURN_FAILED;
|
||||
return FAILED;
|
||||
}
|
||||
result = semaphore->release();
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
if (result != OK) {
|
||||
std::cout << "ScexUartReader::sendMessage: Releasing semaphore failed" << std::endl;
|
||||
}
|
||||
return RETURN_OK;
|
||||
return OK;
|
||||
}
|
||||
|
||||
ReturnValue_t ScexUartReader::getSendSuccess(CookieIF *cookie) { return RETURN_OK; }
|
||||
ReturnValue_t ScexUartReader::getSendSuccess(CookieIF *cookie) { return OK; }
|
||||
|
||||
ReturnValue_t ScexUartReader::requestReceiveMessage(CookieIF *cookie, size_t requestLen) {
|
||||
return RETURN_OK;
|
||||
return OK;
|
||||
}
|
||||
|
||||
void ScexUartReader::setDebugMode(bool enable) { this->debugMode = enable; }
|
||||
@ -158,10 +160,10 @@ void ScexUartReader::setDebugMode(bool enable) { this->debugMode = enable; }
|
||||
ReturnValue_t ScexUartReader::finish() {
|
||||
MutexGuard mg(lock);
|
||||
if (state == States::IDLE) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
return FAILED;
|
||||
}
|
||||
state = States::FINISH;
|
||||
return RETURN_OK;
|
||||
return OK;
|
||||
}
|
||||
|
||||
void ScexUartReader::foundDlePacketHandler(const ScexDleParser::Context &ctx) {
|
||||
@ -178,11 +180,11 @@ void ScexUartReader::handleFoundDlePacket(uint8_t *packet, size_t len) {
|
||||
// sif::info << "Detected DLE encoded packet with decoded size " << len << std::endl;
|
||||
MutexGuard mg(lock);
|
||||
ReturnValue_t result = ipcQueue.insert(len);
|
||||
if (result != RETURN_OK) {
|
||||
if (result != OK) {
|
||||
sif::warning << "ScexUartReader::handleFoundDlePacket: IPCQueue error" << std::endl;
|
||||
}
|
||||
result = ipcRingBuf.writeData(packet, len);
|
||||
if (result != RETURN_OK) {
|
||||
if (result != OK) {
|
||||
sif::warning << "ScexUartReader::handleFoundDlePacket: IPCRingBuf error" << std::endl;
|
||||
}
|
||||
}
|
||||
@ -192,13 +194,13 @@ ReturnValue_t ScexUartReader::readReceivedMessage(CookieIF *cookie, uint8_t **bu
|
||||
MutexGuard mg(lock);
|
||||
if (ipcQueue.empty()) {
|
||||
*size = 0;
|
||||
return RETURN_OK;
|
||||
return OK;
|
||||
}
|
||||
ipcQueue.retrieve(size);
|
||||
*buffer = ipcBuffer.data();
|
||||
ReturnValue_t result = ipcRingBuf.readData(ipcBuffer.data(), *size, true);
|
||||
if (result != RETURN_OK) {
|
||||
if (result != OK) {
|
||||
sif::warning << "ScexUartReader::readReceivedMessage: Reading RingBuffer failed" << std::endl;
|
||||
}
|
||||
return RETURN_OK;
|
||||
return OK;
|
||||
}
|
||||
|
Reference in New Issue
Block a user