🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: es.comp.os.linux.programacion
Article #12885

Re: Detectar si hay un mouse serie conectado a un PC

#12885
From: Manuel López
Date: Fri, 04 May 2001 16:01
51 lines
2093 bytes
Santiago Romero <sromero@servicom2000.com> escribi�:

> >	* Pincho un mouse:
> >	# statserial -x /dev/ttyS0
> >	4106
>  
>   Pues nada, parec�a la mejor soluci�n y la he aplicado
>   pero a mi me devuelve 4006 haya o no un mouse serie :((

Pues eso tiene pinta de fallo hardware.

Un regalito directamente inspirado en statserial.c:

==================================================

#include <stdio.h>	// perror(), printf()
#include <sys/ioctl.h>	// ioctl)(), TIOCM_x

int main (void)
{
	unsigned int	arg;

	for (;;)
	{
		if (ioctl(0, TIOCMGET, &arg) < 0)
		{
			perror("ioctl(TIOCMGET)");
			return 1;
		}

		printf("RTS: %d  CTS: %d  DSR: %d  CAR: %d  DTR: %d  RNG: %d\n",
			!!(arg & TIOCM_RTS),
			!!(arg & TIOCM_CTS),
			!!(arg & TIOCM_DSR),
			!!(arg & TIOCM_CAR),
			!!(arg & TIOCM_DTR),
			!!(arg & TIOCM_RNG)
		);
	}

	return 0;
}

==================================================

	$ gcc -Wall -Wstrict-prototypes test-serial.c -o test-serial
	$ ./test-serial < /dev/ttyS0

-- 
Manuel L�pez Moreno	PGP key ID: 0xC6C9455E
Visita: Web de es.comp.os.linux.* <http://www.escomposlinux.org>
Technical Details
Message-ID: <slrn9f5kis.310.luname@delly.intra.luname.net>
Path: arc1-ca.pugleaf.net!newsfeed.google.com!newsfeed.stanford.edu!news.tele.dk!130.133.1.3!fu-berlin.de!uni-berlin.de!213.98.164.60!not-for-mail
References: <7c3pc9.vd1.ln@127.0.0.1> <slrn9f2j6d.97.luname@delly.intra.luname.net> <48src9.sp2.ln@127.0.0.1>

Show Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII
X-Google-Thread: f86c8,3fd50c75d0339df5
X-Google-Attributes: gidf86c8,public
X-Google-ArrivalTime: 2001-05-04 09:08:10 PST
Path: arc1-ca.pugleaf.net!newsfeed.google.com!newsfeed.stanford.edu!news.tele.dk!130.133.1.3!fu-berlin.de!uni-berlin.de!213.98.164.60!not-for-mail
From: luname@linuxfan.com (Manuel López)
Newsgroups: es.comp.os.linux.programacion
Subject: Re: Detectar si hay un mouse serie conectado a un PC
Date: Fri, 4 May 2001 18:01:34 +0200
Lines: 51
Message-ID: <slrn9f5kis.310.luname@delly.intra.luname.net>
References: <7c3pc9.vd1.ln@127.0.0.1> <slrn9f2j6d.97.luname@delly.intra.luname.net> <48src9.sp2.ln@127.0.0.1>
NNTP-Posting-Host: 213.98.164.60
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: fu-berlin.de 988992488 16155590 213.98.164.60 (16 [66614])
X-Orig-Path: luname
User-Agent: slrn/0.9.7.0 (Linux)