Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Skalierbare serielle Konsole?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Sven Geggus  
View profile   Translate to Translated (View Original)
 More options Jul 25 2011, 11:04 am
Newsgroups: de.comp.os.unix.misc, ka.comp.linux
Followup-To: de.comp.os.unix.misc
From: Sven Geggus <use...@fuchsschwanzdomain.de>
Date: Mon, 25 Jul 2011 15:04:04 +0000 (UTC)
Local: Mon, Jul 25 2011 11:04 am
Subject: Skalierbare serielle Konsole?
Moin zusammen,

Ich greife mit screen auf die serielle Konsole eines embedded Debian Systems
zu:

screen /dev/ttyS0 38400

Der screen läuft in einem xterm, rxvt oder ähnlichem.

Nun ist es so, dass der Wert von COLUMNS immer 80 ist und der Wert von LINES
immer 24 unabhängig davon wie groß mein Terminalfenster wirklich ist und
ändert sich nicht durch skalieren des xterm.

Wenn ich statt "screen" "minicom" verwende tritt das selbe Problem auf.

Die Frage ist nun wie man das ändern kann. Ich vermute ein serverseitiges
Problem.

Muss ich dem getty eventuell einen anderen Terminaltyp als vt100 mitgeben?
Das System selbst beherscht die dynamische Skalierung von Terminalfenstern
prinzipiell, denn wenn ich mich per ssh einlogge ändert sich die Werte von
LINES und COLUMNS beim skalieren dynamisch.

Gruss

Sven

--
"Das Einzige wovor wir Angst haben müssen ist die Angst selbst"
                                                (Franklin D. Roosevelt)

/me is giggls@ircnet, http://sven.gegg.us/ on the Web


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rainer Weikusat  
View profile   Translate to Translated (View Original)
 More options Jul 25 2011, 1:52 pm
Newsgroups: de.comp.os.unix.misc
From: Rainer Weikusat <rweiku...@mssgmbh.com>
Date: Mon, 25 Jul 2011 18:52:52 +0100
Local: Mon, Jul 25 2011 1:52 pm
Subject: Re: Skalierbare serielle Konsole?

Unten angehaengtes Programm uebersetzen und bei Login via seriell
ausfuehren lassen, Beispiel:

if expr `tty` : '.*S.' >/dev/null 2>&1;
then
        rows=`stty -F /dev/tty -a | sed -n 's/^.*rows *//; s/;.*$//; p; q'`
        test "$rows" = 0 && resize
fi

----------------
/* This version of resize.c has been modified from the original, which
 * came with X11/xterm.  It no longer tries to emit shell commands for
 * setting LINES, COLUMNS, or TERMCAP.  It assumes an ANSI terminal,
 * and the availability of the TIOCGWINSZ ioctl.  The portability
 * ifdefs were also removed -- posix termios access is assumed.
 *      Paul Fox, June 2006
 *
 * original copyright messages preserved below...
 */

/*
 *      $Xorg: resize.c,v 1.3 2000/08/17 19:55:09 cpqbld Exp $
 */

/* $XFree86: xc/programs/xterm/resize.c,v 3.51 2001/10/09 21:52:40 alanh Exp $ */

/*
 * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 *
 *                         All Rights Reserved
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation for any purpose and without fee is hereby granted,
 * provided that the above copyright notice appear in all copies and that
 * both that copyright notice and this permission notice appear in
 * supporting documentation, and that the name of Digital Equipment
 * Corporation not be used in advertising or publicity pertaining to
 * distribution of the software without specific, written prior permission.
 *
 *
 * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
 * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
 * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
 * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
 * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 * SOFTWARE.
 */

/* resize.c */

#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <string.h>
#include <termio.h>
#include <termios.h>

#include <signal.h>
#include <pwd.h>

#define ESC "\033"

#define TIMEOUT         10

char *myname;

char getsize[] = ESC "7"  ESC "[r" ESC "[999;999H" ESC "[6n";
char restore[] = ESC "8";

struct termios tioorig;

char size[] = ESC "[%d;%dR";

int tty;
FILE *ttyfp;

static void onintr (int sig);
static void resize_timeout (int sig);
static void Usage (void);
static void readstring (FILE *fp, char *buf, char *str);

char *
x_basename(char *name)
{
   char *cp;

   cp = strrchr(name, '/');
   return (cp ? cp + 1 : name);

}

/*
  tells tty driver to reflect current screen size
 */

int
main (int argc, char **argv)
{

       int rows, cols;
       struct termios tio;
       char buf[BUFSIZ];
       struct winsize ws;
       char *name_of_tty;

       myname = x_basename(argv[0]);

       if (argc > 1) Usage();

       name_of_tty = "/dev/tty";

       if ((ttyfp = fopen (name_of_tty, "r+")) == NULL) {
           fprintf (stderr, "%s:  can't open terminal %s\n",
                    myname, name_of_tty);
           exit (1);
       }
       tty = fileno(ttyfp);

       tcgetattr(tty, &tioorig);
       tio = tioorig;
       tio.c_iflag &= ~ICRNL;
       tio.c_lflag &= ~(ICANON | ECHO);
       tio.c_cflag |= CS8;
       tio.c_cc[VMIN] = 6;
       tio.c_cc[VTIME] = 1;
       signal(SIGINT, onintr);
       signal(SIGQUIT, onintr);
       signal(SIGTERM, onintr);
       tcsetattr(tty, TCSADRAIN, &tio);

       write(tty, getsize, strlen(getsize));
       readstring(ttyfp, buf, size);
       if(sscanf (buf, size, &rows, &cols) != 2) {
               fprintf(stderr, "%s: Can't get rows and columns\r\n", myname);
               onintr(0);
       }
       write(tty, restore, strlen(restore));

       if (ioctl (tty, TIOCGWINSZ, &ws) != -1) {
           /* we don't have any way of directly finding out
              the current height & width of the window in pixels.  We try
              our best by computing the font height and width from the "old"
              struct winsize values, and multiplying by these ratios...*/
           if (ws.ws_col != 0)
               ws.ws_xpixel = cols * (ws.ws_xpixel / ws.ws_col);
           if (ws.ws_row != 0)
               ws.ws_ypixel = rows * (ws.ws_ypixel / ws.ws_row);
           ws.ws_row = rows;
           ws.ws_col = cols;
           ioctl (tty, TIOCSWINSZ, &ws);
       }

       tcsetattr(tty, TCSADRAIN, &tioorig);
       signal(SIGINT, SIG_DFL);
       signal(SIGQUIT, SIG_DFL);
       signal(SIGTERM, SIG_DFL);

       exit(0);

}

static void
readstring(register FILE *fp, register char *buf, char *str)
{
       register int last, c;

       signal(SIGALRM, resize_timeout);
       alarm (TIMEOUT);
       if ((c = getc(fp)) == 0233) {   /* meta-escape, CSI */
               *buf++ = c = ESC[0];
               *buf++ = '[';
       } else {
               *buf++ = c;
       }
       if(c != *str) {
               fprintf(stderr, "%s: unknown character, exiting.\r\n", myname);
               onintr(0);
       }
       last = str[strlen(str) - 1];
       while((*buf++ = getc(fp)) != last)
           ;
       alarm (0);
       *buf = 0;

}

static void
Usage(void)
{
       fprintf(stderr,
        "Usage: %s\n"
        "   sets size via ioctl\n", myname);
       exit(1);

}

static void
resize_timeout(int sig)
{
       fprintf(stderr, "\n%s: timeout occurred\r\n", myname);
       onintr(sig);

}

/* ARGSUSED */
static void
onintr(int sig)
{
       tcsetattr (tty, TCSADRAIN, &tioorig);
       exit(1);


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Christian Weisgerber  
View profile   Translate to Translated (View Original)
 More options Jul 25 2011, 1:22 pm
Newsgroups: de.comp.os.unix.misc
From: na...@mips.inka.de (Christian Weisgerber)
Date: Mon, 25 Jul 2011 17:22:56 +0000 (UTC)
Local: Mon, Jul 25 2011 1:22 pm
Subject: Re: Skalierbare serielle Konsole?

Sven Geggus <use...@fuchsschwanzdomain.de> wrote:
> Ich greife mit screen auf die serielle Konsole eines embedded Debian Systems
> zu:

> screen /dev/ttyS0 38400

> Der screen läuft in einem xterm, rxvt oder ähnlichem.

> Nun ist es so, dass der Wert von COLUMNS immer 80 ist und der Wert von LINES
> immer 24 unabhängig davon wie groß mein Terminalfenster wirklich ist und
> ändert sich nicht durch skalieren des xterm.

Wie denn auch? Es gibt keinen Mechanismus, um die Änderung der
Terminalgröße über eine serielle Leitung zu vermitteln.

(Außerdem: COLUMNS und LINES sind Environmentvariablen, die nicht
direkt an das TTY gekoppelt sind. Wenn etwas automatisch angepasst
wird, dann die columns/rows vom TTY, vgl. stty(1). Wenn sich COLUMNS
und LINES bei dir ändern, dann weil die Shell sie beim Empfang von
SIGWINCH diskret anpasst. Hier in BSD-Umgebung sind die beiden
normalerweise gar nicht gesetzt.)

> Das System selbst beherscht die dynamische Skalierung von Terminalfenstern
> prinzipiell, denn wenn ich mich per ssh einlogge ändert sich die Werte von
> LINES und COLUMNS beim skalieren dynamisch.

Das ist ein Pseudo-TTY unter Kontrolle von sshd(8), der entsprechende
Angaben auf einem separaten Signalisierungkanal von ssh(1) bekommt.

--
Christian "naddy" Weisgerber                          na...@mips.inka.de


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Gernot Zander  
View profile   Translate to Translated (View Original)
 More options Jul 25 2011, 3:48 pm
Newsgroups: de.comp.os.unix.misc
From: h...@gmx.de (Gernot Zander)
Date: Mon, 25 Jul 2011 21:48:18 +0200 (CEST)
Local: Mon, Jul 25 2011 3:48 pm
Subject: Re: Skalierbare serielle Konsole?
Hi,

in de.comp.os.unix.misc Sven Geggus <use...@fuchsschwanzdomain.de> wrote:

> Nun ist es so, dass der Wert von COLUMNS immer 80 ist und der Wert von LINES
> immer 24 unabh ngig davon wie gro mein Terminalfenster wirklich ist und
> ndert sich nicht durch skalieren des xterm.
> Wenn ich statt "screen" "minicom" verwende tritt das selbe Problem auf.
> Die Frage ist nun wie man das ndern kann. Ich vermute ein serverseitiges
> Problem.

"resize" eintippen. Das fragt das Terminal mit irgendwelchen
ESC-Sequenzen nach seiner Gr e und setzt dann die Envirinment-
Varieblen. (Bzw. eval `resize`).
Inwieweit das hinter Screen noch funktioniert/~ soll, wei ich
nicht.
(Die Bash im xterm merkt das irgendwie von selbst.)

mfg.
Gernot

--
<h...@gmx.de> (Gernot Zander) *Keine Mailkopien bitte!*
Wenn alle das t ten, was sie mich k nnten, k me ich nicht mehr
zum Sitzen.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
en...@starfleet.inka.de  
View profile   Translate to Translated (View Original)
 More options Jul 25 2011, 5:47 pm
Newsgroups: de.comp.os.unix.misc
From: <en...@starfleet.inka.de>
Date: Mon, 25 Jul 2011 21:47:52 +0000 (UTC)
Local: Mon, Jul 25 2011 5:47 pm
Subject: Re: Skalierbare serielle Konsole?
Hi Sven,

In ka.comp.linux Sven Geggus <use...@fuchsschwanzdomain.de> wrote:

telnet/ssh etc. bermitteln die Tatsache, dass die Gr e sich ge ndert
hat, "out-of-band" und generieren auf der Serverseite ein SIGWINCH. Der
Handler sorgt dann im Normalfall daf r, dass die neue Gr e abgefragt
wird etc.

Ich meine, im (seriellen) Terminallayer gibt es kein quivalent dazu.
Sicher bin ich mir aber nicht.

Gru ,
Enrik


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sven Geggus  
View profile   Translate to Translated (View Original)
 More options Jul 26 2011, 5:55 am
Newsgroups: de.comp.os.unix.misc
From: Sven Geggus <use...@fuchsschwanzdomain.de>
Date: Tue, 26 Jul 2011 09:55:49 +0000 (UTC)
Local: Tues, Jul 26 2011 5:55 am
Subject: Re: Skalierbare serielle Konsole?
In de.comp.os.unix.misc Sven Geggus <use...@fuchsschwanzdomain.de> wrote:

> Die Frage ist nun wie man das ändern kann. Ich vermute ein serverseitiges
> Problem.

FTR hier eine Zusammenfassung wie man das Problem elegant löst:

* Programm "resize" aus Rainers Posting compilieren und installieren
* Alternativ das Programm "resize" aus dem xterm Paket verwenden

Die serielle Konsole sendet offensichtlich kein SIGWINCH an das Programm das
im Terminal läuft. Daher muss man die zweitbeste Lösung wählen und einfach
immer vor dem Ausführen eines neuen Befehls die Fenstergröße richtig
einstellen. Dazu steckt man sowas in /etc/profile:

if [ "$PS1" ]; then
  if [ $(tty) == '/dev/ttyS0' ]; then
    trap resize DEBUG
  fi
fi

Ein Problem das weiterhin bestehen bleibt ist die Änderung der Fenstergröße
während ein curses basiertes Programm läuft. Wegen fehlendem SIGWINCH kannd
as Programm natürlich nicht reagieren.

Gruss

Sven

BTW: 1:0 hier bei Usenet vs. Stackexchange :)

--
"Those who do not understand Unix are condemned to reinvent it, poorly"
(Henry Spencer)

/me is giggls@ircnet, http://sven.gegg.us/ on the Web


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »