Writing to the parallel port as a normal user

Jacek Wojdel wojdel at chrysler.kbs.twi.tudelft.nl
Thu Nov 29 15:19:34 GMT 2001


On Sunday 25 November 2001 07:17, you wrote:
> Hello All,
>
> I wonder if someone could sort this out for me?
>
> I want to write to and read from the parallel port as a normal user.
>
> This piece of code causes my program to freeze both as root and a normal
> user:
>
>   int fd = open("/dev/lp0", O_RDWR);
>   int res = write(fd, data, 1);
>
> This next piece of code (from the mini howto) works but only if the program
> is run as root:
>
>   /* Get access to the ports */
> //  if (ioperm(BASEPORT, 3, 1)) {perror("ioperm"); exit(1);}
>
>   /* Set the data signals (D0-7) of the port to all low (0) */
> //  outb(0, BASEPORT);
>
> I could set my program, using set setuid, to run as root but that would
> make development and debugging difficult.
>
> What's the answer?

Well, do you have rw permissions to this port (as a user) ? The best way is 
to make the /dev/lp0 group-rw and create a special group of users that are 
allowed to use it:

localhost:~$ ls -l /dev/lp0
crw-rw----    1 root     lp         6,   0 Sep 22 18:33 /dev/lp0
localhost:~$ groups
user cdrom floppy audio video users lp
                                   ^^^^
Does it help ?
	Jacek

-- 
+-------------------------------------+
|from: J.C.Wojdel                     |
|      J.C.Wojdel at cs.tudelft.nl       |
+-------------------------------------+

-
to unsubscribe from this list send an email to kdevelop-request at kdevelop.org with the following body:
unsubscribe »your-email-address«



More information about the KDevelop mailing list