=C4h, das finde ich nicht so klasse.
~B ist bei cu und ssh die Sequenz, um ein Break zu senden. Kannst du =20
f=FCr das Hex-Senden nicht eine Drei-Zeichen-Sequenz verwenden, z. B. =20=
~xDD?
Und stilistisch: Konstanten werden immer in vollst=E4ndigen =20
Gro=DFbuchstaben definiert, also sollte es ESCAPESTATE_WAITFOR2NDDIGIT =20=
hei=DFen.
Gru=DF,
Stefan
Am 29.11.2007 um 06:04 schrieb Dirk Jagdmann:
> Update of /cvsroot/serialconsole/sc
> In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv31048
>
> Modified Files:
> README sc.1 sc.c
> Log Message:
> added sending of arbitrary character via a new escape action
> sending break is now done with ~x
> updated help texts and manpage
>
>
> Index: README
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> RCS file: /cvsroot/serialconsole/sc/README,v
> retrieving revision 1.7
> retrieving revision 1.8
> diff -u -d -r1.7 -r1.8
> --- README 11 Jul 2007 18:57:57 -0000 1.7
> +++ README 29 Nov 2007 05:04:32 -0000 1.8
> @@ -19,6 +19,8 @@
>
> 0.95
> - add "-d" parameters which sets a delay after writing a newline =20
> character.
> +- allow arbitrary characters to be composed with the escape =20
> character.
> +- escape break character is now 'x'
>
> 0.94
> - Fix DTR setting code
>
> Index: sc.1
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> RCS file: /cvsroot/serialconsole/sc/sc.1,v
> retrieving revision 1.6
> retrieving revision 1.7
> diff -u -d -r1.6 -r1.7
> --- sc.1 25 Oct 2007 01:30:28 -0000 1.6
> +++ sc.1 29 Nov 2007 05:04:32 -0000 1.7
> @@ -91,9 +91,11 @@
> The escape character can be used to end the connection to the serial =20=
> device,
> send special characters over the connection, and terminate
> .Nm .
> -The escape character must always follow a newline to be interpreted =20=
> as
> -special. It can be changed using the
> +The escape character must always follow a newline (more specific: a =20=
> carriage return character) to be interpreted as
> +special. The character can be changed using the
> .Fl e
> +option. Some escape actions output a message indicating which =20
> action was executed. To turn off those messages use the
> +.Fl q
> option.
> .Pp
> The supported escapes (assuming the default
> @@ -104,8 +106,10 @@
> Send a single ~ to the device.
> .It Cm ~.
> Disconnect.
> -.It Cm ~B
> +.It Cm ~X
> Send a BREAK to the device, if supported by the driver.
> +.It Cm ~<2x hex character>
> +Reads two hexadecimal digits and sends one byte representing those =20=
> digits. Valid hex characters are 0-9, a-f, A-F.
> .El
> .\" .Sh BUGS
> .Sh SEE ALSO
>
> Index: sc.c
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> RCS file: /cvsroot/serialconsole/sc/sc.c,v
> retrieving revision 1.8
> retrieving revision 1.9
> diff -u -d -r1.8 -r1.9
> --- sc.c 11 Jul 2007 17:27:30 -0000 1.8
> +++ sc.c 29 Nov 2007 05:04:32 -0000 1.9
> @@ -139,12 +139,14 @@
> enum escapestates {
> ESCAPESTATE_WAITFORCR =3D 0,
> ESCAPESTATE_WAITFOREC,
> - ESCAPESTATE_PROCESSCMD
> + ESCAPESTATE_PROCESSCMD,
> + ESCAPESTATE_WAITFOR2ndDIGIT,
> };
>
>
> static int scrunning =3D 1;
> static char *path_dev =3D PATH_DEV "/";
> +static int qflag =3D 0;
>
>
> static void
> @@ -266,11 +268,42 @@
> ti->c_cflag & CRTSCTS ? "" : "no ");
> }
>
> +static int
> +hex2dec(char c)
> +{
> + switch(c)
> + {
> + case '0': return 0;
> + case '1': return 1;
> + case '2': return 2;
> + case '3': return 3;
> + case '4': return 4;
> + case '5': return 5;
> + case '6': return 6;
> + case '7': return 7;
> + case '8': return 8;
> + case '9': return 9;
> + case 'a': return 10;
> + case 'b': return 11;
> + case 'c': return 12;
> + case 'd': return 13;
> + case 'e': return 14;
> + case 'f': return 15;
> + case 'A': return 10;
> + case 'B': return 11;
> + case 'C': return 12;
> + case 'D': return 13;
> + case 'E': return 14;
> + case 'F': return 15;
> + }
> + return -1;
> +}
>
> static int
> loop(int sfd, int escchr, int msdelay)
> {
> enum escapestates escapestate =3D ESCAPESTATE_WAITFOREC;
> + unsigned char escapedigit;
> int i;
> char c;
> #if defined(HAS_BROKEN_POLL)
> @@ -328,6 +361,7 @@
> escapestate =3D =
ESCAPESTATE_WAITFOREC;
> }
> break;
> +
> case ESCAPESTATE_WAITFOREC:
> if (escchr !=3D -1 && =
((unsigned char)c) =3D=3D escchr) {
> escapestate =3D =
ESCAPESTATE_PROCESSCMD;
> @@ -337,21 +371,42 @@
> escapestate =3D =
ESCAPESTATE_WAITFORCR;
> }
> break;
> +
> case ESCAPESTATE_PROCESSCMD:
> escapestate =3D =
ESCAPESTATE_WAITFORCR;
> - switch (tolower(c)) {
> + switch (c) {
> case '.':
> =
scrunning =3D 0;
> =
continue;
> - case 'b':
> +
> + case 'x':
> + case 'X':
> + =
if(!qflag)
> + =
fprintf(stderr, "sending a break\r\n");
> =
tcsendbreak(sfd, 0);
> =
continue;
> +
> default:
> + if =
(isxdigit(c)) {
> + =
escapedigit =3D hex2dec(c) * 16;
> + =
escapestate =3D ESCAPESTATE_WAITFOR2ndDIGIT;
> + =
continue;
> + }
> if =
(((unsigned char)c) !=3D escchr) {
> =
write(sfd, &escchr, 1);
> }
> }
> break;
> +
> + case =
ESCAPESTATE_WAITFOR2ndDIGIT:
> + escapestate =3D =
ESCAPESTATE_WAITFORCR;
> + if(isxdigit(c)) {
> + escapedigit +=3D =
hex2dec(c);
> + write(sfd, =
&escapedigit, 1);
> + if(!qflag)
> + =
fprintf(stderr, "wrote 0x%02X character\r\n", escapedigit);
> + }
> + break;
> }
> i =3D write(sfd, &c, 1);
> if(c =3D=3D '\n' && msdelay > 0)
> @@ -401,24 +456,29 @@
> static void
> usage(void)
> {
> - fprintf(stderr, "Connect to a serial device, using this system =
as =20
> a console, version %s.\n"
> - "usage: sc [-fmq] [-d ms] [-e escape] [-p parms] =
[-s speed] =20
> device\n"
> + fprintf(stderr, "Connect to a serial device, using this system =
as =20
> a console. Version %s.\n"
> + "usage:\tsc [-fmq] [-d ms] [-e escape] [-p =
parms] [-s speed] =20
> device\n"
> "\t-f: use hardware flow control (CRTSCTS)\n"
> "\t-m: use modem lines (!CLOCAL)\n"
> "\t-q: don't show connect and disconnect =
messages\n"
> "\t-d: delay in milliseconds after each newline =
character\n"
> - "\t-e: escape char or \"none\", default \"~\"\n"
> + "\t-e: escape char or \"none\", default '~'\n"
> "\t-p: bits per char, parity, stop bits, default =
\"%s\"\n"
> "\t-s: speed, default \"%s\"\n"
> "\tdevice, default \"%s\"\n",
> SC_VERSION, DEFAULTPARMS, DEFAULTSPEED, =
DEFAULTDEVICE);
> + fprintf(stderr, "escape actions are started with the 3 or 4 =20
> character combination: CR + ~ +\n"
> + "\t~ - send '~' character\n"
> + "\t. - disconnect\n"
> + "\tx - send break\n"
> + "\t<2 hex digits> - send decoded character\n");
> #if defined(TERMIOS_SPEED_IS_INT)
> - fprintf(stderr, "\tavailable speeds depend on device\n");
> + fprintf(stderr, "available speeds depend on device\n");
> #else
> {
> struct termios_speed *ts =3D termios_speeds;
>
> - fprintf(stderr, "\tavailable speeds: ");
> + fprintf(stderr, "available speeds: ");
> while (ts->speed !=3D 0) {
> fprintf(stderr, "%ld ", ts->speed);
> ts++;
> @@ -439,7 +499,6 @@
> char *parms =3D DEFAULTPARMS;
> int fflag =3D 0;
> int mflag =3D 0;
> - int qflag =3D 0;
> int sfd =3D -1;
> char buffer[PATH_MAX+1];
> struct termios serialti, consoleti, tempti;
>
>
> =
-------------------------------------------------------------------------
> SF.Net email is sponsored by: The Future of Linux Business White Paper
> from Novell. =46rom the desktop to the data center, Linux is going
> mainstream. Let it simplify your IT future.
> http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
> _______________________________________________
> Serialconsole-developers mailing list
> Ser...@li...
> https://lists.sourceforge.net/lists/listinfo/serialconsole-developers
--=20
Stefan Bethke <st...@la...> Fon +49 170 346 0140
|