Re: Printing the messages through printk while using Xwindows.

From: Richard B. Johnson (root@chaos.analogic.com)
Date: Fri Jul 28 2000 - 12:43:19 EST


On Fri, 28 Jul 2000, Tigran Aivazian wrote:

> On Fri, 28 Jul 2000, Jesse Pollard wrote:
>
> >
> > > Hi,
> > > I have developed a driver in which I use messages to be printed for =
> > > debugging. When using X Windows terminal I am not able to view the =
> > > messages, while I can see them when using a console. Can I have a =
> > > console window in X Windows where I can view the printed messages.
> >
> > Have you tried running the "xconsole" utility? It is supposed to redirect
> > the /dev/console messages to the xconsole window, and I assume it still
> > works.
> >
>
> You can use process' current->tty (if not NULL) and call the
> tty->driver.write() routine directly.
>
> This is covered in Linux Kernel Module Programming Guide (see
> Coriolis, Linux Programming White Papers, page 288). The idea goes like
> this:
>
> print_string(char *str)
> {
> struct tty_struct *tty = current->tty;
>
> (*tty->driver).write(tty, 0, str, strlen(str));
> (*tty->driver).write(tty, 0, "\015\012", 2);
> }
>
> How about this one?

This is a wee bit better because it will compile and run ;)

print_string(char *str)
{
   struct tty_struct *tty = current->tty;

   (*tty->driver.write)(tty, 0, str, strlen(str));
   (*tty->driver.write)(tty, 0, "\015\012", 2);
}

Cheers,
Dick Johnson

Penguin : Linux version 2.2.15 on an i686 machine (797.90 BogoMips).

"Memory is like gasoline. You use it up when you are running. Of
course you get it all back when you reboot..."; Actual explanation
obtained from the Micro$oft help desk.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Mon Jul 31 2000 - 21:00:27 EST