Problem with 3 Tasks and 2 queue
Hello!
I´m using Freertos some days ago…. And i want to create 3 tasks using 2 queue … the definition of the tasks and queues are
pParamEvento1 = ( Param_evento * )pvPortMalloc( sizeof(Param_evento ) );
pParamEvento1->xQueueEvento = xQueueCreate(LONG_COLA,sizeof(xMessage));
pParamEvento1->xBlockTime = xDontBlock;
pParamEvento1->mensaje.ucMessageID=1;
pParamEvento1->mensaje.ucData=0;
pParamEvento1->DelayTime = ( portTickType ) 200 / portTICK_RATE_MS;
pParamEvento2 = ( Param_evento * )pvPortMalloc( sizeof(Param_evento ) );
pParamEvento2->xQueueEvento = xQueueCreate(LONG_COLA,sizeof(xMessage));
pParamEvento2->xBlockTime = xDontBlock;
pParamEvento2->mensaje.ucMessageID=1;
pParamEvento2->mensaje.ucData=0;
pParamEvento2->DelayTime = ( portTickType ) 200 / portTICK_RATE_MS;
sTaskCreate( Task_Ruedas, ( const portCHAR * const ) "Ruedas", portMINIMAL_STACK_SIZE, ( void * ) pParamEvento2,mainTASK_RUEDAS, NULL );
sTaskCreate( Task_Telemetro, ( const portCHAR * const ) "Telemetro", portMINIMAL_STACK_SIZE, ( void * ) pParamEvento2,mainTASK_TELEMETRO, NULL );
sTaskCreate( Task_Main, ( const portCHAR * const ) "Main", portMINIMAL_STACK_SIZE, ( void * ) pParamEvento1,mainTASK_MAIN, NULL );
so the task Main has to send a parameters to Task Telemetro and whit this value Task Telemetro has to send other value to Task Ruedas….. y don´t know why the program is not working… Do yuo know if i have to use a semophore or something like that to make little bit organize everything??
thanks so mucho for your help…..I was trying anything but it doesn´t work.
Thanks again for your help!!
Regards,
Adriana
Problem with 3 Tasks and 2 queue
There is nothing obviously wrong in the code you have posted, but you do not show how you use the queues.
It might be that you are using a pointer incorrectly somewhere. You could declare things statically rather than dynamically. Did you copy the code from blockq.c? It seems similar. Can you get the BlockQ demo task working then adapt it for your application?
Regards.
Problem with 3 Tasks and 2 queue
Hello, thanks for your help… yes i do, i use the declaration in Blockq for create my tasks…. but i can´t understand wich is my error….
I´m posting the most important code of each tasks, where i´m using the queues…. there is no problem when i have two tasks and one queue the program ran ok… but now i have to add more tasks with differents queues but the program doesn´t work well…
static void Task_Main( void *pvParameters )
{
portTickType xDelayTime = mainNO_ERROR_CHECK_PERIOD;
Param_evento *pParamEvento, ParamEvento;
char mensaje_e, mensaje_enviado=1;
xMessage *pxMessage, Message;
pParamEvento = (Param_evento *) pvParameters;
ParamEvento=*pParamEvento;
Message=*pxMessage;
Message= ParamEvento->mensaje;
Message.ucMessageID=2;
Message.ucData=0;
for(;;)
{
if( cQueueSend( ParamEvento.xQueueEvento,( void * ) &Message, pParamEvento->xBlockTime ) != pdPASS )
{
mensaje_enviado=0;
}
else mensaje_enviado=1;
vTaskDelay(ParamEvento.DelayTime);
}
}
static void Task_Telemetro( void *pvParameters )
{
int fin=0;
int stop=0;
portTickType xDelayTime = mainNO_ERROR_CHECK_PERIOD;
Param_evento *pParamEvento, ParamEvento;
char mensaje_e, mensaje_enviado=1;
xMessage *pxMessage, Message;
pParamEvento = (Param_evento *) pvParameters;
ParamEvento=*pParamEvento;
Message=*pxMessage;
Message= ParamEvento->mensaje;
Message.ucMessageID=2;
Message.ucData=0;
for(;;)
{
if(fin==0)
{
if(cQueueReceive( ParamEvento.xQueueEvento, (void *)&Message, ParamEvento.xBlockTime ) == pdPASS)
{
switch(Message.ucMessageID)
{
case 1:
stop=0;
break;
case 6:
fin=1;
break;
}
}
else if(stop==0) {
if(cQueueReceive( ParamEvento.xQueueEvento, (void *)&Message, ParamEvento.xBlockTime ) == pdPASS)
{
switch(Message.ucMessageID)
{
//differents cases……………..
}
}
vTaskDelay(ParamEvento.DelayTime);
}
}
}
}
static void Task_Ruedas( void *pvParameters )
{
int prueba=0;
char usDataRxEvento=0;
char dat=0;
xMessage *pxMessageRx, MessageRx;
portTickType xDelayTime = mainNO_ERROR_CHECK_PERIOD;
Param_evento *pxParamEvent, ParamEvento;
pxParamEvent= (Param_evento *) pvParameters;
ParamEvento=*pxParamEvent;
MessageRx=*pxMessageRx;
DUTY_PWM1=400;
DUTY_PWM2=400;
direccion=1;
Configuracion_PWM();
for(;;)
{
if(cQueueReceive( ParamEvento.xQueueEvento, (void *)&MessageRx, ParamEvento.xBlockTime ) == pdPASS)
{
switch( MessageRx.ucData )
{
//differents cases….
}
}
}
}
Thanks so much for your help i´m very worried about that, i´m very daleyed with my project….
Thanks again and have a nice day!…
Regards,
Adriana
Problem with 3 Tasks and 2 queue
Hello! Hpw are you?
I couldn´t find the error and the 3 tasks don´t work well…. CAn you help me please i´m very worried about that i don´t know what else can i do to make it works?
Would you have aby idea that can help me ??
Thanks so much for your help!
Regards,
Adriana