LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-05-2004, 12:28 PM   #1
Myrdos
LQ Newbie
 
Registered: Feb 2004
Location: Winnipeg, Canada
Distribution: Debian
Posts: 15

Rep: Reputation: 0
Question Can't claim /dev/par0


The following code couts "PPCLAIM error" when run.
The variable name is set to "/dev/par0"
//******************************************
int mode = 0; /* We'll need this later. */
bool result = true;

fd = open (name, O_RDWR);
if (fd == -1)
{
cout << "Error opening " << name << endl;
result = false;
}//if fd

if (result)
{
if (ioctl (fd, PPCLAIM))
{
cout << "PPCLAIM error" << endl;
perror("PPCLAIM");
close (fd);

result = false;
}//if ioctl
}//if result

if (result)
{
mode = IEEE1284_MODE_COMPAT;
if (ioctl (fd, PPNEGOT, &mode))
{
cout << "PPNEGOT error." << endl;
close (fd);
result = false;
}
}//if result
//*****************************************

My understanding is that if I can't claim the port, something else must be using it?

The first few lines given by lsmod are:
Module Size Used by Not tainted
lp 6912 0 (autoclean)
parport_pc 25704 1
parport 21728 1 [lp parport_pc]

However, the lp line is only present after I run my program. If I remove it with rmmod, the lp line will come back each time the program is run.

This is beyond my simple understanding, anyone have ideas on what could be going on? I'm running Debian linux with kernel 2.4.18-bf2.4

I tested the code on a Fedora machine, and it ran perfectly, although I had to change "/dev/par0" to "/dev/parport0". I really need to get this working on Debian though, and any help would be greatly appreciated.
 
Old 10-05-2004, 12:33 PM   #2
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,991

Rep: Reputation: 76
Judging by your use of cout and cin rather than std::cout and std::cin, I suspect that your standard c++ libraries might be quite old. If this is the case, then you should be aware that there have been quite a few problems with older versions when trying to mix stdio.h and iostream; this could be causing you some problems here.

This will give you a more meaningful error message:
Code:
#include <errno.h>
#include <string.h>
Code:
errno = 0;
if (ioctl (fd, PPCLAIM))
{
cout << "PPCLAIM error: " << strerror(errno) << endl;
perror("PPCLAIM");
close (fd);

result = false;
}//if ioctl

Last edited by rjlee; 10-05-2004 at 12:34 PM.
 
Old 10-05-2004, 02:19 PM   #3
Myrdos
LQ Newbie
 
Registered: Feb 2004
Location: Winnipeg, Canada
Distribution: Debian
Posts: 15

Original Poster
Rep: Reputation: 0
When I run the altered code, I get this output:

PPCLAIM error: Invalid argument
PPCLAIM: Invalid argument

It seems that there must be something invalid in ioctl (fd, PPCLAIM)

And yet, it works in Fedora?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Suicide-causing OS may claim another life in OR laserbeamninja Fedora 1 04-13-2005 02:36 PM
how to claim array on shared memory feetyouwell Programming 1 11-04-2004 10:31 AM
SCO's Claim Against IBM/Linux question tarheel92x General 6 04-08-2004 10:07 PM
how to remove packages that claim not to be installed? dynamicit Fedora 2 11-16-2003 08:25 AM
How can MS claim NTFS is secure?? Pcghost General 5 04-08-2003 07:56 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:10 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration