how to get the text ,which appears on serial console programmatically.
Linux - KernelThis forum is for all discussion relating to the Linux kernel.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
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.
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.
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).
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?
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.