Can anyone tell me the errors in this program???? - VxWorks

This is a discussion on Can anyone tell me the errors in this program???? - VxWorks ; Can anyone tell me the errors in this program???? **************************** #include #include #define MAX_MSGS 10 #define MAX_MSG_LEN 50 #define STACK_SIZE 20000 #define DELAY_TICKS 50 int tidTask1; int tidTask2; MSG_Q_ID myMsgQID; STATUS progStart(void); STATUS task1(void); STATUS task2(void); void progStop(void); STATUS progStart(void) ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: Can anyone tell me the errors in this program????

  1. Can anyone tell me the errors in this program????

    Can anyone tell me the errors in this program????
    ****************************
    #include
    #include

    #define MAX_MSGS 10
    #define MAX_MSG_LEN 50
    #define STACK_SIZE 20000
    #define DELAY_TICKS 50

    int tidTask1;
    int tidTask2;
    MSG_Q_ID myMsgQID;

    STATUS progStart(void);
    STATUS task1(void);
    STATUS task2(void);
    void progStop(void);

    STATUS progStart(void)
    {
    myMsgQID=msgQCreate(MAX_MSGS,MAX_MSG_LEN,MSG_Q_PRI ORITY);
    if(myMsgQID==NULL)
    {
    return(ERROR);
    }

    tidTask1=taskSpawn("tTask1",200,0,STACK_SIZE,(FUNCPTR)task1,0,0,0,0,0,0,0,0,0 ,0);
    printf("AAAAAAA\n");
    tidTask2=taskSpawn("tTask2",220,0,STACK_SIZE,(FUNCPTR)task2,0,0,0,0,0,0,0,0,0 ,0);
    printf("BBBBBBB\n");
    return(OK);
    }

    #define MESSAGE "Greetings from Task1"

    STATUS task1(void)
    {
    FOREVER
    {
    if(msgQSend(myMsgQID,MESSAGE,sizeof(MESSAGE),WAIT_ FOREVER,MSG_PRI_NORMAL)==ERROR)
    {
    return(ERROR);
    }
    else
    printf("in task1\n");
    taskDelay(DELAY_TICKS);
    }
    return(OK);
    }

    STATUS task2(void)
    {
    char msgBuf[MAX_MSG_LEN];


    FOREVER
    {
    memset(msgBuf,0,MAX_MSG_LEN);
    if(msgQReceive(myMsgQID,msgBuf,MAX_MSG_LEN,WAIT_FO REVER)==ERROR)
    {
    printf("error2\n");
    return(ERROR);
    }
    printf("message from task1:%s\n,msgBuf");
    }
    return(OK);
    }

    void progStop(void)
    {
    taskDelete(tidTask1);
    taskDelete(tidTask2);
    msgQDelete(myMsgQID);
    printf("bye\n");
    return;
    }
    **********************
    use the default VxSim0 at the debug mode
    the output is:
    AAAAAAA
    BBBBBBB
    in task1
    message from task1:Exception !
    Vector 13 : General Protection Fault
    Program Counter : 0x00414248
    Status Register : 0x00010286
    in task1
    in task1
    in task1
    in task1
    in task1
    in task1
    in task1
    in task1
    in task1
    in task1
    bye
    *************************


  2. Re: Can anyone tell me the errors in this program????

    Closing quotation mark is out of place. Need to change

    printf("message from task1:%s\n,msgBuf");

    to

    printf("message from task1:%s\n",msgBuf);


    wrote in message
    news:1162116933.495877.208480@h48g2000cwc.googlegr oups.com...
    > Can anyone tell me the errors in this program????
    > ****************************
    > #include
    > #include
    >
    > #define MAX_MSGS 10
    > #define MAX_MSG_LEN 50
    > #define STACK_SIZE 20000
    > #define DELAY_TICKS 50
    >
    > int tidTask1;
    > int tidTask2;
    > MSG_Q_ID myMsgQID;
    >
    > STATUS progStart(void);
    > STATUS task1(void);
    > STATUS task2(void);
    > void progStop(void);
    >
    > STATUS progStart(void)
    > {
    > myMsgQID=msgQCreate(MAX_MSGS,MAX_MSG_LEN,MSG_Q_PRI ORITY);
    > if(myMsgQID==NULL)
    > {
    > return(ERROR);
    > }
    >
    > tidTask1=taskSpawn("tTask1",200,0,STACK_SIZE,(FUNCPTR)task1,0,0,0,0,0,0,0,0,0 ,0);
    > printf("AAAAAAA\n");
    > tidTask2=taskSpawn("tTask2",220,0,STACK_SIZE,(FUNCPTR)task2,0,0,0,0,0,0,0,0,0 ,0);
    > printf("BBBBBBB\n");
    > return(OK);
    > }
    >
    > #define MESSAGE "Greetings from Task1"
    >
    > STATUS task1(void)
    > {
    > FOREVER
    > {
    > if(msgQSend(myMsgQID,MESSAGE,sizeof(MESSAGE),WAIT_ FOREVER,MSG_PRI_NORMAL)==ERROR)
    > {
    > return(ERROR);
    > }
    > else
    > printf("in task1\n");
    > taskDelay(DELAY_TICKS);
    > }
    > return(OK);
    > }
    >
    > STATUS task2(void)
    > {
    > char msgBuf[MAX_MSG_LEN];
    >
    >
    > FOREVER
    > {
    > memset(msgBuf,0,MAX_MSG_LEN);
    > if(msgQReceive(myMsgQID,msgBuf,MAX_MSG_LEN,WAIT_FO REVER)==ERROR)
    > {
    > printf("error2\n");
    > return(ERROR);
    > }
    > printf("message from task1:%s\n,msgBuf");
    > }
    > return(OK);
    > }
    >
    > void progStop(void)
    > {
    > taskDelete(tidTask1);
    > taskDelete(tidTask2);
    > msgQDelete(myMsgQID);
    > printf("bye\n");
    > return;
    > }
    > **********************
    > use the default VxSim0 at the debug mode
    > the output is:
    > AAAAAAA
    > BBBBBBB
    > in task1
    > message from task1:Exception !
    > Vector 13 : General Protection Fault
    > Program Counter : 0x00414248
    > Status Register : 0x00010286
    > in task1
    > in task1
    > in task1
    > in task1
    > in task1
    > in task1
    > in task1
    > in task1
    > in task1
    > in task1
    > bye
    > *************************
    >




  3. Re: Can anyone tell me the errors in this program????


    wrote in message
    newsd31h.9444$Bs.7103@bignews8.bellsouth.net...
    > Closing quotation mark is out of place. Need to change
    >
    > printf("message from task1:%s\n,msgBuf");
    >
    > to
    >
    > printf("message from task1:%s\n",msgBuf);


    OP might consider using a 'language aware' editor such as
    VIM which highlights such silliness in color.

    lee


+ Reply to Thread