We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,498 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

RTOS problem

void main (void)
{
    /* create three message queue */
    mesgQueueId1 = msgQCreate(MAX_MESSAGES,MAX_MESSAGE_LENGTH,MSG_Q_FIFO);



        if((taskIdOne = taskSpawn("t1",90,0x100,20000,(FUNCPTR)t1,0,0,0,0,0,0,0,0,0,0)) == ERROR)
            printf("generating task1 failed\n");
        if((taskIdThree = taskSpawn("t3",90,0x100,20000,(FUNCPTR)taskThrees,0,0,0,0,0,0,0,0,0,0)) == ERROR)
            printf("generating task3 failed\n");

}


void t1(void) 
{

    timer_t task1;

struct itimerspec value;


value.it_value.tv_sec = 3;
value.it_value.tv_nsec = 0;

value.it_interval.tv_sec = 3;
value.it_interval.tv_nsec = 0;


timer_create (CLOCK_REALTIME, NULL, &task1);
timer_connect (task1, task_1_timers,0);
timer_settime (task1, 0, &value, NULL);
while(1)
    sleep(1);
}


void task_1_timers ( timer_t timerid,int myarg )
{


    char message[] = "ta";
    printf (" task1-3sec\n");

    if((msgQSend(mesgQueueId1,message,MAX_MESSAGE_LENGTH, WAIT_FOREVER,MSG_PRI_NORMAL)) == ERROR)
        printf("msgQSend in taskOne failed\n");     

}





void taskThrees(void) 
{
char msgBuf[MAX_MESSAGE_LENGTH];

// receive message from task1
if(msgQReceive(mesgQueueId1,msgBuf,MAX_MESSAGE_LENGTH, WAIT_FOREVER)== ERROR)
    printf("msgQReceive in taskTwo failed\n");
    else
    printf("%s\n",msgBuf);      
msgQDelete(mesgQueueId1); /* terminate and free a message queue */
}

output:
task1-3sec
ta
task1-3sec
msgQSend in taskOne failed
task1-3sec
msgQSend in taskOne failed
...
i have problem with this code. the message is not going more than one time. help me !!!
The output should be that this:
output
task1-3sec
ta
task1-3sec
ta
task1-3sec
ta
...
1
Contributor
0
Replies
2
Views
ajay.joshi.56
Newbie Poster
1 post since Oct 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.0579 seconds using 2.65MB