Nuts, stupid mastake I know, I should have
read the example more, but it was getting late, honest!

I did try an example of non-canocal communications with
and it got the same results as I got here.  Maybe I need
a better question. Ok, so as you know the ps/2 is plugged
in at boot time. That is the mouse used by the window system.
When I plug the mouse (or any device really) into the serial
port do I have to "wake it up" ? I know if i query the mouse
by toggling the DTR the mouse will send back an 'M' . Thats
all fine and good but do I need to toggle the DTR before I can
accept input from the mouse on the serial port?

Thanks again for you help,
-mya

[EMAIL PROTECTED] wrote:
> 
> On Sat, 1 Apr 2000, Marwan Ansari wrote:
> 
> >
> > Hi all,
> >       I need to write some code that will read input
> > from a serial port that has a mouse attached to it.
> > First try is on linux but its got to be ported to windows
> > next. The linux attempt is a proof of concept.
> >
> >       Before you write the email saying : Dude,
> >       you can just use the windows or os calls to get
> >       to the mouse...no, no i cant.
> >
> > The situation is this: I need two mice on a single system.
> > but only one mouse will control the mouse cursor, i just want
> > to read the input off the other. The mouse cursor will be ps/2,
> > the other will be plugged into a serial port..hence I need to read
> > from a serial port.
> >
> > ACK! but it doesnt work. Im following an example online but im not
> > having any luck. I can open the port, i can configure the port..i
> think,
> > but when i goto read the port..it fails with "Input/output error"
> > Does anyone know howto do this?
> >
> >
> >
> > Many Thanks in advance!
> > -Marwan
> >
> >
> >
> > here is the code...its brief and should compile with no issues:
> >
> > ///// code starts here /////
> > #include <stdio.h>   /* Standard input/output definitions */
> > #include <string.h>  /* String function definitions */
> > #include <unistd.h>  /* UNIX standard function definitions */
> > #include <fcntl.h>   /* File control definitions */
> > #include <errno.h>   /* Error number definitions */
> > #include <termios.h> /* POSIX terminal control definitions */
> > #include <term.h> /* POSIX terminal control definitions */
> >
> > /*
> >  * 'OpenPort()' - Open serial port 1.
> >  *
> >  * Returns the file descriptor on success or -1 on error.
> >  */
> >
> > int OpenPort(char *) ;
> > void ConfigurePort(int port) ;
> > void ReadPort(int port) ;
> > void ClosePort(int port) ;
> > //////////////////////////////////////////////////////////
> > int
> > main(int argc, char **argv) {
> >
> >
> >    int port = 0;
> >    if( argc == 1)
> >       port = OpenPort(NULL);
> >    else
> >       port = OpenPort(argv[1]);
> >
> >    if(port) {
> >
> >       ConfigurePort(port) ;
> >       ReadPort(port);
> >       ClosePort(port);
> >    }
> > }
> > //////////////////////////////////////////////////////////
> > void ConfigurePort(int port) {
> >
> >    struct termios options ;
> >
> >    tcgetattr(port,  &options);
> >    printf(" c_cflag: %d\n",options);
> >
> >
> >    // set the baud rate
> >    cfsetispeed(&options, B1200);
> >    cfsetospeed(&options, B1200);
> >
> >    //Enable the receiver and set local mode...
> >    options.c_cflag |= (CLOCAL | CREAD);
> >
> >    // set character size
> >    options.c_cflag &= ~CSIZE; /* Mask the character size bits */
> >    options.c_cflag |= CS8;    /* Select 8 data bits */
> >
> >    // set parity: Even parity (7E1):
> >    options.c_cflag |=  PARENB;
> >    options.c_cflag &= ~PARODD;
> >    options.c_cflag &= ~CSTOPB;
> >    options.c_cflag &= ~CSIZE;
> >    options.c_cflag |=  CS7;
> >
> Did you even bother to read the comments in the example you are trying
> to use??  You are meant to select what you need from this example, not
> gobble the whole thing.  What is the point to setting CS8, then
> CS7? //set hw flow control, then //set software flow control?  Pay
> attention to what the **!\ you are doing.  I very much doubt any mouse
> is going to give you canonical input.  ICBW, of course :-)
> 
> >    // set hw flow control
> >    options.c_cflag |=  CRTSCTS ; //CNEW_RTSCTS;    /* Also called
> > CRTSCTS */
> >
> >    // set canonical input
> >    options.c_lflag |= (ICANON | ECHO | ECHOE);
> >
> >    // set input parity options
> >    options.c_iflag |= (INPCK | ISTRIP);
> >
> >    // set software flow control
> >    options.c_iflag |= (IXON | IXOFF | IXANY);
> >
> >    //Set the new options for the port...
> >    tcsetattr(port, TCSANOW, &options);
> >
> > }
> > //////////////////////////////////////////////////////////
> > void ReadPort(int port) {
> >
> >    int done=0;
> >    char buffer[80];
> >    int readAmount =0;
> >
> >    while( !done ) {
> >
> >       memset(buffer, 0, 80);
> >       readAmount = read( port, buffer, 10);
> >       if( readAmount != -1 ) {
> >
> >          printf("Got data %d bytes:|%s|\n",readAmount,buffer);
> >          readAmount = 0;
> >       }
> >       else {
> >          if ( readAmount == -1 ) {
> >
> >             perror("Got error:");
> >             return;
> >          }//endif
> >          else {
> >
> >             printf("EOF\n");
> >             return;
> >          }
> >       }//endelse
> >    }//endwhile
> >
> > }
> > //////////////////////////////////////////////////////////
> > void ClosePort(int port) {
> >
> >    close(port);
> > }
> > //////////////////////////////////////////////////////////
> > int OpenPort(char *device) {
> >
> >   int fd; /* File descriptor for the port */
> >   char portname[80];
> >   char error[80];
> >
> >   if( device == NULL)
> >      strcpy(portname,"/dev/ttyS0");
> >   else
> >      strcpy(portname,device);
> >
> >   fd = open( portname , O_RDWR | O_NOCTTY | O_NDELAY);
> >   if (fd == -1) {
> >
> >    /*
> >     * Could not open the port.
> >     */
> >
> >     sprintf(error,"open_port: Unable to open %s  -", portname);
> >     perror(error);
> >     fd =0;
> >   }
> >   else {
> >     int bytes =0;
> >     printf("Opend the port:|%s|\n",portname);
> >     fcntl(fd, F_SETFL, 0);
> >   }
> >   return (fd);
> > }
> >
> > -
> > To unsubscribe from this list: send the line "unsubscribe linux-serial"
> > in
> > the body of a message to [EMAIL PROTECTED]
> >
> I bet you wish I would :-)
> 
> Lawson
>           >< Microsoft free environment
> 
> This mail client runs on Wine.  Your mileage may vary.
> 
> ---cut here---
> 
> ________________________________________________________________
> YOU'RE PAYING TOO MUCH FOR THE INTERNET!
> Juno now offers FREE Internet Access!
> Try it today - there's no risk!  For your FREE software, visit:
> http://dl.www.juno.com/get/tagj.

-
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to [EMAIL PROTECTED]

Reply via email to