Revision 17d978fe
| inc/urt_core.h | ||
|---|---|---|
| 57 | 57 |
#endif /* URT_CFG_RPC_ENABLED */ |
| 58 | 58 |
}urt_core_t; |
| 59 | 59 |
|
| 60 |
static urt_core_t core; |
|
| 61 |
|
|
| 60 | 62 |
/******************************************************************************/ |
| 61 | 63 |
/* MACROS */ |
| 62 | 64 |
/******************************************************************************/ |
| inc/urt_debug.h | ||
|---|---|---|
| 1 |
/* |
|
| 2 |
µRtWare is a lightweight publish/subscribe middleware for real-time |
|
| 3 |
applications. It was developed as part of the software habitat for the |
|
| 4 |
Autonomous Mini Robot [1] (AMiRo) but can be used for other purposes as well. |
|
| 5 |
|
|
| 6 |
Copyright (C) 2018..2020 Thomas Schöpping et al. |
|
| 7 |
|
|
| 8 |
This program is free software: you can redistribute it and/or modify |
|
| 9 |
it under the terms of the GNU General Public License as published by |
|
| 10 |
the Free Software Foundation, either version 3 of the License, or |
|
| 11 |
(at your option) any later version. |
|
| 12 |
|
|
| 13 |
This program is distributed in the hope that it will be useful, |
|
| 14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 16 |
GNU General Public License for more details. |
|
| 17 |
|
|
| 18 |
You should have received a copy of the GNU General Public License |
|
| 19 |
along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
| 20 |
*/ |
|
| 21 |
|
|
| 22 |
#ifndef URT_DEBUG_H |
|
| 23 |
#define URT_DEBUG_H |
|
| 24 |
|
|
| 25 |
/******************************************************************************/ |
|
| 26 |
/* CONSTANTS */ |
|
| 27 |
/******************************************************************************/ |
|
| 28 |
|
|
| 29 |
/******************************************************************************/ |
|
| 30 |
/* SETTINGS */ |
|
| 31 |
/******************************************************************************/ |
|
| 32 |
|
|
| 33 |
/******************************************************************************/ |
|
| 34 |
/* CHECKS */ |
|
| 35 |
/******************************************************************************/ |
|
| 36 |
|
|
| 37 |
/******************************************************************************/ |
|
| 38 |
/* DATA STRUCTURES AND TYPES */ |
|
| 39 |
/******************************************************************************/ |
|
| 40 |
|
|
| 41 |
/******************************************************************************/ |
|
| 42 |
/* MACROS */ |
|
| 43 |
/******************************************************************************/ |
|
| 44 |
|
|
| 45 |
/******************************************************************************/ |
|
| 46 |
/* EXTERN DECLARATIONS */ |
|
| 47 |
/******************************************************************************/ |
|
| 48 |
|
|
| 49 |
#if defined(__cplusplus) |
|
| 50 |
extern "C" {
|
|
| 51 |
#endif /* defined(__cplusplus) */ |
|
| 52 |
|
|
| 53 |
void urtDebugAssert (bool condition); |
|
| 54 |
|
|
| 55 |
#if defined(__cplusplus) |
|
| 56 |
} |
|
| 57 |
#endif /* defined(__cplusplus) */ |
|
| 58 |
|
|
| 59 |
/******************************************************************************/ |
|
| 60 |
/* INLINE FUNCTIONS */ |
|
| 61 |
/******************************************************************************/ |
|
| 62 |
|
|
| 63 |
#endif /* URT_DEBUG_H */ |
|
| src/urt_core.c | ||
|---|---|---|
| 33 | 33 |
/* LOCAL TYPES */ |
| 34 | 34 |
/******************************************************************************/ |
| 35 | 35 |
|
| 36 |
urt_core_t core; |
|
| 37 |
|
|
| 38 | 36 |
/******************************************************************************/ |
| 39 | 37 |
/* LOCAL VARIABLES */ |
| 40 | 38 |
/******************************************************************************/ |
| ... | ... | |
| 103 | 101 |
*/ |
| 104 | 102 |
urt_status_t urtCoreSynchronizeNodes(urt_node_t* node) |
| 105 | 103 |
{
|
| 104 |
urtDebugAssert(node != NULL); |
|
| 105 |
|
|
| 106 | 106 |
urtMutexLock(&core._lock); |
| 107 | 107 |
node->stage -= 1; |
| 108 | 108 |
urt_node_t* nodeFromCore = core._nodes; |
| src/urt_node.c | ||
|---|---|---|
| 37 | 37 |
/* LOCAL VARIABLES */ |
| 38 | 38 |
/******************************************************************************/ |
| 39 | 39 |
|
| 40 |
urt_node_t localNode; //TODO:Correct? |
|
| 41 |
|
|
| 40 | 42 |
/******************************************************************************/ |
| 41 | 43 |
/* LOCAL FUNCTIONS */ |
| 42 | 44 |
/******************************************************************************/ |
| 43 | 45 |
|
| 46 |
/** |
|
| 47 |
* @brief Main function of a node. |
|
| 48 |
* |
|
| 49 |
* @param[in] arg Optional Argument to the thread main function. |
|
| 50 |
*/ |
|
| 51 |
void _main(void* arg) |
|
| 52 |
{
|
|
| 53 |
//TODO: Register to core event |
|
| 54 |
if (localNode.setupcallback != NULL) |
|
| 55 |
{
|
|
| 56 |
// urt_osEventMask_t mask = localNode.setupcallback(localNode, arg); |
|
| 57 |
// TODOs |
|
| 58 |
} |
|
| 59 |
else |
|
| 60 |
{
|
|
| 61 |
//TODO: act as if setupcallback returned 0xF..F |
|
| 62 |
} |
|
| 63 |
if (core._status == URT_STATUS_OK) |
|
| 64 |
{
|
|
| 65 |
//TODO: Suspend all child threads |
|
| 66 |
urtCoreSynchronizeNodes(&localNode); |
|
| 67 |
//TODO: Resume all child threads |
|
| 68 |
} |
|
| 69 |
//TODOs |
|
| 70 |
return; |
|
| 71 |
} |
|
| 72 |
|
|
| 44 | 73 |
/******************************************************************************/ |
| 45 | 74 |
/* EXPORTED FUNCTIONS */ |
| 46 | 75 |
/******************************************************************************/ |
| 47 | 76 |
|
| 48 | 77 |
/** |
| 49 |
* @brief Initalize the node.
|
|
| 78 |
* @brief Initalize a node.
|
|
| 50 | 79 |
* |
| 51 | 80 |
* @param[in] node The node to initialize. Must not be NULL. |
| 52 | 81 |
* @param[in] thread The already initialized, exclusive thread for the node. Must not be NULL. |
| ... | ... | |
| 69 | 98 |
void* setupparams, urt_nodeLoopCallback_t* loopcallback, void* loopparams, |
| 70 | 99 |
urt_nodeShutdownCallback_t* shutdowncallback, void* shutdownparams) |
| 71 | 100 |
{
|
| 101 |
urtDebugAssert(node != NULL); |
|
| 102 |
urtDebugAssert(thread != NULL); |
|
| 103 |
//TODO: Setupcallback |
|
| 104 |
if (setupcallback == NULL) |
|
| 105 |
urtDebugAssert(setupparams == NULL); |
|
| 106 |
urtDebugAssert(loopcallback != NULL); |
|
| 107 |
//urtDebugAssert(/*loopparams*/); |
|
| 108 |
//urtDebugAssert(shutdowncallback); |
|
| 109 |
//urtDebugAssert(shutdownparams); |
|
| 110 |
|
|
| 72 | 111 |
node->next = NULL; |
| 73 | 112 |
node->thread = thread; |
| 74 | 113 |
node->setupcallback = setupcallback; |
| ... | ... | |
| 82 | 121 |
#if (URT_CFG_PUBSUB_PROFILING || URT_CFG_RPC_PROFILING) |
| 83 | 122 |
node->loops = 0; |
| 84 | 123 |
#endif /* URT_CFG_PUBSUB_PROFILING || URT_CFG_RPC_PROFILING */ |
| 85 |
urt_core_t temp; //TODO: Correct?
|
|
| 86 |
urtMutexLock(&temp._lock);
|
|
| 87 |
node->next = temp._nodes;
|
|
| 88 |
temp._nodes = node;
|
|
| 89 |
urtMutexUnlock(&temp._lock);
|
|
| 124 |
urtMutexLock(&core._lock);
|
|
| 125 |
node->next = core._nodes;
|
|
| 126 |
core._nodes = node;
|
|
| 127 |
urtMutexUnlock(&core._lock);
|
|
| 128 |
localNode = *node;
|
|
| 90 | 129 |
return; |
| 91 | 130 |
} |
Also available in: Unified diff