[nSLUG] Serial drivers for Ubuntu 10.04?

Mike Spencer mspencer at tallships.ca
Fri Feb 1 16:17:47 AST 2013

Joel Maxuel wrote:

> The particular conversation I was thinking of is:
> http://old.nabble.com/Analog-to-digital-optical-sensor-for-Linux-sought-to34223172.html

Since this references a thread that I started, perhaps I shoud add the
little FWIW bits that I have in my notes from this successful project.

Even before I had sensor hardware that would toggle the button-1
switch on a serial mouse, I found I was unable to read data from the
serial port using the perl locution:

   open IN, ("</dev/ttyS0") || die "Can't cat the mouse";

Eventually, I found that if I manually rexecuted:

   gpm -m /dev/ttyS0 -b 9600 -t ms3 -3

from the command line as root before starting the perl script, the
"open IN..." resulted in a readable IN handle.

The -t argument to gpm (See: gpm(8) manpage) mattered. "-t ms" enabled
reading from ttyS0 but incoming data was all zeroes. I tried various
values for this argument before I got one that would work
consistently.  See gpm-types(7). I was never able to acquire clicks
from the middle button of the mouse but I didn't pursue it further
because I only needed one button's data for my purpose.

Another weirdness is that gpm did not have to remain running as a
daemon.  That is, having executed the gmp command as above, I could
then kill the gpm process and my perl script would continue to read
data from ttyS0. 

Another step on the way to success was to enable /etc/rc.d/rc.serial,
making sure that rc.serial referenced the right ttySx. On my machine,
BTW, /dev/ttySx is a symlink to /dev/tts/x for x == {0,1,2,3}. 

I also chmod'ed /dev/tts/0 to 644 but found that udev reset perms at
boot.  So I added "chmod 644 /dev/tts/0" to rc.local.

Another thought: I was reading a serial port directly in an xterm
while X was running and using a mouse so I did *not* want /dev/mouse
to point to that serial port. You probably *do* want that if your
trackball is to become you main X pointer.

I use Slackware, have never used Ubuntu.  I have no idea what the
equivalients of /etc/rc.d/* are in Ubuntu if those files don't
exist. My (rather anecdotal) impression of Ubuntu is that it
intentionally obscures (obfuscates?)  access to low-level technical
details.  So all this is a shot in the dark but is at least vaguely
relevant to your problem, Trina. (Some days, vague relevance is a
cognitive win for me. :-)

I suppose, if you grok perl, you could write a simple script similar
to the one I used for my mouse tach project and see if you can
read/detect anything on /dev/ttySx, playing around as I did with gpm(8)
and various arguments. That might give you some clue as to which driver
would work in in the xorg.conf locution:

   Section "InputDevice"
      Identifier  "Mouse0"
      Driver      "mouse"
      Option      "Protocol" [what-goes-here?]

Still more tangentially: I have the following note in xorg.conf about a
mouse I retired last year:

# X thinks the USB optical mouse has 11 buttons, even with the Buttons
# 3 option.  We only have 3 buttons and we don't want ZAxis (wheel)
# support.  This is dealt with in ~/.Xmodmap where we have: pointer =
# 2 3 1 4 5 6 7 8 9 10 11 which seems to have no ill side effects.  
# -- mds, 21 May 2009

Together with a couple of other never-resolved mouse problems I've had
with X, all this is grounds to infer that mouse tech in Linux/X
remains a bit wonky and unpredictable.  So don't give up too easily.

- Mike

Michael Spencer                  Nova Scotia, Canada       .~. 
mspencer at tallships.ca                                     /( )\
http://home.tallships.ca/mspencer/                        ^^-^^

More information about the nSLUG mailing list