LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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 05-15-2008, 07:49 AM   #1
cwc
Member
 
Registered: Nov 2004
Location: Tri-Cities, WA
Distribution: Gentoo, Ubuntu, Mint,Fedora
Posts: 71

Rep: Reputation: 16
./lptloop Couldn't get the port at 378


./lptloop Couldn't get the port at 378
I am building a simple circuit I trying to control from the
parallel port using linux gcc.
I get the following error. I don't understand what I need to
do to get my code to work from a non root user.
Any hint would be appreciated.

./lptloop Couldn't get the port at 378


[code]
// lptloop
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/io.h>
//#include </usr/include/sys/io.h>
#define base 0x378 /* printer port base address */
#define value 255 /* numeric value to send to printer port */
#define value0 0 /* numeric value to send to printer port */
#define value1 1 /* numeric value to send to printer port */
#define value2 2 /* numeric value to send to printer port */
#define value3 4 /* numeric value to send to printer port */
#define value4 8 /* numeric value to send to printer port */
#define value5 16 /* numeric value to send to printer port */
#define value6 32 /* numeric value to send to printer port */
#define value7 64 /* numeric value to send to printer port */
#define value8 128 /* numeric value to send to printer port */

main(int argc, char **argv)
{
int i,p;
if (ioperm(base,1,1))
fprintf(stderr, "Couldn't get the port at %x\n", base), exit(1);

outb(value0, base);//clear printer port
for (p = 0;p < 1000;p++){
outb(value0, base);
sleep(1);
outb(value1, base);
sleep(1);
outb(value2, base);
sleep(1);
outb(value3, base);
sleep(1);
outb(value4, base);
sleep(1);
outb(value5, base);
sleep(1);
outb(value6, base);
sleep(1);
outb(value7, base);
sleep(1);
outb(value8, base);
sleep(1);
}
//outb(value0, base);

}
 
Old 05-17-2008, 04:13 PM   #2
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
You need capability CAP_SYS_RAWIO. Not sure which method of setting it will be best for you, so start from man capabilities.
 
  


Reply



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
$./lptloop Couldn't get the port at 378 cwc Linux - General 3 05-17-2008 04:39 PM
SATA Promise FastTrak 378 Carpo Slackware 2 07-31-2007 06:01 AM
Promise FastTrack 378 SATA HD Help! ericbobbitt Linux - Hardware 3 06-18-2006 03:56 PM
OpenSUSE vs. Promise 378 RAdams SUSE / openSUSE 1 06-03-2006 02:29 PM
fasttrak 378 +suse 10 jseber1982 Linux - Hardware 1 02-07-2006 01:54 PM

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

All times are GMT -5. The time now is 10:38 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
Open Source Consulting | Domain Registration