From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan-Benedict Glaw Subject: Re: ioctl fails.... Date: Sun, 16 May 2004 11:18:24 +0200 Sender: linux-c-programming-owner@vger.kernel.org Message-ID: <20040516091823.GG1912@lug-owl.de> References: <40A6F876.50405@sancharnet.in> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="yJGMwzir+WFaxbyA" Return-path: Content-Disposition: inline In-Reply-To: <40A6F876.50405@sancharnet.in> List-Id: To: linux-c-programming@vger.kernel.org --yJGMwzir+WFaxbyA Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, 2004-05-16 10:43:26 +0530, joy wrote in message <40A6F876.50405@sancharnet.in>: > #include > #include > #include > #include parport.h shouldn't be needed. > #include > #include > #include > #include > #include For a small program I wrote, these headers were sufficient: #include #include #include #include #include #include #include #include Generally, try to keep the number of needed OS dependand headers small. That keeps you informed about that needs to be ported if you ever need to go to another OS. > main() > { > int filedes; > char data=3D0xff; > struct timespec time; > filedes=3Dopen("/dev/par0",O_RDWR); > if(ioctl(filedes,PPCLAIM)=3D=3D-1) > perror("OPEN"); > =09 > if(ioctl(filedes, PPWDATA, &data)=3D=3D-1) > perror("Hi"); > time.tv_sec=3D1; > time.tv_nsec=3D1000; > nanosleep(&time,NULL); > close(filedes); > return; > } The code itself looks okay technically (well, early exit on failure would be nice:), but I suspect that you're using a wrong device. Is your device /dev/par0 a char-dev with major=3D99 and minor=3D0? Is the ppdev driver loaded? MfG, JBG --=20 Jan-Benedict Glaw jbglaw@lug-owl.de . +49-172-7608481 "Eine Freie Meinung in einem Freien Kopf | Gegen Zensur | Gegen Krieg fuer einen Freien Staat voll Freier B=FCrger" | im Internet! | im Ira= k! ret =3D do_actions((curr | FREE_SPEECH) & ~(NEW_COPYRIGHT_LAW | DRM | TC= PA)); --yJGMwzir+WFaxbyA Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) iD8DBQFApzHfHb1edYOZ4bsRAvrqAJ4tde8ELQ1OnIH7Mg7DmPC0UkEanQCeOjYQ LJpzU6B7CO50VxVXzUkEzMY= =69tF -----END PGP SIGNATURE----- --yJGMwzir+WFaxbyA--