renamed system context to call context

to avoid conflicts with ISIS library, I don't want to fiddle with
it if we don't have source code
This commit is contained in:
Robin Müller 2020-03-02 01:00:17 +01:00
parent fa38a37604
commit d0e8eb386c
7 changed files with 106 additions and 14 deletions

View File

@ -0,0 +1,9 @@
/**
* @file CommunicationMessage.cpp
*
* @date 28.02.2020
*/

View File

@ -0,0 +1,82 @@
/**
* @file CommunicationMessage.h
*
* @date 28.02.2020
*/
#ifndef FRAMEWORK_DEVICEHANDLERS_COMMUNICATIONMESSAGE_H_
#define FRAMEWORK_DEVICEHANDLERS_COMMUNICATIONMESSAGE_H_
#include <framework/ipc/MessageQueueMessage.h>
#include <framework/storagemanager/StorageManagerIF.h>
/**
* @brief Used to pass communication information between tasks
*
* @details
* Can be used to pass information like data pointers and
* data sizes between communication tasks
* like the Device Handler Comm Interfaces and Polling Tasks.
*
* Can also be used to exchange actual data if its not too large
* (e.g. Sensor values).
*
*/
class CommunicationMessage: public MessageQueueMessage {
public:
enum communicationStatus {
SEND_DATA,
PROCESS_DATA,
FAULTY,
};
//Add other messageIDs here if necessary.
static const uint8_t COMMUNICATION_MESSAGE_SIZE = HEADER_SIZE + 4 * sizeof(uint32_t);
CommunicationMessage();
/**
* Send requests with pointer to the data to be sent and send data length
* @param address Target Address
* @param sendData
* @param length
*/
void setSendRequest(uint32_t address, const uint8_t * sendData, uint32_t length);
/**
* Data message with data stored in IPC store
* @param address
* @param length
* @param storeId
*/
void setDataMessage(uint32_t address, uint32_t length, store_address_t * storeId);
/**
* Data message with data stored in actual message.
* 4 byte datafield is intialized with 0.
* Set data with specific setter functions.
*/
void setDataMessage(uint32_t address, uint32_t length);
private:
void setCommunicationStatus(communicationStatus status);
void setAddress(uint32_t address);
void setSendData(const uint8_t * sendData);
void setDataLen(uint32_t length);
/** For low size data, maximum of 4 bytes can be sent */
void setDataByte1(uint8_t byte1);
void setDataByte2(uint8_t byte2);
void setDataByte3(uint8_t byte3);
void setDataByte4(uint8_t byte4);
void setDataUINT16_1(uint16_t data1);
void setDataUINT16_2(uint16_t data2);
void setData(uint32_t data);
virtual ~CommunicationMessage();
};
#endif /* FRAMEWORK_DEVICEHANDLERS_COMMUNICATIONMESSAGE_H_ */

View File

@ -88,7 +88,7 @@ ReturnValue_t BinarySemaphore::giveBinarySemaphoreFromISR(SemaphoreHandle_t sema
if (returncode == pdPASS) {
if(*higherPriorityTaskWoken == pdPASS) {
// Request context switch
TaskManagement::requestContextSwitch(SystemContext::isr_context);
TaskManagement::requestContextSwitch(CallContext::isr);
}
return HasReturnvaluesIF::RETURN_OK;
} else {

View File

@ -6,7 +6,7 @@
// As a first step towards this, introduces system context variable which needs to be switched manually
// Haven't found function to find system context.
MessageQueue::MessageQueue(size_t message_depth, size_t max_message_size) :
defaultDestination(0),lastPartner(0), callContext(SystemContext::task_context) {
defaultDestination(0),lastPartner(0), callContext(CallContext::task) {
handle = xQueueCreate(message_depth, max_message_size);
if (handle == NULL) {
error << "MessageQueue creation failed" << std::endl;
@ -19,7 +19,7 @@ MessageQueue::~MessageQueue() {
}
}
void MessageQueue::switchSystemContext(SystemContext callContext) {
void MessageQueue::switchSystemContext(CallContext callContext) {
this->callContext = callContext;
}
@ -53,10 +53,10 @@ ReturnValue_t MessageQueue::sendMessageFrom(MessageQueueId_t sendTo,
ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo,
MessageQueueMessage *message, MessageQueueId_t sentFrom,
bool ignoreFault, SystemContext callContext) {
bool ignoreFault, CallContext callContext) {
message->setSender(sentFrom);
BaseType_t result;
if(callContext == SystemContext::task_context) {
if(callContext == CallContext::task) {
result = xQueueSendToBack(reinterpret_cast<void*>(sendTo),
reinterpret_cast<const void*>(message->getBuffer()), 0);
}

View File

@ -58,7 +58,7 @@ public:
*/
virtual ~MessageQueue();
void switchSystemContext(SystemContext callContext);
void switchSystemContext(CallContext callContext);
/**
* @brief This operation sends a message to the given destination.
@ -168,7 +168,7 @@ protected:
*/
static ReturnValue_t sendMessageFromMessageQueue(MessageQueueId_t sendTo,
MessageQueueMessage* message, MessageQueueId_t sentFrom = NO_QUEUE,
bool ignoreFault=false, SystemContext callContex = SystemContext::task_context);
bool ignoreFault=false, CallContext callContex = CallContext::task);
static ReturnValue_t handleSendResult(BaseType_t result, bool ignoreFault);
@ -177,7 +177,7 @@ private:
QueueHandle_t handle;
MessageQueueId_t defaultDestination;
MessageQueueId_t lastPartner;
SystemContext callContext; //!< Stores the current system context
CallContext callContext; //!< Stores the current system context
};
#endif /* MESSAGEQUEUE_H_ */

View File

@ -13,8 +13,8 @@ void TaskManagement::requestContextSwitchFromTask() {
vTaskDelay(0);
}
void TaskManagement::requestContextSwitch(SystemContext callContext = SystemContext::task_context) {
if(callContext == SystemContext::isr_context) {
void TaskManagement::requestContextSwitch(CallContext callContext = CallContext::task) {
if(callContext == CallContext::isr) {
// This function depends on the partmacro.h definition for the specific device
portYIELD_FROM_ISR();
} else {

View File

@ -12,9 +12,10 @@
* within an ISR or from a regular task. This is required because FreeRTOS
* has different functions for handling semaphores and messages from within an ISR and task.
*/
enum SystemContext {
task_context = 0x00,//!< task_context
isr_context = 0xFF //!< isr_context
enum CallContext {
task = 0x00,//!< task_context
isr = 0xFF //!< isr_context
};
class TaskManagement {
@ -25,7 +26,7 @@ public:
* This can be used if sending to the queue from an ISR caused a task to unblock
* and a context switch is required.
*/
static void requestContextSwitch(SystemContext callContext);
static void requestContextSwitch(CallContext callContext);
/**
* If task preemption in FreeRTOS is disabled, a context switch