renormalized line endings
This commit is contained in:
container
ArrayList.hDynamicFIFO.hFIFO.hFIFOBase.hFixedArrayList.hFixedMap.hHybridIterator.hIndexedRingMemoryArray.hPlacementFactory.hRingBufferBase.hSharedRingBuffer.cppSharedRingBuffer.hSimpleRingBuffer.cppSimpleRingBuffer.h
contrib/sgp4
controller
datapool
ControllerSet.cppControllerSet.hHkSwitchHelper.cppHkSwitchHelper.hPoolEntry.cppPoolEntry.hPoolEntryIF.hPoolRawAccessHelper.cppPoolRawAccessHelper.hPoolVarList.h
datapoolglob
DataPoolAdmin.cppDataPoolAdmin.hDataPoolParameterWrapper.cppDataPoolParameterWrapper.hGlobalDataPool.cppGlobalDataPool.hGlobalPoolVariable.hGlobalPoolVector.hPIDReader.hPIDReaderList.hPoolRawAccess.cppPoolRawAccess.h
datapoollocal
devicehandlers
AcceptsDeviceResponsesIF.hAssemblyBase.cppAssemblyBase.hChildHandlerBase.cppChildHandlerBase.hChildHandlerFDIR.cppChildHandlerFDIR.hCommunicationMessage.cppCommunicationMessage.hDeviceCommunicationIF.hDeviceHandlerIF.hDeviceHandlerMessage.cppDeviceHandlerMessage.hDeviceTmReportingWrapper.cppDeviceTmReportingWrapper.hHealthDevice.cppHealthDevice.h
fdir
ConfirmsFailuresIF.hEventCorrelation.cppEventCorrelation.hFailureIsolationBase.cppFailureIsolationBase.hFaultCounter.cppFaultCounter.h
globalfunctions
AsciiConverter.cppAsciiConverter.hCRC.cppDleEncoder.cppDleEncoder.hType.cppType.harrayprinter.cpp
matching
math
timevalOperations.cpphealth
HasHealthIF.hHealthHelper.cppHealthHelper.hHealthMessage.cppHealthMessage.hHealthTable.cppHealthTable.hHealthTableIF.hManagesHealthIF.h
housekeeping
internalError
ipc
CommandMessage.cppCommandMessage.hCommandMessageCleaner.cppCommandMessageCleaner.hCommandMessageIF.hMessageQueueIF.hMessageQueueMessage.cppMessageQueueMessage.hMessageQueueSenderIF.hMutexFactory.hMutexHelper.hMutexIF.hQueueFactory.h
memory
AcceptsMemoryMessagesIF.hFileSystemMessage.cppFileSystemMessage.hHasFileSystemIF.hHasMemoryIF.hMemoryHelper.cppMemoryHelper.hMemoryMessage.cppMemoryMessage.hMemoryProxyIF.h
modes
monitoring
AbsLimitMonitor.hHasMonitorsIF.hLimitMonitor.hLimitViolationReporter.cppLimitViolationReporter.hMonitorBase.hMonitorReporter.hMonitoringIF.hMonitoringMessage.cppMonitoringMessage.hMonitoringMessageContent.hReceivesMonitoringReportsIF.hTriplexMonitor.hTwoValueLimitMonitor.h
objectmanager
osal
FreeRTOS
BinSemaphUsingTask.cppBinSemaphUsingTask.hBinarySemaphore.cppBinarySemaphore.hClock.cppCountingSemaphUsingTask.cppCountingSemaphUsingTask.hCountingSemaphore.cppCountingSemaphore.hFixedTimeslotTask.cppFixedTimeslotTask.hMessageQueue.hMutex.cppMutex.hMutexFactory.cppQueueFactory.cppSemaphoreFactory.cppTaskFactory.cppTaskManagement.cppTaskManagement.hTimekeeper.cppTimekeeper.h
InternalErrorCodes.hhost
Clock.cppFixedTimeslotTask.cppFixedTimeslotTask.hMessageQueue.cppMessageQueue.hMutex.cppMutex.hMutexFactory.cppPeriodicTask.cppPeriodicTask.hQueueFactory.cppQueueMapManager.cppQueueMapManager.hSemaphoreFactory.cppTaskFactory.cpp
linux
BinarySemaphore.cppBinarySemaphore.hClock.cppCountingSemaphore.cppCountingSemaphore.hFixedTimeslotTask.cppFixedTimeslotTask.hInternalErrorCodes.cppMessageQueue.cppMessageQueue.hMutex.cppMutex.hMutexFactory.cppPeriodicPosixTask.cppPeriodicPosixTask.hPosixThread.cppPosixThread.hQueueFactory.cppSemaphoreFactory.cppTaskFactory.cppTcUnixUdpPollingTask.cppTcUnixUdpPollingTask.hTimer.cppTmTcUnixUdpBridge.cppTmTcUnixUdpBridge.h
rtems
parameters
HasParametersIF.hParameterHelper.cppParameterHelper.hParameterMessage.cppParameterMessage.hParameterWrapper.cppParameterWrapper.hReceivesParameterMessagesIF.h
power
Fuse.cppFuse.hPowerComponent.cppPowerComponent.hPowerComponentIF.hPowerSensor.cppPowerSensor.hPowerSwitchIF.hPowerSwitcher.cppPowerSwitcher.h
pus
CService200ModeCommanding.cppCService200ModeCommanding.hCService201HealthCommanding.cppCService201HealthCommanding.hService1TelecommandVerification.cppService1TelecommandVerification.hService2DeviceAccess.cppService2DeviceAccess.hService5EventReporting.cppService5EventReporting.hService8FunctionManagement.cppService8FunctionManagement.h
servicepackets
returnvalues
rmap
RMAP.cppRMAP.hRMAPChannelIF.hRMAPCookie.cppRMAPCookie.hRmapDeviceCommunicationIF.cppRmapDeviceCommunicationIF.h
serialize
EndianConverter.hSerialArrayListAdapter.hSerialBufferAdapter.cppSerialBufferAdapter.hSerialFixedArrayListAdapter.hSerialLinkedListAdapter.hSerializeAdapter.hSerializeElement.hSerializeIF.h
serviceinterface
ServiceInterfaceBuffer.cppServiceInterfaceBuffer.hServiceInterfaceStream.cppServiceInterfaceStream.h
storagemanager
ConstStorageAccessor.cppConstStorageAccessor.hLocalPool.hPoolManager.hStorageAccessor.cppStorageAccessor.hStorageManagerIF.h
subsystem
tasks
ExecutableObjectIF.hFixedSequenceSlot.cppFixedSequenceSlot.hFixedSlotSequence.cppFixedSlotSequence.hFixedTimeslotTaskIF.hPeriodicTaskIF.hSemaphoreFactory.hSemaphoreIF.hTaskFactory.h
tcdistribution
CCSDSDistributor.cppCCSDSDistributor.hCCSDSDistributorIF.hPUSDistributor.cppPUSDistributor.hPUSDistributorIF.hTcDistributor.cppTcDistributor.hTcPacketCheck.cppTcPacketCheck.h
thermal
AbstractTemperatureSensor.cppAbstractTemperatureSensor.hAcceptsThermalMessagesIF.hCoreComponent.hHeater.cppHeater.hRedundantHeater.hTemperatureSensor.hThermalComponentIF.hThermalModule.cppThermalModule.hThermalMonitor.cppThermalMonitor.h
timemanager
CCSDSTime.cppCCSDSTime.hClock.hCountdown.cppCountdown.hReceivesTimeInfoIF.hStopwatch.cppStopwatch.hTimeMessage.cppTimeMessage.hTimeStamperIF.h
tmstorage
tmtcpacket
tmtcservices
AcceptsTelecommandsIF.hAcceptsTelemetryIF.hAcceptsVerifyMessageIF.hCommandingServiceBase.cppCommandingServiceBase.hPusServiceBase.cppPusServiceBase.hPusVerificationReport.cppPusVerificationReport.hSourceSequenceCounter.hTmTcBridge.cppTmTcBridge.hTmTcMessage.cppTmTcMessage.hVerificationReporter.cppVerificationReporter.h
@ -1,137 +1,137 @@
|
||||
#include "../../osal/linux/TcUnixUdpPollingTask.h"
|
||||
#include "../../globalfunctions/arrayprinter.h"
|
||||
|
||||
TcUnixUdpPollingTask::TcUnixUdpPollingTask(object_id_t objectId,
|
||||
object_id_t tmtcUnixUdpBridge, size_t frameSize,
|
||||
double timeoutSeconds): SystemObject(objectId),
|
||||
tmtcBridgeId(tmtcUnixUdpBridge) {
|
||||
|
||||
if(frameSize > 0) {
|
||||
this->frameSize = frameSize;
|
||||
}
|
||||
else {
|
||||
this->frameSize = DEFAULT_MAX_FRAME_SIZE;
|
||||
}
|
||||
|
||||
// Set up reception buffer with specified frame size.
|
||||
// For now, it is assumed that only one frame is held in the buffer!
|
||||
receptionBuffer.reserve(this->frameSize);
|
||||
receptionBuffer.resize(this->frameSize);
|
||||
|
||||
if(timeoutSeconds == -1) {
|
||||
receptionTimeout = DEFAULT_TIMEOUT;
|
||||
}
|
||||
else {
|
||||
receptionTimeout = timevalOperations::toTimeval(timeoutSeconds);
|
||||
}
|
||||
}
|
||||
|
||||
TcUnixUdpPollingTask::~TcUnixUdpPollingTask() {}
|
||||
|
||||
ReturnValue_t TcUnixUdpPollingTask::performOperation(uint8_t opCode) {
|
||||
// Poll for new UDP datagrams in permanent loop.
|
||||
while(1) {
|
||||
//! Sender Address is cached here.
|
||||
struct sockaddr_in senderAddress;
|
||||
socklen_t senderSockLen = 0;
|
||||
ssize_t bytesReceived = recvfrom(serverUdpSocket,
|
||||
receptionBuffer.data(), frameSize, receptionFlags,
|
||||
reinterpret_cast<sockaddr*>(&senderAddress), &senderSockLen);
|
||||
if(bytesReceived < 0) {
|
||||
// handle error
|
||||
sif::error << "TcSocketPollingTask::performOperation: Reception"
|
||||
"error." << std::endl;
|
||||
handleReadError();
|
||||
|
||||
continue;
|
||||
}
|
||||
// sif::debug << "TcSocketPollingTask::performOperation: " << bytesReceived
|
||||
// << " bytes received" << std::endl;
|
||||
|
||||
ReturnValue_t result = handleSuccessfullTcRead(bytesReceived);
|
||||
if(result != HasReturnvaluesIF::RETURN_FAILED) {
|
||||
|
||||
}
|
||||
tmtcBridge->registerCommConnect();
|
||||
tmtcBridge->checkAndSetClientAddress(senderAddress);
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
|
||||
ReturnValue_t TcUnixUdpPollingTask::handleSuccessfullTcRead(size_t bytesRead) {
|
||||
store_address_t storeId;
|
||||
ReturnValue_t result = tcStore->addData(&storeId,
|
||||
receptionBuffer.data(), bytesRead);
|
||||
// arrayprinter::print(receptionBuffer.data(), bytesRead);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::error << "TcSerialPollingTask::transferPusToSoftwareBus: Data "
|
||||
"storage failed" << std::endl;
|
||||
sif::error << "Packet size: " << bytesRead << std::endl;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
||||
TmTcMessage message(storeId);
|
||||
|
||||
result = MessageQueueSenderIF::sendMessage(targetTcDestination, &message);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::error << "Serial Polling: Sending message to queue failed"
|
||||
<< std::endl;
|
||||
tcStore->deleteData(storeId);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t TcUnixUdpPollingTask::initialize() {
|
||||
tcStore = objectManager->get<StorageManagerIF>(objects::TC_STORE);
|
||||
if (tcStore == nullptr) {
|
||||
sif::error << "TcSerialPollingTask::initialize: TC Store uninitialized!"
|
||||
<< std::endl;
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
}
|
||||
|
||||
tmtcBridge = objectManager->get<TmTcUnixUdpBridge>(tmtcBridgeId);
|
||||
if(tmtcBridge == nullptr) {
|
||||
sif::error << "TcSocketPollingTask::TcSocketPollingTask: Invalid"
|
||||
" TMTC bridge object!" << std::endl;
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
}
|
||||
|
||||
serverUdpSocket = tmtcBridge->serverSocket;
|
||||
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t TcUnixUdpPollingTask::initializeAfterTaskCreation() {
|
||||
// Initialize the destination after task creation. This ensures
|
||||
// that the destination will be set in the TMTC bridge.
|
||||
targetTcDestination = tmtcBridge->getRequestQueue();
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
void TcUnixUdpPollingTask::setTimeout(double timeoutSeconds) {
|
||||
timeval tval;
|
||||
tval = timevalOperations::toTimeval(timeoutSeconds);
|
||||
int result = setsockopt(serverUdpSocket, SOL_SOCKET, SO_RCVTIMEO,
|
||||
&tval, sizeof(receptionTimeout));
|
||||
if(result == -1) {
|
||||
sif::error << "TcSocketPollingTask::TcSocketPollingTask: Setting "
|
||||
"receive timeout failed with " << strerror(errno) << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void TcUnixUdpPollingTask::handleReadError() {
|
||||
switch(errno) {
|
||||
case(EAGAIN): {
|
||||
// todo: When working in timeout mode, this will occur more often
|
||||
// and is not an error.
|
||||
sif::error << "TcUnixUdpPollingTask::handleReadError: Timeout."
|
||||
<< std::endl;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
sif::error << "TcUnixUdpPollingTask::handleReadError: "
|
||||
<< strerror(errno) << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
#include "../../osal/linux/TcUnixUdpPollingTask.h"
|
||||
#include "../../globalfunctions/arrayprinter.h"
|
||||
|
||||
TcUnixUdpPollingTask::TcUnixUdpPollingTask(object_id_t objectId,
|
||||
object_id_t tmtcUnixUdpBridge, size_t frameSize,
|
||||
double timeoutSeconds): SystemObject(objectId),
|
||||
tmtcBridgeId(tmtcUnixUdpBridge) {
|
||||
|
||||
if(frameSize > 0) {
|
||||
this->frameSize = frameSize;
|
||||
}
|
||||
else {
|
||||
this->frameSize = DEFAULT_MAX_FRAME_SIZE;
|
||||
}
|
||||
|
||||
// Set up reception buffer with specified frame size.
|
||||
// For now, it is assumed that only one frame is held in the buffer!
|
||||
receptionBuffer.reserve(this->frameSize);
|
||||
receptionBuffer.resize(this->frameSize);
|
||||
|
||||
if(timeoutSeconds == -1) {
|
||||
receptionTimeout = DEFAULT_TIMEOUT;
|
||||
}
|
||||
else {
|
||||
receptionTimeout = timevalOperations::toTimeval(timeoutSeconds);
|
||||
}
|
||||
}
|
||||
|
||||
TcUnixUdpPollingTask::~TcUnixUdpPollingTask() {}
|
||||
|
||||
ReturnValue_t TcUnixUdpPollingTask::performOperation(uint8_t opCode) {
|
||||
// Poll for new UDP datagrams in permanent loop.
|
||||
while(1) {
|
||||
//! Sender Address is cached here.
|
||||
struct sockaddr_in senderAddress;
|
||||
socklen_t senderSockLen = 0;
|
||||
ssize_t bytesReceived = recvfrom(serverUdpSocket,
|
||||
receptionBuffer.data(), frameSize, receptionFlags,
|
||||
reinterpret_cast<sockaddr*>(&senderAddress), &senderSockLen);
|
||||
if(bytesReceived < 0) {
|
||||
// handle error
|
||||
sif::error << "TcSocketPollingTask::performOperation: Reception"
|
||||
"error." << std::endl;
|
||||
handleReadError();
|
||||
|
||||
continue;
|
||||
}
|
||||
// sif::debug << "TcSocketPollingTask::performOperation: " << bytesReceived
|
||||
// << " bytes received" << std::endl;
|
||||
|
||||
ReturnValue_t result = handleSuccessfullTcRead(bytesReceived);
|
||||
if(result != HasReturnvaluesIF::RETURN_FAILED) {
|
||||
|
||||
}
|
||||
tmtcBridge->registerCommConnect();
|
||||
tmtcBridge->checkAndSetClientAddress(senderAddress);
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
|
||||
ReturnValue_t TcUnixUdpPollingTask::handleSuccessfullTcRead(size_t bytesRead) {
|
||||
store_address_t storeId;
|
||||
ReturnValue_t result = tcStore->addData(&storeId,
|
||||
receptionBuffer.data(), bytesRead);
|
||||
// arrayprinter::print(receptionBuffer.data(), bytesRead);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::error << "TcSerialPollingTask::transferPusToSoftwareBus: Data "
|
||||
"storage failed" << std::endl;
|
||||
sif::error << "Packet size: " << bytesRead << std::endl;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
||||
TmTcMessage message(storeId);
|
||||
|
||||
result = MessageQueueSenderIF::sendMessage(targetTcDestination, &message);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::error << "Serial Polling: Sending message to queue failed"
|
||||
<< std::endl;
|
||||
tcStore->deleteData(storeId);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t TcUnixUdpPollingTask::initialize() {
|
||||
tcStore = objectManager->get<StorageManagerIF>(objects::TC_STORE);
|
||||
if (tcStore == nullptr) {
|
||||
sif::error << "TcSerialPollingTask::initialize: TC Store uninitialized!"
|
||||
<< std::endl;
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
}
|
||||
|
||||
tmtcBridge = objectManager->get<TmTcUnixUdpBridge>(tmtcBridgeId);
|
||||
if(tmtcBridge == nullptr) {
|
||||
sif::error << "TcSocketPollingTask::TcSocketPollingTask: Invalid"
|
||||
" TMTC bridge object!" << std::endl;
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
}
|
||||
|
||||
serverUdpSocket = tmtcBridge->serverSocket;
|
||||
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t TcUnixUdpPollingTask::initializeAfterTaskCreation() {
|
||||
// Initialize the destination after task creation. This ensures
|
||||
// that the destination will be set in the TMTC bridge.
|
||||
targetTcDestination = tmtcBridge->getRequestQueue();
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
void TcUnixUdpPollingTask::setTimeout(double timeoutSeconds) {
|
||||
timeval tval;
|
||||
tval = timevalOperations::toTimeval(timeoutSeconds);
|
||||
int result = setsockopt(serverUdpSocket, SOL_SOCKET, SO_RCVTIMEO,
|
||||
&tval, sizeof(receptionTimeout));
|
||||
if(result == -1) {
|
||||
sif::error << "TcSocketPollingTask::TcSocketPollingTask: Setting "
|
||||
"receive timeout failed with " << strerror(errno) << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void TcUnixUdpPollingTask::handleReadError() {
|
||||
switch(errno) {
|
||||
case(EAGAIN): {
|
||||
// todo: When working in timeout mode, this will occur more often
|
||||
// and is not an error.
|
||||
sif::error << "TcUnixUdpPollingTask::handleReadError: Timeout."
|
||||
<< std::endl;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
sif::error << "TcUnixUdpPollingTask::handleReadError: "
|
||||
<< strerror(errno) << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user