[comp.os.minix] ST-MINIX ioctls, RS232 etc.

SQ79%liverpool.ac.uk@nsfnet-relay.ac.uk (Mark Powell) (09/14/89)

   I've been playing around with RS232, on minix lately. I just got all the
PC1.4 stuff off of a PC owning friend and have been installing all the new
commands. I've installed the new init.c, which sets the bauds rate/bits per
char./parity for the tty1 line. After delving into the alltar kernel I
realised that the ST doesn't support bits per char & parity, so I want about
adding them. I used the PC definitions for BITS and PAR i.e.

BITS8    0001400
BITS7    0001000
BITS6    0000400
BITS5    0000000
EVENP    0000200
ODDP     0000100

(I think, I've not got the sgtty.h handy.)
I also added support for stop bits. As below

STPB2    0030000
STPB15   0020000
STPB1    0010000

I'm not well up on UN*X standards so I'd like someone to  tell me whether
adding support for changing the number of stop bits is breaking some
fundamental rule. It seems a logical thing to have in there, but if it is
breaking rules then I may remove it for compatibility's sake.
   I added a new routine in rs232.c called set_ucr, which sets the MFP's
ucr register from the bits/parity/stop bits info. in tty->tty_mode. I also
put in  a debugging line in so I could see what byte was being written to
MFP->mf_ucr. From looking at the code it seems that HCJ has altered rstty.c
so that TIOCSETP, doesn't alter the baud (presumably to stop naughty programs
like more etc. from corrupting your baud rate), but added a new ioctl TCBAUD
which will, in fact, set the baud. I changed rstty.c so that TIOCSETP does in
fact call the rs232.c TIOCSETP and set the timer and the ucr, as it should
do. Is this okay, I wouldn't want to be missing something here Howard. This
seems to work sort of okay except that init.c is not able to change the baud
rate from the default set in rs232.c. Also, with debugging info. I can see
that whenever a program opens tty1, SET_TIMER goes and sets the baud to 4
(2400) again. Why? Is the kernel resettng the baud? I'm using HCJ's ioctl
from cu.tar, but I couldn't seem to work out what this exactly does.
Also, I set sgttyb.flags (or whatever) to the correct parity, stopbits and
bits per char, in init.c. A short diagnostic program I wrote which simply
opens the tty1 line and dumps the sgttyb and tchars structures, displays
a correct sgttyb.flags, the first time it is run since init set up the line.
However, the second time it is run the bits/parity/stop bits info. has been
cleared away from the flags info. just leaving the RAW, CRMOD etc. in tact.
I guessed closing the rs232 was doing a bitwise AND which was clearing those
bits that I was using for my ucr info. (as this is what the old login did
but I fixed it!) However, I haven't been able to solve the problem.
   Any ideas, anyone? (to all the questions I've put)

Mark Powell

ARPA : sq79%liv.ac.uk@nsfnet-relay.ac.uk
UUCP : ...!mcvax!ukc!liv.ac.uk!sq79