From: Jan-Benedict Glaw <jbglaw@lug-owl.de>
To: linux-c-programming@vger.kernel.org
Subject: Re: ioctl fails....
Date: Sun, 16 May 2004 11:18:24 +0200 [thread overview]
Message-ID: <20040516091823.GG1912@lug-owl.de> (raw)
In-Reply-To: <40A6F876.50405@sancharnet.in>
[-- Attachment #1: Type: text/plain, Size: 1680 bytes --]
On Sun, 2004-05-16 10:43:26 +0530, joy <gracecott@sancharnet.in>
wrote in message <40A6F876.50405@sancharnet.in>:
> #include<linux/ppdev.h>
> #include<stdlib.h>
> #include<unistd.h>
> #include<linux/parport.h>
parport.h shouldn't be needed.
> #include<time.h>
> #include<sys/types.h>
> #include<sys/stat.h>
> #include<fcntl.h>
> #include<linux/ioctl.h>
For a small program I wrote, these headers were sufficient:
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <linux/ppdev.h>
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=0xff;
> struct timespec time;
> filedes=open("/dev/par0",O_RDWR);
> if(ioctl(filedes,PPCLAIM)==-1)
> perror("OPEN");
>
> if(ioctl(filedes, PPWDATA, &data)==-1)
> perror("Hi");
> time.tv_sec=1;
> time.tv_nsec=1000;
> 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=99 and minor=0? Is the ppdev
driver loaded?
MfG, JBG
--
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ürger" | im Internet! | im Irak!
ret = do_actions((curr | FREE_SPEECH) & ~(NEW_COPYRIGHT_LAW | DRM | TCPA));
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
prev parent reply other threads:[~2004-05-16 9:18 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-05-16 5:13 ioctl fails joy
2004-05-16 9:18 ` Jan-Benedict Glaw [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20040516091823.GG1912@lug-owl.de \
--to=jbglaw@lug-owl.de \
--cc=linux-c-programming@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).