Click to See Complete Forum and Search --> : Programming with the parallel port
Yo yo yo,
In a nutshell, what I want to do in linux is to make pin one on the parallel port, HI, or LO. What ever pin I choose, what ever state I choose.
Does anyone know how to do this in c++??
bwkaz
05-16-2004, 08:55 PM
Maybe.
(Oh, you wanted details? ;))
Well then, you can't make it leave the pin on forever, if it's a data pin. You can output a certain byte to the port to turn some data pins on and others off, but the state of all pins will return to zero after a bit of handshaking occurs (I am assuming you're using either EPP or ECP mode on your parallel port; SPP mode does the same thing, just without the handshaking). As for the non-data pins, you might be able to hack through the details of the parallel port's protocol to do it, but it'd be a huge pain -- you'd need to figure out EPP, then figure out how to turn the pin you want on (which is non-trivial), then figure out how to keep it on.
Well I want to use this program to control LED and Servos, so there will be no "handshaking"?? Does that help you explanation??
bwkaz
05-16-2004, 09:50 PM
No no no, there will be handshaking. This is the parallel port; there is always handshaking going on. The protocols are already defined; you can't put the port into a mode where it doesn't follow one of those protocols.
Just because your hardware isn't going to support it doesn't mean the port isn't going to try anyway... ;)
Originally posted by bwkaz
No no no, there will be handshaking.
OK I thought handshaking meant two devices talking togeather sharing information and whatnot
I did some googleing around and I found parapin http://www.circlemud.org/~jelson/software/parapin/docs/parapin.html, when I read the documentation it looked easy enuff for me to use and it did everything I wanted to do. But when I do the following:
#include <stdio.h>
#include <unistd.h>
#include <iostream.h>
#include "/usr/local/include/parapin.h"
int main()
{
pin_init_user(0x378);
for (int i = 1; i <= 9; i++) {
set_pin(LP_PIN[i]);
usleep(200);
clear_pin(LP_PIN[i]);
}
return 0;
}
Has anyone successfully used parapin??
Hello,
Ive got some code, that works and compiles but I still have to make the hardware to check to see if it does what I want it to do.
#include <stdio.h>
#include <unistd.h> /* needed for ioperm() */
#include <sys/io.h> /* for outb() and inb() */
#include <iostream.h>
#define DATA 888
/*#define DATA 0x378*/
#define STATUS DATA+1
#define CONTROL DATA+2
int main(void) /* 10 */
{
// int x = 0x32;
int x = 0;
int y = 0x08;
if (ioperm(DATA,3,1)) {
printf("Sorry, you were not able to gain access to the ports\n");
printf("You must be root to run this program\n");
// exit(1);
} /* 20 */
// while(int i = 0; i < 1000; i++)
outb(DATA, x); /* Sends 0011 0010 to the Data Port */
// outb(CONTROL, y^0x0b);
/* SELECT_IN = 1, INIT = 0, /AUTO_FEED = 0, /STROBE = 0 */
/* 30 */
return 0;
}
I'm hopeing that his sets port 1 to 0, 2 to 0, 3 to 1, 4 to 1, ... as the binary says. This does what I want it to do right??
I am posting this apology because of my un-provoked ranting on this fourm. I want to especially apologize to everyone who tried to help me when I was too emotional to read what was right infrount of me (I was also able to find a windows solution @ http://www.logix4u.cjb.net/ that I am going to try to port to linux in a few weeks time).
SORRY
Thanks for all the help too
cc: outb() problem - Segmentation fault
(http://www.justlinux.com/forum/showthread.php?s=&threadid=127692)