Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 68 additions & 65 deletions FreeRTOSConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,52 +37,55 @@
* https://www.FreeRTOS.org/a00110.html
*----------------------------------------------------------*/

#define configUSE_PREEMPTION 1
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
#define configUSE_IDLE_HOOK 0
#define configUSE_TICK_HOOK 0
#define configUSE_DAEMON_TASK_STARTUP_HOOK 1
#define configTICK_RATE_HZ ( 100 ) /* In this non-real time simulated environment the tick frequency has to be at least a multiple of the Win32 tick frequency, and therefore very slow. */
#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 70 ) /* In this simulated case, the stack only has to hold one small structure as the real stack is part of the win32 thread. */
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 65 * 1024 ) )
#define configMAX_TASK_NAME_LEN ( 12 )
#define configUSE_TRACE_FACILITY 0
#define configUSE_16_BIT_TICKS 0
#define configIDLE_SHOULD_YIELD 1
#define configUSE_MUTEXES 1
#define configCHECK_FOR_STACK_OVERFLOW 0
#define configUSE_RECURSIVE_MUTEXES 1
#define configQUEUE_REGISTRY_SIZE 20
#define configUSE_APPLICATION_TASK_TAG 1
#define configUSE_COUNTING_SEMAPHORES 1
#define configUSE_ALTERNATIVE_API 0
#define configUSE_QUEUE_SETS 1
#define configUSE_TASK_NOTIFICATIONS 1
#define configSUPPORT_STATIC_ALLOCATION 0
#define configUSE_PREEMPTION 1
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
#define configUSE_IDLE_HOOK 0
#define configUSE_TICK_HOOK 0
#define configUSE_DAEMON_TASK_STARTUP_HOOK 1
#define configTICK_RATE_HZ \
(100) /* In this non-real time simulated environment the tick frequency has to be at least a multiple of the Win32 tick frequency, and therefore very slow. \
*/
#define configMINIMAL_STACK_SIZE \
((unsigned short)70) /* In this simulated case, the stack only has to hold one small structure as the real stack is part of the win32 thread. */
#define configTOTAL_HEAP_SIZE ((size_t)(65 * 1024))
#define configMAX_TASK_NAME_LEN (12)
#define configUSE_TRACE_FACILITY 0
#define configUSE_16_BIT_TICKS 0
#define configIDLE_SHOULD_YIELD 1
#define configUSE_MUTEXES 1
#define configCHECK_FOR_STACK_OVERFLOW 0
#define configUSE_RECURSIVE_MUTEXES 1
#define configQUEUE_REGISTRY_SIZE 20
#define configUSE_APPLICATION_TASK_TAG 1
#define configUSE_COUNTING_SEMAPHORES 1
#define configUSE_ALTERNATIVE_API 0
#define configUSE_QUEUE_SETS 1
#define configUSE_TASK_NOTIFICATIONS 1
#define configSUPPORT_STATIC_ALLOCATION 0

/* Software timer related configuration options. The maximum possible task
priority is configMAX_PRIORITIES - 1. The priority of the timer task is
deliberately set higher to ensure it is correctly capped back to
configMAX_PRIORITIES - 1. */
#define configUSE_TIMERS 0
#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )
#define configTIMER_QUEUE_LENGTH 20
#define configTIMER_TASK_STACK_DEPTH ( configMINIMAL_STACK_SIZE * 2 )
#define configUSE_TIMERS 0
#define configTIMER_TASK_PRIORITY (configMAX_PRIORITIES - 1)
#define configTIMER_QUEUE_LENGTH 20
#define configTIMER_TASK_STACK_DEPTH (configMINIMAL_STACK_SIZE * 2)

#define configMAX_PRIORITIES ( 7 )
#define configMAX_PRIORITIES (7)

/* Run time stats gathering configuration options. */
#define configGENERATE_RUN_TIME_STATS 0
#define configGENERATE_RUN_TIME_STATS 0

/* Co-routine related configuration options. */
#define configUSE_CO_ROUTINES 0
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
#define configUSE_CO_ROUTINES 0
#define configMAX_CO_ROUTINE_PRIORITIES (2)

/* This demo can use of one or more example stats formatting functions. These
format the raw data provided by the uxTaskGetSystemState() function in to human
readable ASCII form. See the notes in the implementation of vTaskList() within
FreeRTOS/Source/tasks.c for limitations. */
#define configUSE_STATS_FORMATTING_FUNCTIONS 0
#define configUSE_STATS_FORMATTING_FUNCTIONS 0

/* Enables the test whereby a stack larger than the total heap size is
requested. */
Expand All @@ -91,31 +94,31 @@ requested. */
/* Set the following definitions to 1 to include the API function, or zero
to exclude the API function. In most cases the linker will remove unused
functions anyway. */
#define INCLUDE_vTaskPrioritySet 1
#define INCLUDE_uxTaskPriorityGet 1
#define INCLUDE_vTaskDelete 1
#define INCLUDE_vTaskCleanUpResources 0
#define INCLUDE_vTaskSuspend 1
#define INCLUDE_vTaskDelayUntil 1
#define INCLUDE_vTaskDelay 1
#define INCLUDE_uxTaskGetStackHighWaterMark 1
#define INCLUDE_uxTaskGetStackHighWaterMark2 1
#define INCLUDE_xTaskGetSchedulerState 1
#define INCLUDE_xTimerGetTimerDaemonTaskHandle 1
#define INCLUDE_xTaskGetIdleTaskHandle 1
#define INCLUDE_xTaskGetHandle 1
#define INCLUDE_eTaskGetState 1
#define INCLUDE_xSemaphoreGetMutexHolder 1
#define INCLUDE_xTimerPendFunctionCall 0
#define INCLUDE_xTaskAbortDelay 1

#define configINCLUDE_MESSAGE_BUFFER_AMP_DEMO 0
#if ( configINCLUDE_MESSAGE_BUFFER_AMP_DEMO == 1 )
extern void vGenerateCoreBInterrupt( void * xUpdatedMessageBuffer );
#define sbSEND_COMPLETED( pxStreamBuffer ) vGenerateCoreBInterrupt( pxStreamBuffer )
#define INCLUDE_vTaskPrioritySet 1
#define INCLUDE_uxTaskPriorityGet 1
#define INCLUDE_vTaskDelete 1
#define INCLUDE_vTaskCleanUpResources 0
#define INCLUDE_vTaskSuspend 1
#define INCLUDE_vTaskDelayUntil 1
#define INCLUDE_vTaskDelay 1
#define INCLUDE_uxTaskGetStackHighWaterMark 1
#define INCLUDE_uxTaskGetStackHighWaterMark2 1
#define INCLUDE_xTaskGetSchedulerState 1
#define INCLUDE_xTimerGetTimerDaemonTaskHandle 1
#define INCLUDE_xTaskGetIdleTaskHandle 1
#define INCLUDE_xTaskGetHandle 1
#define INCLUDE_eTaskGetState 1
#define INCLUDE_xSemaphoreGetMutexHolder 1
#define INCLUDE_xTimerPendFunctionCall 0
#define INCLUDE_xTaskAbortDelay 1

#define configINCLUDE_MESSAGE_BUFFER_AMP_DEMO 0
#if (configINCLUDE_MESSAGE_BUFFER_AMP_DEMO == 1)
extern void vGenerateCoreBInterrupt(void* xUpdatedMessageBuffer);
#define sbSEND_COMPLETED(pxStreamBuffer) vGenerateCoreBInterrupt(pxStreamBuffer)
#endif /* configINCLUDE_MESSAGE_BUFFER_AMP_DEMO */

extern void vAssertCalled( unsigned long ulLine, const char * const pcFileName );
extern void vAssertCalled(unsigned long ulLine, const char* const pcFileName);

/* projCOVERAGE_TEST should be defined on the command line so this file can be
used with multiple project configurations. If it is
Expand All @@ -125,28 +128,28 @@ used with multiple project configurations. If it is
#error projCOVERAGE_TEST should be defined to 1 or 0 on the command line.
#endif

#if( projCOVERAGE_TEST == 1 )
#if (projCOVERAGE_TEST == 1)
/* Insert NOPs in empty decision paths to ensure both true and false paths
are being tested. */
#define mtCOVERAGE_TEST_MARKER() __asm volatile( "NOP" )
are being tested. */
#define mtCOVERAGE_TEST_MARKER() __asm volatile("NOP")

/* Ensure the tick count overflows during the coverage test. */
#define configINITIAL_TICK_COUNT 0xffffd800UL
/* Ensure the tick count overflows during the coverage test. */
#define configINITIAL_TICK_COUNT 0xffffd800UL

/* Allows tests of trying to allocate more than the heap has free. */
#define configUSE_MALLOC_FAILED_HOOK 0
/* Allows tests of trying to allocate more than the heap has free. */
#define configUSE_MALLOC_FAILED_HOOK 0

/* To test builds that remove the static qualifier for debug builds. */
#define portREMOVE_STATIC_QUALIFIER
/* To test builds that remove the static qualifier for debug builds. */
#define portREMOVE_STATIC_QUALIFIER
#else
/* It is a good idea to define configASSERT() while developing. configASSERT()
uses the same semantics as the standard C assert() macro. Don't define
configASSERT() when performing code coverage tests though, as it is not
intended to asserts() to fail, some some code is intended not to run if no
errors are present. */
#define configASSERT( x ) if( ( x ) == 0 )
#define configASSERT(x) if ((x) == 0)

#define configUSE_MALLOC_FAILED_HOOK 0
#define configUSE_MALLOC_FAILED_HOOK 0

/* Include the FreeRTOS+Trace FreeRTOS trace macro definitions. */
#endif
Expand Down
25 changes: 24 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Prepare your topic .json file (see [topic definition]#Defining-messages) with yo
Run:

```
umsg-gen -d '\messages' -o '\umsg_lib'
umsg-gen -d '\messages' -o '\umsg_lib' -l
```

## Add to CMake Project
Expand Down Expand Up @@ -237,6 +237,29 @@ typedef struct {

All of the topic.json files should be grouped in a single directory. which are then passed to the umsg-gen generator.

# Logging support
The library has a logging support that can be enabled by -l, if you use this, you will get two new types of functions:

```c
uint32_t umsg_sensors_imu_serialize(umsg_sensors_imu_t* data, uint8_t* buffer);
```
This function will put the message into a buffer and will tell you how many bytes from the buffer were used, so you can log in onto an SD card or some other storage system.
The message will be stored as (message class enum, message type enum, message). eg. (UMSG_SENSORS, SENSORS_IMU, struct umsg_sensors_imu_t). The endianity if dependent on the processor for now.

```c
uint8_t umsg_sensors_imu_deserialize(umsg_sensors_imu_t* data,uint8_t* buffer);
```
This function will put the message from a buffer back into struct and it will check if the message class and message type are correct for this type of message, it will also be indicated by the return value of the function.

For now, it is assumed that there are no more than 256 message classes and no more than 256 types of message in a class, this constaint will be fixed in the future.

This option also generated log_parser folder that contains cpp code and CMakeLists that when compiled is able to read the stored messages and write them to .csv files, the structure of the generated files is given as:

```
logfilename/message_class/message_type.csv;
```


# uMsg-Graph
(Work in Progress)

Expand Down
91 changes: 42 additions & 49 deletions tests/freertos/test_length.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,60 +4,53 @@
#include <umsg_test.h>
#include <stdlib.h>

#define QUEUE_LENGTH 5
#define QUEUE_LENGTH 5

static void main_task(void* params);

int main( void )
{
// single task which will publish messages and then read them back
xTaskCreate(main_task, "main_task", 1000, NULL, 1, NULL);
vTaskStartScheduler();
int main(void) {
// single task which will publish messages and then read them back
xTaskCreate(main_task, "main_task", 1000, NULL, 1, NULL);
vTaskStartScheduler();

return 0;
return 0;
}

static void main_task(void* params)
{
umsg_sub_handle_t sub_1 = umsg_test_uints_subscribe(1,1); // queue size of 1 (always latest message)
umsg_sub_handle_t sub_5 = umsg_test_uints_subscribe(1,QUEUE_LENGTH); // queue size of 5 (keeps 5 earliest messages)
umsg_test_uints_t msg_tx;
umsg_test_uints_t msg_rx;
while(1) {
// publish message 10 times
for(uint8_t counter = 1; counter <= 10; counter++)
{
msg_tx.u8 = counter;
umsg_test_uints_publish(&msg_tx);
vTaskDelay(pdMS_TO_TICKS(10));
}

// receive messages of sub1 untill timeout
while(umsg_test_uints_receive(sub_1,&msg_rx,0) == pdTRUE)
{
printf("Received message from queue size of 1: %d\n",msg_rx.u8);
}

// value should be equal to last sent message
if(msg_rx.u8 != msg_tx.u8)
{
printf("Received message does not match last sent message!\n");
exit(1);
}

// receive messages of sub 5 untill timeout
while(umsg_test_uints_receive(sub_5,&msg_rx, pdMS_TO_TICKS(10)) == pdTRUE)
{
printf("Received message from queue size of 5: %d\n",msg_rx.u8);
}

// counter should on reach to the size of queue. messages sent after are lost.
if(msg_rx.u8 != QUEUE_LENGTH)
{
printf("Received message does not match queue length!\n");
exit(1);
}

exit(0);
static void main_task(void* params) {
umsg_sub_handle_t sub_1 = umsg_test_uints_subscribe(1, 1); // queue size of 1 (always latest message)
umsg_sub_handle_t sub_5 = umsg_test_uints_subscribe(1, QUEUE_LENGTH); // queue size of 5 (keeps 5 earliest messages)
umsg_test_uints_t msg_tx;
umsg_test_uints_t msg_rx;
while (1) {
// publish message 10 times
for (uint8_t counter = 1; counter <= 10; counter++) {
msg_tx.u8 = counter;
umsg_test_uints_publish(&msg_tx);
vTaskDelay(pdMS_TO_TICKS(10));
}

// receive messages of sub1 untill timeout
while (umsg_test_uints_receive(sub_1, &msg_rx, 0) == pdTRUE) {
printf("Received message from queue size of 1: %d\n", msg_rx.u8);
}

// value should be equal to last sent message
if (msg_rx.u8 != msg_tx.u8) {
printf("Received message does not match last sent message!\n");
exit(1);
}

// receive messages of sub 5 untill timeout
while (umsg_test_uints_receive(sub_5, &msg_rx, pdMS_TO_TICKS(10)) == pdTRUE) {
printf("Received message from queue size of 5: %d\n", msg_rx.u8);
}

// counter should on reach to the size of queue. messages sent after are lost.
if (msg_rx.u8 != QUEUE_LENGTH) {
printf("Received message does not match queue length!\n");
exit(1);
}

exit(0);
}
}
Loading
Loading