Doubt in target hanging when i use printf - VxWorks

This is a discussion on Doubt in target hanging when i use printf - VxWorks ; hi friends, i have some doubts in this code. #include "vxWorks.h" #include "logLib.h" #include "stdio.h" void loop(); void spawn() { taskSpawn("tLoop",125,0,2000,(FUNCPTR)loop,0,0,0,0,0,0,0,0,0,0); } void loop() { for(; /* logMsg("%s\n","I m logmessage",0,0,0,0,0);*/ printf("I m printf\n"); } .......After this i spawned a task ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: Doubt in target hanging when i use printf

  1. Doubt in target hanging when i use printf

    hi friends,
    i have some doubts in this code.

    #include "vxWorks.h"
    #include "logLib.h"
    #include "stdio.h"

    void loop();
    void spawn()
    {
    taskSpawn("tLoop",125,0,2000,(FUNCPTR)loop,0,0,0,0,0,0,0,0,0,0);
    }

    void loop()
    {
    for(;
    /* logMsg("%s\n","I m logmessage",0,0,0,0,0);*/
    printf("I m printf\n");
    }

    .......After this i spawned a task to call the function spawn();

    -> sp spawn
    task spawned: id = 1f68ee60, name = s2u2
    value = 526970464 = 0x1f68ee60
    -> i
    NAME ENTRY TID PRI STATUS PC SP
    ERRNO DELAY
    ---------- ------------ -------- --- ---------- -------- --------
    ------- -----
    tExcTask _excTask 1f6f7134 0 PEND 16f7fe 1f6f70a4
    0 0
    tLogTask _logTask 1f6f4830 0 PEND 16f7fe 1f6f479c
    0 0
    tWdbTask _wdbCmdLoop 1f690028 3 READY 11730c 1f68ff84
    0 0
    tNetTask _netTask 1f6b4530 50 READY 117273 1f6b4414
    0 0
    tLoop _loop 1f7fe374 125 READY 10910a 1f7fdf70
    0 0
    value = 0 = 0x0

    .......................After that i tried to delete the task "tLoop".
    -> td tLoop
    Cannot kill task 0x1f7fe374 which is currently safe from deletion
    value = -1 = 0xffffffff
    -> taskDeleteForce tLoop
    value = 0 = 0x0

    ..............After that my target has got hanged.......then i tried
    like this.
    -> ?shConfig
    DSM_HEX_MODE = off
    LD_CALL_XTORS = target
    LD_COMMON_MATCH_ALL = on
    LD_PATH = .
    LD_SEND_MODULES = on
    SH_GET_TASK_IO = on

    -> ?shConfig SH_GET_TASK_IO off

    -> printf("Hello\n")

    ..... Now the printf() got hanged..then i opened another shell from
    that i got this output.
    -> i
    NAME ENTRY TID PRI STATUS PC SP
    ERRNO DELAY
    ---------- ------------ -------- --- ---------- -------- --------
    ------- -----
    tExcTask _excTask 1f6f7134 0 PEND 16f7fe
    1f6f70a4 0 0
    tLogTask _logTask 1f6f4830 0 PEND 16f7fe
    1f6f479c 0 0
    tWdbTask _wdbCmdLoop 1f690028 3 READY 11730c
    1f68ff84 0 0
    t7 _funcCallWra 1f68ee60 4 PEND 11730c
    1f68eb8c 0 0
    tNetTask _netTask 1f6b4530 50 READY 117273
    1f6b4414 0 0
    value = 0 = 0x0

    ...........then i reboot my target
    -> reboot
    Rebooting...

    ......When i remove the printf and include the logMsg() everything is
    working fine...

    #include "vxWorks.h"
    #include "logLib.h"
    #include "stdio.h"

    void loop();
    void spawn()
    {
    taskSpawn("tLoop",125,0,2000,(FUNCPTR)loop,0,0,0,0,0,0,0,0,0,0);
    }

    void loop()
    {
    for(;
    logMsg("%s\n","I m logmessage",0,0,0,0,0);
    /* printf("I m printf\n"); */
    }

    i want to know why my target is getting hanged when i use printf() and
    not
    when i use logMsg()....also how to recover from this problem.

    my target board is a PC...
    CPU: PC PENTIUM
    VxWorks: 5.4
    BSP version: 1.2/0


  2. Re: Doubt in target hanging when i use printf


    samrat wrote:
    > hi friends,
    > i have some doubts in this code.
    >
    > #include "vxWorks.h"
    > #include "logLib.h"
    > #include "stdio.h"
    >
    > void loop();
    > void spawn()
    > {
    > taskSpawn("tLoop",125,0,2000,(FUNCPTR)loop,0,0,0,0,0,0,0,0,0,0);
    > }
    >
    > void loop()
    > {
    > for(;
    > /* logMsg("%s\n","I m logmessage",0,0,0,0,0);*/
    > printf("I m printf\n");
    > }
    >
    > ......After this i spawned a task to call the function spawn();
    >
    > -> sp spawn
    > task spawned: id = 1f68ee60, name = s2u2
    > value = 526970464 = 0x1f68ee60
    > -> i
    > NAME ENTRY TID PRI STATUS PC SP
    > ERRNO DELAY
    > ---------- ------------ -------- --- ---------- -------- --------
    > ------- -----
    > tExcTask _excTask 1f6f7134 0 PEND 16f7fe 1f6f70a4
    > 0 0
    > tLogTask _logTask 1f6f4830 0 PEND 16f7fe 1f6f479c
    > 0 0
    > tWdbTask _wdbCmdLoop 1f690028 3 READY 11730c 1f68ff84
    > 0 0
    > tNetTask _netTask 1f6b4530 50 READY 117273 1f6b4414
    > 0 0
    > tLoop _loop 1f7fe374 125 READY 10910a 1f7fdf70
    > 0 0
    > value = 0 = 0x0
    >
    > ......................After that i tried to delete the task "tLoop".
    > -> td tLoop
    > Cannot kill task 0x1f7fe374 which is currently safe from deletion
    > value = -1 = 0xffffffff
    > -> taskDeleteForce tLoop
    > value = 0 = 0x0
    >
    > .............After that my target has got hanged.......then i tried
    > like this.
    > -> ?shConfig
    > DSM_HEX_MODE = off
    > LD_CALL_XTORS = target
    > LD_COMMON_MATCH_ALL = on
    > LD_PATH = .
    > LD_SEND_MODULES = on
    > SH_GET_TASK_IO = on
    >
    > -> ?shConfig SH_GET_TASK_IO off
    >
    > -> printf("Hello\n")
    >
    > .... Now the printf() got hanged..then i opened another shell from
    > that i got this output.
    > -> i
    > NAME ENTRY TID PRI STATUS PC SP
    > ERRNO DELAY
    > ---------- ------------ -------- --- ---------- -------- --------
    > ------- -----
    > tExcTask _excTask 1f6f7134 0 PEND 16f7fe
    > 1f6f70a4 0 0
    > tLogTask _logTask 1f6f4830 0 PEND 16f7fe
    > 1f6f479c 0 0
    > tWdbTask _wdbCmdLoop 1f690028 3 READY 11730c
    > 1f68ff84 0 0
    > t7 _funcCallWra 1f68ee60 4 PEND 11730c
    > 1f68eb8c 0 0
    > tNetTask _netTask 1f6b4530 50 READY 117273
    > 1f6b4414 0 0
    > value = 0 = 0x0
    >
    > ..........then i reboot my target
    > -> reboot
    > Rebooting...
    >
    > .....When i remove the printf and include the logMsg() everything is
    > working fine...
    >
    > #include "vxWorks.h"
    > #include "logLib.h"
    > #include "stdio.h"
    >
    > void loop();
    > void spawn()
    > {
    > taskSpawn("tLoop",125,0,2000,(FUNCPTR)loop,0,0,0,0,0,0,0,0,0,0);
    > }
    >
    > void loop()
    > {
    > for(;
    > logMsg("%s\n","I m logmessage",0,0,0,0,0);
    > /* printf("I m printf\n"); */
    > }
    >
    > i want to know why my target is getting hanged when i use printf() and
    > not
    > when i use logMsg()....also how to recover from this problem.
    >
    > my target board is a PC...
    > CPU: PC PENTIUM
    > VxWorks: 5.4
    > BSP version: 1.2/0


    Hi,
    I would check the following to be sure that printf works:
    1)Check that the standard output device is initialised and can be used
    to get output properly
    2)Confirm incase output device is redirected to another file/device and
    see if thats fully functional.
    3)Another thing to check will be the stack size of your task and
    increase it and see if it helps.

    Regards,
    s.subbarayan


  3. Re: Doubt in target hanging when i use printf

    The command logMsg is not blocking and not uses any internal semaphore.
    Sometimes you can loose some of the messages if are consecutively
    invoqued. To skip this situation you can include a semaphore. On the
    contrary, the command printf is blocking. It seems that when you kill
    you task the printf was still running and didn't finish so it must be
    still blocked. For example in a ISR you can't use printf because you
    can bloack the system, something similar that is happen to you.

    Hope this helps,
    Greetings
    Andrés m. Pazos

    samrat wrote:
    > hi friends,
    > i have some doubts in this code.
    >
    > #include "vxWorks.h"
    > #include "logLib.h"
    > #include "stdio.h"
    >
    > void loop();
    > void spawn()
    > {
    > taskSpawn("tLoop",125,0,2000,(FUNCPTR)loop,0,0,0,0,0,0,0,0,0,0);
    > }
    >
    > void loop()
    > {
    > for(;
    > /* logMsg("%s\n","I m logmessage",0,0,0,0,0);*/
    > printf("I m printf\n");
    > }
    >
    > ......After this i spawned a task to call the function spawn();
    >
    > -> sp spawn
    > task spawned: id = 1f68ee60, name = s2u2
    > value = 526970464 = 0x1f68ee60
    > -> i
    > NAME ENTRY TID PRI STATUS PC SP
    > ERRNO DELAY
    > ---------- ------------ -------- --- ---------- -------- --------
    > ------- -----
    > tExcTask _excTask 1f6f7134 0 PEND 16f7fe 1f6f70a4
    > 0 0
    > tLogTask _logTask 1f6f4830 0 PEND 16f7fe 1f6f479c
    > 0 0
    > tWdbTask _wdbCmdLoop 1f690028 3 READY 11730c 1f68ff84
    > 0 0
    > tNetTask _netTask 1f6b4530 50 READY 117273 1f6b4414
    > 0 0
    > tLoop _loop 1f7fe374 125 READY 10910a 1f7fdf70
    > 0 0
    > value = 0 = 0x0
    >
    > ......................After that i tried to delete the task "tLoop".
    > -> td tLoop
    > Cannot kill task 0x1f7fe374 which is currently safe from deletion
    > value = -1 = 0xffffffff
    > -> taskDeleteForce tLoop
    > value = 0 = 0x0
    >
    > .............After that my target has got hanged.......then i tried
    > like this.
    > -> ?shConfig
    > DSM_HEX_MODE = off
    > LD_CALL_XTORS = target
    > LD_COMMON_MATCH_ALL = on
    > LD_PATH = .
    > LD_SEND_MODULES = on
    > SH_GET_TASK_IO = on
    >
    > -> ?shConfig SH_GET_TASK_IO off
    >
    > -> printf("Hello\n")
    >
    > .... Now the printf() got hanged..then i opened another shell from
    > that i got this output.
    > -> i
    > NAME ENTRY TID PRI STATUS PC SP
    > ERRNO DELAY
    > ---------- ------------ -------- --- ---------- -------- --------
    > ------- -----
    > tExcTask _excTask 1f6f7134 0 PEND 16f7fe
    > 1f6f70a4 0 0
    > tLogTask _logTask 1f6f4830 0 PEND 16f7fe
    > 1f6f479c 0 0
    > tWdbTask _wdbCmdLoop 1f690028 3 READY 11730c
    > 1f68ff84 0 0
    > t7 _funcCallWra 1f68ee60 4 PEND 11730c
    > 1f68eb8c 0 0
    > tNetTask _netTask 1f6b4530 50 READY 117273
    > 1f6b4414 0 0
    > value = 0 = 0x0
    >
    > ..........then i reboot my target
    > -> reboot
    > Rebooting...
    >
    > .....When i remove the printf and include the logMsg() everything is
    > working fine...
    >
    > #include "vxWorks.h"
    > #include "logLib.h"
    > #include "stdio.h"
    >
    > void loop();
    > void spawn()
    > {
    > taskSpawn("tLoop",125,0,2000,(FUNCPTR)loop,0,0,0,0,0,0,0,0,0,0);
    > }
    >
    > void loop()
    > {
    > for(;
    > logMsg("%s\n","I m logmessage",0,0,0,0,0);
    > /* printf("I m printf\n"); */
    > }
    >
    > i want to know why my target is getting hanged when i use printf() and
    > not
    > when i use logMsg()....also how to recover from this problem.
    >
    > my target board is a PC...
    > CPU: PC PENTIUM
    > VxWorks: 5.4
    > BSP version: 1.2/0



  4. Re: Doubt in target hanging when i use printf

    printf() can't be used in interrupt level code.

    logMsg was created to allow printing inside interrupt level code.


    samrat wrote:
    > hi friends,
    > i have some doubts in this code.
    >
    > #include "vxWorks.h"
    > #include "logLib.h"
    > #include "stdio.h"
    >
    > void loop();
    > void spawn()
    > {
    > taskSpawn("tLoop",125,0,2000,(FUNCPTR)loop,0,0,0,0,0,0,0,0,0,0);
    > }
    >
    > void loop()
    > {
    > for(;
    > /* logMsg("%s\n","I m logmessage",0,0,0,0,0);*/
    > printf("I m printf\n");
    > }
    >
    > ......After this i spawned a task to call the function spawn();
    >
    > -> sp spawn
    > task spawned: id = 1f68ee60, name = s2u2
    > value = 526970464 = 0x1f68ee60
    > -> i
    > NAME ENTRY TID PRI STATUS PC SP
    > ERRNO DELAY
    > ---------- ------------ -------- --- ---------- -------- --------
    > ------- -----
    > tExcTask _excTask 1f6f7134 0 PEND 16f7fe 1f6f70a4
    > 0 0
    > tLogTask _logTask 1f6f4830 0 PEND 16f7fe 1f6f479c
    > 0 0
    > tWdbTask _wdbCmdLoop 1f690028 3 READY 11730c 1f68ff84
    > 0 0
    > tNetTask _netTask 1f6b4530 50 READY 117273 1f6b4414
    > 0 0
    > tLoop _loop 1f7fe374 125 READY 10910a 1f7fdf70
    > 0 0
    > value = 0 = 0x0
    >
    > ......................After that i tried to delete the task "tLoop".
    > -> td tLoop
    > Cannot kill task 0x1f7fe374 which is currently safe from deletion
    > value = -1 = 0xffffffff
    > -> taskDeleteForce tLoop
    > value = 0 = 0x0
    >
    > .............After that my target has got hanged.......then i tried
    > like this.
    > -> ?shConfig
    > DSM_HEX_MODE = off
    > LD_CALL_XTORS = target
    > LD_COMMON_MATCH_ALL = on
    > LD_PATH = .
    > LD_SEND_MODULES = on
    > SH_GET_TASK_IO = on
    >
    > -> ?shConfig SH_GET_TASK_IO off
    >
    > -> printf("Hello\n")
    >
    > .... Now the printf() got hanged..then i opened another shell from
    > that i got this output.
    > -> i
    > NAME ENTRY TID PRI STATUS PC SP
    > ERRNO DELAY
    > ---------- ------------ -------- --- ---------- -------- --------
    > ------- -----
    > tExcTask _excTask 1f6f7134 0 PEND 16f7fe
    > 1f6f70a4 0 0
    > tLogTask _logTask 1f6f4830 0 PEND 16f7fe
    > 1f6f479c 0 0
    > tWdbTask _wdbCmdLoop 1f690028 3 READY 11730c
    > 1f68ff84 0 0
    > t7 _funcCallWra 1f68ee60 4 PEND 11730c
    > 1f68eb8c 0 0
    > tNetTask _netTask 1f6b4530 50 READY 117273
    > 1f6b4414 0 0
    > value = 0 = 0x0
    >
    > ..........then i reboot my target
    > -> reboot
    > Rebooting...
    >
    > .....When i remove the printf and include the logMsg() everything is
    > working fine...
    >
    > #include "vxWorks.h"
    > #include "logLib.h"
    > #include "stdio.h"
    >
    > void loop();
    > void spawn()
    > {
    > taskSpawn("tLoop",125,0,2000,(FUNCPTR)loop,0,0,0,0,0,0,0,0,0,0);
    > }
    >
    > void loop()
    > {
    > for(;
    > logMsg("%s\n","I m logmessage",0,0,0,0,0);
    > /* printf("I m printf\n"); */
    > }
    >
    > i want to know why my target is getting hanged when i use printf() and
    > not
    > when i use logMsg()....also how to recover from this problem.
    >
    > my target board is a PC...
    > CPU: PC PENTIUM
    > VxWorks: 5.4
    > BSP version: 1.2/0



+ Reply to Thread