LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Closed Thread
  Search this Thread
Old 05-14-2008, 06:34 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


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-16-2008, 09:39 AM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
You can't use the IO instructions without root permissions. To allows this would completely undermine all security on the system. That is why access to real hardware is done through kernel-mode device drivers. Your application looks as if it is only using the data signals of the parallel port; perhaps simply writing bytes to /dev/lp will suffice.
--- rod.

Last edited by theNbomr; 05-16-2008 at 09:42 AM.
 
Old 05-16-2008, 06:07 PM   #3
cwc
Member
 
Registered: Nov 2004
Location: Tri-Cities, WA
Distribution: Gentoo, Ubuntu, Mint,Fedora
Posts: 71

Original Poster
Rep: Reputation: 16
That's what I thought

Quote:
Originally Posted by theNbomr View Post
You can't use the IO instructions without root permissions. To allows this would completely undermine all security on the system. That is why access to real hardware is done through kernel-mode device drivers. Your application looks as if it is only using the data signals of the parallel port; perhaps simply writing bytes to /dev/lp will suffice.
--- rod.
Thank you very much.

That's what I thought. It looks like I have some work to do
I've looked into a couple of device driver books.
 
Old 05-17-2008, 04:39 PM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,676

Rep: Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892
Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. This thread is being closed because it is a duplicate.
 
  


Closed Thread


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
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
Fasttrak 378 ft3xx.o boot image help Rufus330Ci Mandriva 0 02-01-2006 09:42 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:16 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