From: kevin@shady.UUCP (Kevin Smith)
Newsgroups: biz.sco.general
Subject: Re: Logitech C9 Serial Mouse at 9600 Baud
Date: 2 Jan 93 08:46:17 GMT
Organization: ShadeTree Software, Inc.

In article <9212311731.aa13710@scoke.sco.COM> belal@sco.COM (Bela Lubkin) writes:
:>Kevin Smith wrote:
:>
:>> It doesn't appear that the STTY and INIT strings are in any way
:>> configured into the kernel.  For a serial mouse, then, this must be
:>> handled by the event library calls (By the way, I seem to be missing
:>> my ev_open() man pages).  The sequence would be, I believe, to apply
:>> the STTY to the port then send the INIT string, after which,
:>> everything should be ready to go.
:>
:>I've included ev_open(S) below (compressed, uuencoded -- it has
:>formatting which will not necessarily transport correctly over the
:>Internet).
:>
:>It is ev_open() which sends the INIT string to the mouse port.  The
:>string itself is meaningful to the mouse, not the kernel.  The serial
:>mouse init strings in /usr/lib/event/devices all have the form "*nNx",
:>where "x" varies depending on the mouse mode to be used.  So presumably
:>either "n" or "N" is the baud rate specifier.  I'd say, experiment with
:>it.  With nothing using the serial mouse, do this:
:>
:>  on multiscreen 1: sleep 10000 < /dev/tty1a    # keep the port open
:>  on multiscreen 2: hd /dev/tty1a               # log mouse output
:>  on multiscreen 3: stty 1200 < /dev/tty1a
:>  on multiscreen 3: echo "*nNU\c" > /dev/tty1a  # init to default mode
:>  <move mouse around, look at the hex output on screen 2, get an idea of
:>   what it's supposed to look like when it's working correctly>
:>  on multiscreen 3: stty 2400 < /dev/tty1a
:>  on multiscreen 3: echo "*nOU\c" > /dev/tty1a  # init 2400??
:>  <move mouse around: is it making sense on screen 2?>
:>
:>I learned from the ev_open() source that the baud rate is set before the
:>init string is sent.  So I'm guessing that the mouse automatically
:>handles varying baud rates for the init string, which probably means the
:>first two characters are just to get it in sync.  So the third is
:>probably the baud rate, thus the guess of "*nOU" to initialize the same
:>mouse mode at 2400bps.
:>
:>Anyone with tech docs for a Logitech serial mouse should be able to
:>answer this instantly...
:>
:>>Bela<

Through further experimentation I have discovered the following:

    The mouse is initially operating at 1200 baud.

    The sequence "*nN?" where ? is the operational/encoding mode
    for the mouse ("U" for SCO).

    The 'n' in the sequence encodes the baud rate and must be
    delivered at the current operating rate of the mouse (i.e.
    it doesn't seem to do any baud rate matching like modems).

	n = 1200, o=2400, p=4800, q=9600

    I was able to step through the speeds with

	<starting at the default 1200 baud>
	echo "*oNU
	stty 2400
	<works now at 2400>
	echo "*pNU"
	stty 4800
	<works now at 4800>
	echo "*qNU"
	stty 9600
	<works now at 9600>

    so... the following script will put the mouse in 9600 baud
    mode

	(
	    stty 1200
	    echo "*qNU"
	) </dev/tty1a >/dev/tty1a

    With the mouse now in 9600 baud mode, I edited /usr/lib/event/devices
    and changed the INIT and STTY strings for "*qNU" and "... 9600 ..."

    Normally this would not work since (as Bela pointed out) ev_open()
    sets the baud rate before issuing the INIT and the modem would not
    (if not at 1200 baud) recognize the control string.  Since I have
    already programmed the modem into 9600 baud mode it still works
    after the stty and the INIT string is redundant (since the mouse
    is already programmed) but necessary since the original '*nNU' would
    put the mouse right back into 1200 baud mode.  I could, I guess,
    eliminate the INIT string or set it to something harmless.

    I created an rc2.d/S88mouse script to do the initial programming
    and my pointer is now gracefully sliding around my display.
    This is a bit of a hack but I'll live with it.
-- 
	    | Email - !shady!kevin uunet!shady!kevin kevin%shady@uunet.uu.net
Kevin Smith | Voice - (+1) (908) 874-7980
	    | Mail  - ShadeTree Software, Inc., 192 Capricorn Dr. #10,
	    |         Somerville, NJ  08876, USA