LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 09-01-2009, 05:17 AM   #1
shiv.singh
LQ Newbie
 
Registered: May 2009
Posts: 16

Rep: Reputation: 0
printf is not working on MVL.


Hi All,
Here I encountered problem with printfs.

I am running number of processes using rc script on an embedded system ONT(Optical network terminal).

I have developed a packet sniffer application which captures RTP/RTCP packets on the network.

I am adding this process into rc script(onuInit) file for starting my application with other process while initing the board.

The problem comes now. I will not be able to see any printf traces which I supposed to print in packet-recorder application whenever I start capture, while other process are able to print the traces happily.

All the process are getting started as deamon(using fork) and my application too.


The strange thing here is I am able to see the printf traces in my application while init process completes, which is before a infinite while loop inside the message-handler thread which is reading the messages on queue, and once it reaches to the while loop it stops printind further traces. I am using msgrcv and checking for the number of bytes it read from the queue, if it is more than 0 then I process the message or else sleep for some time and try to read the queue again.

Now one more thing here if I kill my packet-recorder application and re-start it manually then I will be able to see my all printf traces

I have tried the following:
1) Bring–up the processes in different order.

2) Checked the stdin, stdout, stderr values (they all are fine and showing as 0, 1, 2).

3) ‘write’ is not working as it uses stdout.

4) File-writing fwrite and fprintf(both are working fine).

5) used _exit(0) instead exit(0).


Please can you suggest what can be the possible issues here.

I will be pleased to elaborate the issue if u find it non-understandable somewhere.

Thanks in advance.
 
Old 09-02-2009, 12:58 AM   #2
Valery Reznic
ELF Statifier author
 
Registered: Oct 2007
Posts: 676

Rep: Reputation: 137Reputation: 137
Quote:
Originally Posted by shiv.singh View Post
Hi All,
Here I encountered problem with printfs.

I am running number of processes using rc script on an embedded system ONT(Optical network terminal).

I have developed a packet sniffer application which captures RTP/RTCP packets on the network.

I am adding this process into rc script(onuInit) file for starting my application with other process while initing the board.

The problem comes now. I will not be able to see any printf traces which I supposed to print in packet-recorder application whenever I start capture, while other process are able to print the traces happily.

All the process are getting started as deamon(using fork) and my application too.


The strange thing here is I am able to see the printf traces in my application while init process completes, which is before a infinite while loop inside the message-handler thread which is reading the messages on queue, and once it reaches to the while loop it stops printind further traces. I am using msgrcv and checking for the number of bytes it read from the queue, if it is more than 0 then I process the message or else sleep for some time and try to read the queue again.

Now one more thing here if I kill my packet-recorder application and re-start it manually then I will be able to see my all printf traces

I have tried the following:
1) Bring–up the processes in different order.

2) Checked the stdin, stdout, stderr values (they all are fine and showing as 0, 1, 2).

3) ‘write’ is not working as it uses stdout.

4) File-writing fwrite and fprintf(both are working fine).

5) used _exit(0) instead exit(0).


Please can you suggest what can be the possible issues here.

I will be pleased to elaborate the issue if u find it non-understandable somewhere.

Thanks in advance.
It;s likely that in "normal mode" process's stdout redirected somewhere
You can start system, find your procss id and then
Code:
ls -l /proc/PID/fds
will show your where your stdout is going.

Valery.

P.S. may be 'fd' and not 'fds'
 
Old 09-02-2009, 05:26 AM   #3
shiv.singh
LQ Newbie
 
Registered: May 2009
Posts: 16

Original Poster
Rep: Reputation: 0
Thanks Valery.

I checked the fds of my process and it shows as below:
I241GA(a0adc9ea)# ls -l /proc/649/fd/
lrwx------ 1 root root 64 Jan 1 00:52 0 -> /dev/ttyS0
lrwx------ 1 root root 64 Jan 1 00:52 1 -> /dev/ttyS0
lrwx------ 1 root root 64 Jan 1 00:52 2 -> /dev/ttyS0
lrwx------ 1 root root 64 Jan 1 00:52 3 -> /var/alcatel/captur
elog/c11-struct-file

and for the other process it shows:
lrwx------ 1 root root 64 Jan 1 00:53 0 -> /dev/ttyS0
l-wx------ 1 root root 64 Jan 1 00:53 1 -> /tmp/fifo
l-wx------ 1 root root 64 Jan 1 00:53 2 -> /tmp/error
l-wx------ 1 root root 64 Jan 1 00:53 3 -> /tmp/fifo
l-wx------ 1 root root 64 Jan 1 00:53 4 -> /tmp/error
l-wx------ 1 root root 64 Jan 1 00:53 5 -> /tmp/fifo
l-wx------ 1 root root 64 Jan 1 00:53 6 -> /tmp/error
l-wx------ 1 root root 64 Jan 1 00:53 7 -> /tmp/PalIptkFifo


I am not able to see anythinf in /dev/ttyS0 file.
I am not sure whether we can redirect my process output to some /tmp/xyz.
If we can then please can you suggest how we can do it..


Regards,
shiv
 
Old 09-02-2009, 06:28 AM   #4
Valery Reznic
ELF Statifier author
 
Registered: Oct 2007
Posts: 676

Rep: Reputation: 137Reputation: 137
Quote:
Originally Posted by shiv.singh View Post
Thanks Valery.

I checked the fds of my process and it shows as below:
I241GA(a0adc9ea)# ls -l /proc/649/fd/
lrwx------ 1 root root 64 Jan 1 00:52 0 -> /dev/ttyS0
lrwx------ 1 root root 64 Jan 1 00:52 1 -> /dev/ttyS0
lrwx------ 1 root root 64 Jan 1 00:52 2 -> /dev/ttyS0
lrwx------ 1 root root 64 Jan 1 00:52 3 -> /var/alcatel/captur
elog/c11-struct-file

and for the other process it shows:
lrwx------ 1 root root 64 Jan 1 00:53 0 -> /dev/ttyS0
l-wx------ 1 root root 64 Jan 1 00:53 1 -> /tmp/fifo
l-wx------ 1 root root 64 Jan 1 00:53 2 -> /tmp/error
l-wx------ 1 root root 64 Jan 1 00:53 3 -> /tmp/fifo
l-wx------ 1 root root 64 Jan 1 00:53 4 -> /tmp/error
l-wx------ 1 root root 64 Jan 1 00:53 5 -> /tmp/fifo
l-wx------ 1 root root 64 Jan 1 00:53 6 -> /tmp/error
l-wx------ 1 root root 64 Jan 1 00:53 7 -> /tmp/PalIptkFifo


I am not able to see anythinf in /dev/ttyS0 file.
I am not sure whether we can redirect my process output to some /tmp/xyz.
If we can then please can you suggest how we can do it..


Regards,
shiv
/dev/ttyS0 is not file, it's serial port device
Looks like your system uses serial port for communication.
How do you login to this system to run this ls program, ssh, or some other method ?
 
Old 09-03-2009, 09:57 AM   #5
shiv.singh
LQ Newbie
 
Registered: May 2009
Posts: 16

Original Poster
Rep: Reputation: 0
Hi,
Sorry for the delayed response.

We are not using ssh for login. Infact our ONT(Optical network Terminal) does not require any login password. We can create user-name & password but did not create because it is not needed here.
One more thing I observed, even I start my packet-recorder process using command-Line instead running while initing ONT through rc script, it gives the same result for 'ls -l /proc/PID/fds'.


Thanks,
Shiv
 
Old 09-03-2009, 10:30 AM   #6
Valery Reznic
ELF Statifier author
 
Registered: Oct 2007
Posts: 676

Rep: Reputation: 137Reputation: 137
Quote:
Originally Posted by shiv.singh View Post
Hi,
Sorry for the delayed response.

We are not using ssh for login. Infact our ONT(Optical network Terminal) does not require any login password. We can create user-name & password but did not create because it is not needed here.
One more thing I observed, even I start my packet-recorder process using command-Line instead running while initing ONT through rc script, it gives the same result for 'ls -l /proc/PID/fds'.


Thanks,
Shiv
Did you try to use strace ?
 
Old 09-04-2009, 02:21 AM   #7
shiv.singh
LQ Newbie
 
Registered: May 2009
Posts: 16

Original Poster
Rep: Reputation: 0
No I did not try it.
Actually I need to install strace utility.
I m trying to cross-compile strace for MVL.
I will analyse and share you the results once
I will run it for my process.

Thanks.
 
Old 09-10-2009, 06:47 AM   #8
shiv.singh
LQ Newbie
 
Registered: May 2009
Posts: 16

Original Poster
Rep: Reputation: 0
Hi Valery,
I am facing issue while cross-compiling strace for MVL.
It is not getting configured if I set CC compiler as /vobs/montavista/pro/devkit/ppc/82xx/bin/ppc_82xx-gcc.

So not able to get any logs for strace. but is printf uses any system call because it is an C library function.
 
Old 09-10-2009, 09:03 AM   #9
Valery Reznic
ELF Statifier author
 
Registered: Oct 2007
Posts: 676

Rep: Reputation: 137Reputation: 137
Quote:
Originally Posted by shiv.singh View Post
Hi Valery,
I am facing issue while cross-compiling strace for MVL.
It is not getting configured if I set CC compiler as /vobs/montavista/pro/devkit/ppc/82xx/bin/ppc_82xx-gcc.

So not able to get any logs for strace. but is printf uses any system call because it is an C library function.
Yes, printf uses system call (write).
There are a lot of functions in the libc, that are only wrapper around syscals
 
Old 09-11-2009, 01:20 AM   #10
shiv.singh
LQ Newbie
 
Registered: May 2009
Posts: 16

Original Poster
Rep: Reputation: 0
Hmm...
I tried to use write explicitly and that also did not worked for me.

Today I was able to compile strace for MVL but getting the following error.
"__uClibc_start_main" this is because strace is not getting compiled with ld-cUlibc.so.0 and libc.so.0, I will try to include as library while compiling today.

Thanks.
 
Old 09-17-2009, 02:58 AM   #11
shiv.singh
LQ Newbie
 
Registered: May 2009
Posts: 16

Original Poster
Rep: Reputation: 0
Hi All,
I tried to include the shared libraries mentioned above but not able to resolve the above error.
Can you please suggest me what can be the issue with strace throwing this error?

And do I need to check some more things which may cause to hide print outputs.

Thansk & Regards,
Shiv
 
  


Reply

Tags
printf


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
printf is not working on MVL. shiv.singh Programming 2 09-02-2009 01:54 AM
printf macro ashlesha Programming 4 11-13-2006 05:14 AM
montavista 3.1 x86_pentium4 mvl-update-script?? lemay_jeff Linux - Newbie 0 07-06-2004 04:52 PM
printf new_user10 Programming 3 09-10-2003 12:12 AM
bash printf anyone? gumby Programming 4 05-13-2003 12:51 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:41 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration