[Linux-parport] Can't Claim Port

Michael.Schmidt at L-3com.com Michael.Schmidt at L-3com.com
Fri Sep 26 12:45:03 EDT 2008


I'm having problems claiming a parallel port.

I'm running the following commands as root:

  rccups stop
  modprobe -r lp
  modprobe ppdev
  chmod 666 /dev/parport0

If I try "rmmod lp", I get "ERROR: Module lp does not exist
in /proc/modules".

Here is my source code:

#include <cstdlib>
#include <linux/ppdev.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <iostream>
#include <unistd.h> /* for libc5 */
#include <sys/io.h> /* for glibc */

using namespace std;
#define VCGL_BASEPORT  0x378

int main()
  int fd;

  cout <<"before open" << endl;
  ioperm ( VCGL_BASEPORT, 3, 1 ) ;

  fd = open ("/dev/parport0", O_RDWR);
  if (fd == -1) {
    perror ("open");
    return 1;

  // set exclusive
  if (ioctl (fd, PPEXCL)) {
    perror ("PPEXCL");
    close (fd);
    return 1;

  cout << "before claim" << endl;
  if (ioctl (fd, PPCLAIM)) {
    perror ("PPCLAIM");
    close (fd);
    return 1;
  cout << "after claim" << endl;

  return 0;

After I compile and run the program, the following is printed:

  before open
  before claim
  PPCLAIM: No such device or address

If I remove the PPEXCL call, then the PPCLAIM call blocks.  Any help
would be greatly appreciated.


More information about the Linux-parport mailing list