[comp.os.minix] [PC] Has someone run serial line w 38400 Baud ?

regn@geyer.UUCP (Robert Regn) (04/11/91)

A real 386 PC should be able to run the serial lines with 38400
(or higher ) Baud. But when i try it ( init.c and getty.c are changed!)
i get only garbage chars. 19200 works. Is the problem in the driver ?
(i try to log INTO the Minix PC - a HP vectra orig. with 1.5[.10] )

-- 
	Robert Regn				University of Wuerzburg, Germany
	regn@informatik.uni-wuerzburg.dbp.de

evans@syd.dit.CSIRO.AU (Bruce.Evans) (04/11/91)

In article <650@geyer.UUCP> regn@informatik.uni-wuerzburg.dbp.de  (Robert Regn) writes:
>A real 386 PC should be able to run the serial lines with 38400
>(or higher ) Baud. But when i try it ( init.c and getty.c are changed!)
>i get only garbage chars. 19200 works. Is the problem in the driver ?

The 'argp->sg_ispeed' and 'argp->sg_ospeed' variables in ioctl.c are
(unsigned) chars, so they only range from 0 to 255. In the driver, they
are multiplied by 100 so the speed only ranges from 0 to 25500. This
packing and encoding is stupid. Here is a hack (even stupider encoding
:-) to allow some higher speeds. Someday these speeds should be defined
as B115200 etc in sgtty.h (and termios.h?).

table
 !"#$%&'()*+,-./0123456789:;<=>?
@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_
begin 644 rs.shar.Z
M'YV-(T* >"$FC9L7<] H& %BR!LW=,I G*,#! @Y<V3,D.%B3$<R(.;0H9.Gz
MX\>%(*[("0,'3AF08O*$E#,&B)@R<^"P*8,'Q$,05-#4 1$$CAP0,6(@K:$#y
M!@T=-&H@S9$CA@(H0:@@Z4'0H(X7=>;(Z>KF:]BQ=<:( ;$#!$\X;^30 8%5x
MJX(T9D!$% FB1=X3&#5R]#B&S(F^84"((+$G1A\1($+T4-QB#.2V=-!(!*' w
M8IDQ:-Z$1!-&3L4K:=BP >'FS=PQ;-Z(N7F49QJ1!L^ ,).Z# @N(@!GW&BRv
M\ G@"LJPF5,F.6C1"4M7+(*'SLHQ='+_#AZ8.&'#P'^CJ"'#!@C0I<-@+X.1u
M2PH%S$&*F//""Y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"X>JA"(_M*!"WE41!&4RV!*Q&&XE.5$'PYL*O"2(A'I$$,1S*!?O,HB$[FXc
MKA[:ZHL%R]8482A#B*7QAFO<(18LXD9YE<$,@6(#'<1(13+*T&UK:,T=W*#$b
M#6;P2>8[40UP0*4:""E+(H19>61 I1L(24PM0&%.RO 2%-"04#P\%AWJ( <Wa
MZ)%B%EN7112'@O>-"@TH6!D=6*"8(]8P!7': P]'64H8S0"5;50E*UT9L(HUz
MDY:V))4N>6E%<]TQF,/$%!E,F0,:(--3"5!F*U]9IEA2#)IAN&4NX;!+Q9S1y
M7S;$9AN)N4T8U>";( AG&58YSF::LTSH5.<T%6/') )35=DD93W!A$P^BI.9x
MX$O:^)BFN*>!@'G.:\'4JG:UR@!H>\<SCM<Z)Q&Q@8YWT*L(\>9WN[:]33T;w
M @G=T& WO(5D;WW[6QH"YX;!_86E:]/I[J"34A 4H:<^R4M"E+.:TH &365Pv
'07):-Q<9 85Du
 t
end
-- 
Bruce Evans		evans@syd.dit.csiro.au

waltje@uwalt.nl.mugnet.org (Fred 'The Rebel' van Kempen) (04/16/91)

regn@geyer.UUCP (Robert Regn) wrote:
> A real 386 PC should be able to run the serial lines with 38400
> (or higher ) Baud. But when i try it ( init.c and getty.c are changed!)
> i get only garbage chars. 19200 works. Is the problem in the driver ?
> (i try to log INTO the Minix PC - a HP vectra orig. with 1.5[.10] )

I run my machines at speeds up to 115Kbps - no problem.  
However, for to put less load on the kernel (115Kbps is 11,000
ints per second :-(  ), I installed NS16550 UART's and rewrote
the serial drivers.

Fred.
--
MicroWalt Corporation, for MINIX Development	waltje@uwalt.nl.mugnet.org
Tel (+31) 252 230 205, Hoefbladhof  27, 2215 DV  VOORHOUT, The Netherlands
	"An Operating System is what the _USERS_ think of it- me"

waltje@uwalt.nl.mugnet.org (Fred 'The Rebel' van Kempen) (04/28/91)

regn@geyer.UUCP (Robert Regn) wrote:
> A real 386 PC should be able to run the serial lines with 38400
> (or higher ) Baud. But when i try it ( init.c and getty.c are changed!)
> i get only garbage chars. 19200 works. Is the problem in the driver ?
> (i try to log INTO the Minix PC - a HP vectra orig. with 1.5[.10] )

The standard MINIX serial driver only supports (certain) baud rates
between 110 and 9600, with 19200 being defined as EXTA.

Several people thought about fixing this, but that would include a
complete rewrite of the ioctl() system call implementation, since
it currently uses divide-by-100 encoding for the speeds.  This
results in a maximum of (255 * 100) == 25.5Kbps .... :-(

I just finished a TTY-driver with the new ioctl() structure.  For
_backward_ compatibility, I added some code in the TTy driver to
convert old-style ioctl()s to new-style ones.  Here is my version
of sgtty.h :

/* The <sgtty.h> header contains data structures for ioctl(). */

#ifndef _SGTTY_H
#define _SGTTY_H

struct sgttyb {
  char sg_ispeed;		/* input speed */
  char sg_ospeed;		/* output speed */
  char sg_erase;		/* erase character */
  char sg_kill;			/* kill character */
  int  sg_flags;		/* mode flags */
};

struct tchars {
  char t_intrc;			/* SIGINT char */
  char t_quitc;			/* SIGQUIT char */
  char t_startc;		/* start output (initially CTRL-Q) */
  char t_stopc;			/* stop output	(initially CTRL-S) */
  char t_eofc;			/* EOF (initially CTRL-D) */
  char t_brkc;			/* input delimiter (like nl) */
};

/* Field names */
#define XTABS	     0006000	/* do tab expansion */
#define CS8	     0001400	/* 8 bits/char */
#define CS7          0001000	/* 7 bits/char */
#define CS6          0000400	/* 6 bits/char */
#define CS5          0000000	/* 5 bits/char */
#define EVENP        0000200	/* even parity */
#define ODDP         0000100	/* odd parity */
#define RAW	     0000040	/* enable raw mode */
#define CRMOD	     0000020	/* map lf to cr + lf */
#define ECHO	     0000010	/* echo input */
#define CBREAK	     0000002	/* enable cbreak mode */
#define COOKED       0000000	/* neither CBREAK nor RAW */
#define DCD          0100000	/* Data Carrier Detect */

/* Line speeds */
#define B0	0	/* code for line-hangup */
#define B50	1
#define B75	2
#define B110	3
#define B134	4
#define B150	5
#define B200	6
#define B300	7
#define B600	8
#define B1200	9
#define B1800	10
#define B2400	11
#define B3600	12
#define B4800	13
#define B7200	14
#define B9600	15
#define B19200	16
#define B38400	17
#define B115200	18

/* I/O control codes. */
#define TIOCGETP (('T'<<8) | 8)
#define TIOCSETP (('T'<<8) | 9)
#define TIOCGETC (('T'<<8) | 18)
#define TIOCSETC (('T'<<8) | 17)
#define TIOCFLUSH (('T'<<8) | 16)
#define TIOCICNT (('T'<<8) | 19)

/* Things Minix supports but not properly */
#define ANYP         0000300

/* Things Minix doesn't support but are fairly harmless if used */
#define NLDELAY      0001400
#define TBDELAY      0006000
#define CRDELAY      0030000
#define VTDELAY      0040000
#define BSDELAY      0100000
#define ALLDELAY     0177400

#if MACHINE == ATARI
/* ST specific clock stuff */

#define	 DCLOCK	('D'<<8)

#define	DC_RBMS100	(DCLOCK|1)
#define	DC_RBMS200	(DCLOCK|2)
#define	DC_RSUPRA	(DCLOCK|3)
#define	DC_RICD  	(DCLOCK|4)
#define	DC_WBMS100	(DCLOCK|8)
#define	DC_WBMS200	(DCLOCK|9)
#endif

/* Old-style stuff, for (temp.) backwards compatibility */
#if 1
#define OB0	0	/* code for line-hangup */
#define OB110	1
#define OB200	2
#define OB300	3
#define OB600	6
#define OB1200	12
#define OB1800	18
#define OB2400	24
#define OB3600	36
#define OB4800	48
#define OB7200	72
#define OB9600	96
#define OEXTA	192

#define OTIOCGETP (('t'<<8) | 8)
#define OTIOCSETP (('t'<<8) | 9)
#define OTIOCGETC (('t'<<8) | 18)
#define OTIOCSETC (('t'<<8) | 17)
#define OTIOCFLUSH (('t'<<8) | 16)
#define OTIOCICNT (('t'<<8) | 19)

#define	BITS8	CS8
#define	BITS7	CS7
#define	BITS6	CS6
#define	BITS5	CS5
#endif	/* COMPAT */

#include <ansi.h>

_PROTOTYPE( int gtty, (int _fd, struct sgttyb *_argp)			);
_PROTOTYPE( int ioctl, (int _fd, int _request, struct sgttyb *_argp)	);
_PROTOTYPE( int stty, (int _fd, struct sgttyb *_argp)			);

#endif /* _SGTTY_H */

It works well.  I can now talk to "minixug" at 115Kbps, which is much
better than 19K2 ! :-)

Fred.
--
MicroWalt Corporation, for MINIX Development	waltje@uwalt.nl.mugnet.org
Tel (+31) 252 230 205, Hoefbladhof  27, 2215 DV  VOORHOUT, The Netherlands
	"An Operating System is what the _USERS_ think of it- me"