Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


VxWorks stdout from tasks

Posted on 2007-08-01
Medium Priority
Last Modified: 2013-12-26

I'm hoping there's a couple experts out there with some VxWorks experience.

I'm unable to get printf - stdout to my shell from tasks that I've spawned.  From what I could gather this is because the shell runs at a much higher priority than my task.  I think there's a way to get a task's stdout to a serial port, however this isn't a great solution for me since the target is in another building.

I'd still like to get printf output from tasks just for development and debugging puposes.  Is there some other way to do that like redirecting a task's stdout or telnet to a machine connected to the serial output.....?

Question by:JohnSantaFe
LVL 86

Assisted Solution

jkr earned 300 total points
ID: 19617551
Can you redirect stdout to a file and read that using 'tail -f'? I.e.

mytask 1>&2 mytasklog

tail -f mytasklog

Accepted Solution

billtouch earned 600 total points
ID: 19627453
Something is a bit strange with what you were told. Shell's don't typically run, much less at a higher priority, when a process id running under it. It has been a while since I used VxWorks, but I never had a problem getting printf() output.

You named the most common workarounds. Is there a nearby machine you can access the serial port on? You can also use a fprintf()/flush() to get your info out to a file/serial port, etc...

Is the process daemonized or running in the background (started with &)?

Is your shell a real shell or is it Wind River's cut down shell?


Author Comment

ID: 19639037
Well, let me post some sample code to show the problem I'm having with printf.  I'm using the generic Tornado shell.

#include "cstdio"

void myTask(void);

int myData = 0;
int tidMyTask = 0;

int start(void)
   printf("myData before task is:  %i\n", myData);

   tidMyTask = taskSpawn ("tTaskName", 100, 0, 20000,
                               (FUNCPTR)myTask, 0,0,0,0,0,0,0,0,0,0);


  printf("myData after task is: %i\n", myData);


 return 1;

void myTask(void)
  printf("Starting my task");   //this never happens

  myData = 56;   //this does happen

  printf("myData inside of task is: %i\n", myData);  //this never happens

Output from the Tornado shell

myData before task is: 0
myData after task is: 56
value = 1 = 0x1


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.


Expert Comment

ID: 19639834
Try checking the return from printf(). If it is -1, check errno. There might be a clue there.

My first thought is you don't have a stdout assigned. The only failures are from your spawn'd task. That implies that stdio assigns are not happening. Without the source to tornado, you won't know for sure, but if you treat it like there is no default terminal assigned, you will be better off. Try using a file.

Are you NFS mounted?


Assisted Solution

sjith2000 earned 600 total points
ID: 19962081
I understood the problem here.As per the VxWorks, the root task is having the priority of 100.That means int start(void) which is the root task is having the prority 100.But you are spawning one more task inside the root task which is of the same priority.So what will happen is your void myTask(void)
task will be executed once the execution of int start(void) is OVER.But before the root task is over, you are deleting the task by the statement  taskDelete(tidMyTask);

So what you have to try out here is, spawn the task with the prority 99 which is a higher priority than the root task.

tidMyTask = taskSpawn ("tTaskName", 99, 0, 20000,
                               (FUNCPTR)myTask, 0,0,0,0,0,0,0,0,0,0);

Otherwise, spawn the task with priority 100 only, but remove the statement


Author Comment

ID: 19974199

Thanks.  Unfortunately it's not a problem with the task running.  I'm sure the task runs because the value of myData changes.

I've moved on to Windriver's Workbench and the newer version of Vxworks so I've abandoned the issue.

Thanks for the replies.

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

577 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question