LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 10-07-2009, 08:28 AM   #1
annadaprasana
LQ Newbie
 
Registered: Jul 2009
Posts: 11

Rep: Reputation: 0
how to get the text ,which appears on serial console programmatically.




Hi Experts,

I want to get the text, appears on serial console to a buffer programmatically. I have openwrt linux box, which connetcts to a serial cable to host machine through hyper-term. i want to get all the in/out text(which appears on console screen) to a buffer in the program. Can you please some idea how to get it.

Thanks
Annada
 
Old 10-07-2009, 08:51 AM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
When you mention hyper-term, does that indicate that you want to do this on a Windows machine?

If you want to do it on Linux then both mrxvt (with the -C option) and bootlogd intercept console writes. You could take a look at their source code. If mrxvt does it, chances are rxvt does it too and the source code may be simpler.

Writes to terminals notoriously contain a lot more than the casual user expects to see, especially control codes, for example to change colour and highlighting or to move to end of line. The console is simpler than terminals in general so that may not be a big problem in this case. bootlogd has code to strip out some of this gumph.
 
Old 10-08-2009, 12:26 AM   #3
annadaprasana
LQ Newbie
 
Registered: Jul 2009
Posts: 11

Original Poster
Rep: Reputation: 0
Hi Catkin,

Thanks for your reply. I might not clear of my question. Let me describe my doubt.

It is not a matter which host machine(windows/linux), the openwrt linux box connects through null modem serial cable. I am using hyper-term/tera-term s/w for windows and minicom s/w for linux to get the serial console.

I want to get all the messages appears on the console in a buffer and store in a file, programmatically. Is there any way to get the file descriptor of the serial console device, and read from that fd.

Thanks
Annada
 
Old 10-08-2009, 08:16 AM   #4
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
You want to do it on the openwrt linux box?
 
Old 10-09-2009, 04:56 AM   #5
annadaprasana
LQ Newbie
 
Registered: Jul 2009
Posts: 11

Original Poster
Rep: Reputation: 0
Hi Catkin,

My program runs on a openwrt linux box.
Basically i want to redirect console messages to a virtual terminal.
The default console is /dev/ttyS0, where all the kernel messages are printed,
that needs to get at different virtual terminal. I got some information
to use ioctl(TIOCLINUX), but not sure how to do that.

Thanks
Annada
 
Old 10-09-2009, 05:09 AM   #6
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
I don't know openwrt or a general answer to your question but the programs I mentioned earlier do intercept console output so you could look to see how they do it in C and adapt it to your needs.

Alternatively, have you looked into passing the kernel the name of an alternative-or-secondary console at boot time. Not my area of expertise but may be worth investigating.

Another alternative is to start a new thread, with what you want to do in the title, something like "How to replicate/switch console output to a virtual terminal?"

Once you've found out how to do it, it may not need programing (a permanent configuration change) or may require one very simple command (to add to the boot scripts).

Last edited by catkin; 10-09-2009 at 05:13 AM.
 
Old 10-12-2009, 06:18 AM   #7
annadaprasana
LQ Newbie
 
Registered: Jul 2009
Posts: 11

Original Poster
Rep: Reputation: 0
Hi Catkin,
Thanks for your response.

I am not sure, how to configure kernel with the secondary console.
Is there any /proc ,to add for this console? Actually i want to make a pseudo terminal as the secondary console. So more precisely, how to make a pseudo terminal to a virtual terminal?

Thanks
Annada
 
Old 10-19-2009, 06:08 AM   #8
annadaprasana
LQ Newbie
 
Registered: Jul 2009
Posts: 11

Original Poster
Rep: Reputation: 0
Hi,

Some approach towards the answer of my query. The syslogd records kernel messages and logs from user-space applications. The command used for read the log is "logread -f" (-f : output data as the log grows). So this command can be execv in child process context. The output is generated in slave-fd is visible in master-fd through pseudo terminal.

Thanks
Annada P.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
RHEL 5 and X-Win32 remote login appears on console?? thepeleda Linux - Newbie 1 02-12-2009 08:16 PM
When i open a shell console, not one, but two appears. Kanesoban Ubuntu 9 04-09-2007 06:46 AM
Serial A terminal appears not functional Taikon Solaris / OpenSolaris 2 07-30-2006 11:15 AM
Mozilla/Firefox: Text only appears when marked abisko00 Linux - Software 1 03-25-2004 05:19 AM
no text appears in dialogue boxes! agostini714 Linux - Software 1 02-09-2004 07:19 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 02:45 AM.

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
Open Source Consulting | Domain Registration