checksquid
March 2nd, 2008, 01:00 PM
Hi all,
I'm a new Ubuntu (and Linux) user, and this forum has been amazingly helpful so far. I think I've finally found something that you haven't already answered (although I found a post that was close).
I am trying to use my parallel port to interface with an electronics project. To start, I am trying a simple "hello world" program to set all of the data pins low, then high. (The timing doesn't matter, I'm just trying to see a response.) I am using a volt meter to watch pin 2 (Data0) in reference to pin 20 (Signal Ground). Unfortunately, the voltemeter is not showing any response--it is always at 0.
Is there a utility I could use to check that the port is working? (It's an old Dell Latitude L400, and I've never used this port before. I'm running Xubuntu.)
Here is the result of dmesg | grep parport
[ 45.284000] parport_pc 00:07: reported by Plug and Play ACPI
[ 45.284000] parport0: PC-style at 0x378 (0x778), irq 7, using FIFO [PCSPP,TRISTATE,COMPAT,ECP]
[ 48.416000] lp0: using parport0 (interrupt-driven).
I am also not a veteran programmer--any suggestions on the code below would be an enormous help.
#include <stdio.h>
#include <sys/io.h>
#include <string.h>
#include <errno.h>
#define PORTBASE 0x378 //printer port base address
int main() {
printf("hello world.\n");
if (ioperm(PORTBASE, 1, 1)) {
printf("Couldn't get the port.\n");
perror("ioperm problem:");
}
outb(0x00, PORTBASE);
perror("Error from outb?");
outb(0xFF, PORTBASE);
perror("Error from outb?");
return 0;
}
That code results in the following output:
weston@weston-laptop:~/C_Test$ sudo gcc -o hello -O2 -Wall hello.c
weston@weston-laptop:~/C_Test$ sudo ./hello
hello world.
Error from outb?: Success
Error from outb?: Illegal seek
weston@weston-laptop:~/C_Test$
Thanks so much for any help!
I'm a new Ubuntu (and Linux) user, and this forum has been amazingly helpful so far. I think I've finally found something that you haven't already answered (although I found a post that was close).
I am trying to use my parallel port to interface with an electronics project. To start, I am trying a simple "hello world" program to set all of the data pins low, then high. (The timing doesn't matter, I'm just trying to see a response.) I am using a volt meter to watch pin 2 (Data0) in reference to pin 20 (Signal Ground). Unfortunately, the voltemeter is not showing any response--it is always at 0.
Is there a utility I could use to check that the port is working? (It's an old Dell Latitude L400, and I've never used this port before. I'm running Xubuntu.)
Here is the result of dmesg | grep parport
[ 45.284000] parport_pc 00:07: reported by Plug and Play ACPI
[ 45.284000] parport0: PC-style at 0x378 (0x778), irq 7, using FIFO [PCSPP,TRISTATE,COMPAT,ECP]
[ 48.416000] lp0: using parport0 (interrupt-driven).
I am also not a veteran programmer--any suggestions on the code below would be an enormous help.
#include <stdio.h>
#include <sys/io.h>
#include <string.h>
#include <errno.h>
#define PORTBASE 0x378 //printer port base address
int main() {
printf("hello world.\n");
if (ioperm(PORTBASE, 1, 1)) {
printf("Couldn't get the port.\n");
perror("ioperm problem:");
}
outb(0x00, PORTBASE);
perror("Error from outb?");
outb(0xFF, PORTBASE);
perror("Error from outb?");
return 0;
}
That code results in the following output:
weston@weston-laptop:~/C_Test$ sudo gcc -o hello -O2 -Wall hello.c
weston@weston-laptop:~/C_Test$ sudo ./hello
hello world.
Error from outb?: Success
Error from outb?: Illegal seek
weston@weston-laptop:~/C_Test$
Thanks so much for any help!